#include "third_party/blink/renderer/core/loader/frame_fetch_context.h"
#include <memory>
#include <optional>
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/web_client_hints_types.mojom-blink.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/device_memory/approximated_device_memory.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink.h"
#include "third_party/blink/public/mojom/timing/resource_timing.mojom-blink-forward.h"
#include "third_party/blink/public/platform/scheduler/web_scoped_virtual_time_pauser.h"
#include "third_party/blink/public/platform/web_document_subresource_filter.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/ad_tracker.h"
#include "third_party/blink/renderer/core/frame/frame_owner.h"
#include "third_party/blink/renderer/core/frame/frame_types.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/loader/frame_resource_fetcher_properties.h"
#include "third_party/blink/renderer/core/loader/subresource_filter.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_initiator_info.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_timing_utils.h"
#include "third_party/blink/renderer/platform/loader/fetch/unique_identifier.h"
#include "third_party/blink/renderer/platform/loader/testing/mock_resource.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/reporting_disposition.h"
namespace blink {
namespace {
class DummyFrameOwner final : public GarbageCollected<DummyFrameOwner>,
public FrameOwner { … };
}
Checkpoint;
class FrameFetchContextMockLocalFrameClient : public EmptyLocalFrameClient { … };
class FixedPolicySubresourceFilter : public WebDocumentSubresourceFilter { … };
class FrameFetchContextTest : public testing::Test { … };
class FrameFetchContextSubresourceFilterTest : public FrameFetchContextTest { … };
class FrameFetchContextMockedLocalFrameClientTest
: public FrameFetchContextTest { … };
class FrameFetchContextModifyRequestTest : public FrameFetchContextTest { … };
TEST_F(FrameFetchContextModifyRequestTest, UpgradeInsecureResourceRequests) { … }
TEST_F(FrameFetchContextModifyRequestTest,
DoNotUpgradeInsecureResourceRequests) { … }
TEST_F(FrameFetchContextModifyRequestTest, IsAutomaticUpgradeSet) { … }
TEST_F(FrameFetchContextModifyRequestTest, IsAutomaticUpgradeNotSet) { … }
TEST_F(FrameFetchContextModifyRequestTest, SendUpgradeInsecureRequestHeader) { … }
class FrameFetchContextHintsTest : public FrameFetchContextTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(FrameFetchContextHintsTest, MonitorDeviceMemorySecureTransport) { … }
TEST_P(FrameFetchContextHintsTest, MonitorDeviceMemoryHintsInsecureContext) { … }
TEST_P(FrameFetchContextHintsTest, MonitorDeviceMemoryHintsLocalContext) { … }
TEST_P(FrameFetchContextHintsTest, MonitorDeviceMemoryHints) { … }
TEST_P(FrameFetchContextHintsTest, MonitorDPRHints) { … }
TEST_P(FrameFetchContextHintsTest, MonitorDPRHintsInsecureTransport) { … }
TEST_P(FrameFetchContextHintsTest, MonitorResourceWidthHints) { … }
TEST_P(FrameFetchContextHintsTest, MonitorViewportWidthHints) { … }
TEST_P(FrameFetchContextHintsTest, MonitorUAHints) { … }
TEST_P(FrameFetchContextHintsTest, MonitorPrefersColorSchemeHint) { … }
TEST_P(FrameFetchContextHintsTest, MonitorPrefersReducedMotionHint) { … }
TEST_P(FrameFetchContextHintsTest, MonitorPrefersReducedTransparencyHint) { … }
TEST_P(FrameFetchContextHintsTest, MonitorAllHints) { … }
TEST_P(FrameFetchContextHintsTest, MonitorAllHintsPermissionsPolicy) { … }
TEST_P(FrameFetchContextHintsTest, MonitorSomeHintsPermissionsPolicy) { … }
TEST_P(FrameFetchContextHintsTest,
MonitorHintsPermissionsPolicyInsecureContext) { … }
TEST_F(FrameFetchContextTest, SubResourceCachePolicy) { … }
TEST_P(FrameFetchContextHintsTest, EnableDataSaver) { … }
TEST_P(FrameFetchContextHintsTest, DisabledDataSaver) { … }
TEST_P(FrameFetchContextHintsTest, ChangeDataSaverConfig) { … }
TEST_F(FrameFetchContextSubresourceFilterTest, Filter) { … }
TEST_F(FrameFetchContextSubresourceFilterTest, Allow) { … }
TEST_F(FrameFetchContextSubresourceFilterTest, DuringOnFreeze) { … }
TEST_F(FrameFetchContextSubresourceFilterTest, WouldDisallow) { … }
TEST_F(FrameFetchContextTest, AddAdditionalRequestHeadersWhenDetached) { … }
TEST_F(FrameFetchContextTest, ResourceRequestCachePolicyWhenDetached) { … }
TEST_F(FrameFetchContextMockedLocalFrameClientTest,
PrepareRequestWhenDetached) { … }
TEST_F(FrameFetchContextTest, PrepareRequestHistogramCount) { … }
TEST_F(FrameFetchContextTest, AddResourceTimingWhenDetached) { … }
TEST_F(FrameFetchContextTest, AllowImageWhenDetached) { … }
TEST_F(FrameFetchContextTest, PopulateResourceRequestWhenDetached) { … }
TEST_F(FrameFetchContextTest, SetFirstPartyCookieWhenDetached) { … }
TEST_F(FrameFetchContextTest, TopFrameOrigin) { … }
TEST_F(FrameFetchContextTest, TopFrameOriginDetached) { … }
TEST_F(FrameFetchContextSubresourceFilterTest,
CanRequestBasedOnSubresourceFilterOnly) { … }
TEST_F(FrameFetchContextSubresourceFilterTest,
CalculateIfAdSubresourceWithAliasURL) { … }
class FrameFetchContextDisableReduceAcceptLanguageTest
: public FrameFetchContextTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(FrameFetchContextDisableReduceAcceptLanguageTest,
VerifyReduceAcceptLanguage) { … }
}