chromium/third_party/blink/renderer/core/loader/link_loader_test.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/loader/link_loader.h"

#include <memory>

#include "base/task/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_mock_time_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/loader/referrer_utils.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/platform/web_prescient_networking.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.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/settings.h"
#include "third_party/blink/renderer/core/html/link_rel_attribute.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/link_loader_client.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_fetch_request.h"
#include "third_party/blink/renderer/core/loader/pending_link_preload.h"
#include "third_party/blink/renderer/core/loader/resource/link_dictionary_resource.h"
#include "third_party/blink/renderer/core/testing/dummy_modulator.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/testing/scoped_mock_overlay_scrollbars.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.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/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/url_loader_mock_factory.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"

namespace blink {

namespace {

class MockLinkLoaderClient final
    : public GarbageCollected<MockLinkLoaderClient>,
      public LinkLoaderClient {};

class NetworkHintsMock : public WebPrescientNetworking {};

class LinkLoaderPreloadTestBase : public testing::Test,
                                  private ScopedMockOverlayScrollbars {};

struct PreloadTestParams {};

constexpr PreloadTestParams kPreloadTestParams[] =;

class LinkLoaderPreloadTest
    : public LinkLoaderPreloadTestBase,
      public testing::WithParamInterface<PreloadTestParams> {};

TEST_P(LinkLoaderPreloadTest, Preload) {}

INSTANTIATE_TEST_SUITE_P();

struct PreloadMimeTypeTestParams {};

constexpr PreloadMimeTypeTestParams kPreloadMimeTypeTestParams[] =;

class LinkLoaderPreloadMimeTypeTest
    : public LinkLoaderPreloadTestBase,
      public testing::WithParamInterface<PreloadMimeTypeTestParams> {};

TEST_P(LinkLoaderPreloadMimeTypeTest, Preload) {}

INSTANTIATE_TEST_SUITE_P();

struct PreloadMediaTestParams {};

constexpr PreloadMediaTestParams kPreloadMediaTestParams[] =;

class LinkLoaderPreloadMediaTest
    : public LinkLoaderPreloadTestBase,
      public testing::WithParamInterface<PreloadMediaTestParams> {};

TEST_P(LinkLoaderPreloadMediaTest, Preload) {}

INSTANTIATE_TEST_SUITE_P();

constexpr network::mojom::ReferrerPolicy kPreloadReferrerPolicyTestParams[] =;

class LinkLoaderPreloadReferrerPolicyTest
    : public LinkLoaderPreloadTestBase,
      public testing::WithParamInterface<network::mojom::ReferrerPolicy> {};

TEST_P(LinkLoaderPreloadReferrerPolicyTest, Preload) {}

INSTANTIATE_TEST_SUITE_P();

struct PreloadNonceTestParams {};

constexpr PreloadNonceTestParams kPreloadNonceTestParams[] =;

class LinkLoaderPreloadNonceTest
    : public LinkLoaderPreloadTestBase,
      public testing::WithParamInterface<PreloadNonceTestParams> {};

TEST_P(LinkLoaderPreloadNonceTest, Preload) {}

INSTANTIATE_TEST_SUITE_P();

struct PreloadImageSrcsetTestParams {};

constexpr PreloadImageSrcsetTestParams kPreloadImageSrcsetTestParams[] =;

class LinkLoaderPreloadImageSrcsetTest
    : public LinkLoaderPreloadTestBase,
      public testing::WithParamInterface<PreloadImageSrcsetTestParams> {};

TEST_P(LinkLoaderPreloadImageSrcsetTest, Preload) {}

INSTANTIATE_TEST_SUITE_P();

struct ModulePreloadTestParams {};

constexpr ModulePreloadTestParams kModulePreloadTestParams[] =;

class LinkLoaderModulePreloadTest
    : public testing::TestWithParam<ModulePreloadTestParams>,
      private ScopedMockOverlayScrollbars {};

class ModulePreloadTestModulator final : public DummyModulator {};

TEST_P(LinkLoaderModulePreloadTest, ModulePreload) {}

INSTANTIATE_TEST_SUITE_P();

class LinkLoaderTestPrefetchPrivacyChanges
    : public testing::Test,
      public testing::WithParamInterface<bool>,
      private ScopedMockOverlayScrollbars {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(LinkLoaderTestPrefetchPrivacyChanges, PrefetchPrivacyChanges) {}

class LinkLoaderTest : public testing::Test,
                       private ScopedMockOverlayScrollbars {};

TEST_F(LinkLoaderTest, Prefetch) {}

TEST_F(LinkLoaderTest, DNSPrefetch) {}

TEST_F(LinkLoaderTest, Preconnect) {}

TEST_F(LinkLoaderTest, PreloadAndPrefetch) {}

class DictionaryLinkTest : public testing::Test,
                           public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(DictionaryLinkTest, LoadDictionaryFromLink) {}

}  // namespace

// Required to be outside the anomymous namespace for testing
class DictionaryLoadFromHeaderTest : public SimTest,
                                     public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(DictionaryLoadFromHeaderTest, LoadDictionaryFromHeader) {}

}  // namespace blink