#include <stddef.h>
#include <stdint.h>
#include <map>
#include <memory>
#include <tuple>
#include "base/containers/queue.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/time_formatting.h"
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/renderer_host/chrome_navigation_ui_data.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/prefs/pref_member.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/browser/api/declarative_net_request/test_utils.h"
#include "extensions/browser/api/web_request/extension_web_request_event_router.h"
#include "extensions/browser/api/web_request/upload_data_presenter.h"
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/api/web_request/web_request_api_constants.h"
#include "extensions/browser/api/web_request/web_request_api_helpers.h"
#include "extensions/browser/api/web_request/web_request_info.h"
#include "extensions/common/api/declarative_net_request.h"
#include "extensions/common/api/web_request.h"
#include "extensions/common/constants.h"
#include "extensions/common/features/feature.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-message.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom-forward.h"
helpers;
keys;
web_request;
dnr_api;
Time;
CalculateOnAuthRequiredDelta;
CalculateOnBeforeRequestDelta;
CalculateOnBeforeSendHeadersDelta;
CalculateOnHeadersReceivedDelta;
CharListToString;
EventResponseDelta;
EventResponseDeltas;
ExtraInfoSpec;
InDecreasingExtensionInstallationTimeOrder;
MergeCancelOfResponses;
MergeOnBeforeRequestResponses;
RequestCookieModification;
ResponseCookieModification;
ResponseHeader;
ResponseHeaders;
StringToCharList;
ElementsAre;
DNRRequestAction;
namespace extensions {
namespace {
constexpr const char kExampleUrl[] = …;
bool HasIgnoredAction(const helpers::IgnoredActions& ignored_actions,
const std::string& extension_id,
web_request::IgnoredActionType action_type) { … }
}
class ExtensionWebRequestTest : public testing::Test { … };
namespace {
bool GenerateInfoSpec(content::BrowserContext* browser_context,
const std::string& values,
int* result) { … }
}
TEST_F(ExtensionWebRequestTest, AddAndRemoveListeners) { … }
TEST_F(ExtensionWebRequestTest, BrowserContextShutdown) { … }
namespace {
void TestInitFromValue(content::BrowserContext* browser_context,
const std::string& values,
bool expected_return_code,
int expected_extra_info_spec) { … }
}
TEST_F(ExtensionWebRequestTest, InitFromValue) { … }
TEST(ExtensionWebRequestHelpersTest,
TestInDecreasingExtensionInstallationTimeOrder) { … }
TEST(ExtensionWebRequestHelpersTest, TestStringToCharList) { … }
TEST(ExtensionWebRequestHelpersTest, TestCalculateOnBeforeRequestDelta) { … }
TEST(ExtensionWebRequestHelpersTest, TestCalculateOnBeforeSendHeadersDelta) { … }
TEST(ExtensionWebRequestHelpersTest,
TestCalculateOnBeforeSendHeadersDeltaWithExtraHeaders) { … }
TEST(ExtensionWebRequestHelpersTest, TestCalculateOnHeadersReceivedDelta) { … }
TEST(ExtensionWebRequestHelpersTest,
TestCalculateOnHeadersReceivedDeltaWithExtraHeaders) { … }
TEST(ExtensionWebRequestHelpersTest, TestCalculateOnAuthRequiredDelta) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeCancelOfResponses) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses2) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses3) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeRequestResponses4) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnBeforeSendHeadersResponses) { … }
namespace {
struct ExpectedHeader { … };
void ExecuteDNRActionsAndCheckHeaders(
const WebRequestInfo& info,
net::HttpRequestHeaders base_headers,
const std::vector<ExpectedHeader>& expected_headers) { … }
}
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnBeforeSendHeadersResponses_DeclarativeNetRequest_Append) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnBeforeSendHeadersResponses_DeclarativeNetRequest_Set) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnBeforeSendHeadersResponses_DeclarativeNetRequest_Remove) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnBeforeSendHeadersResponses_Conflicts) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnBeforeSendHeadersResponses_Cookies) { … }
namespace {
std::string GetCookieExpirationDate(int delta_secs) { … }
}
TEST(ExtensionWebRequestHelpersTest,
TestMergeCookiesInOnHeadersReceivedResponses) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnHeadersReceivedResponses) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnHeadersReceivedResponsesDeletion) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnHeadersReceivedResponsesRedirect) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnHeadersReceivedResponses_DeclarativeNetRequest) { … }
TEST(ExtensionWebRequestHelpersTest,
TestMergeOnHeadersReceivedResponses_DeclarativeNetRequestMetrics) { … }
TEST(ExtensionWebRequestHelpersTest, TestMergeOnAuthRequiredResponses) { … }
}