chromium/third_party/blink/renderer/core/loader/document_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

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

#include <utility>

#include "base/auto_reset.h"
#include "base/containers/span.h"
#include "base/rand_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/unguessable_token.h"
#include "net/storage_access_api/status.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_encoding_data.h"
#include "third_party/blink/public/platform/web_navigation_body_loader.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/renderer/core/dom/visited_link_state.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/testing/scoped_fake_plugin_registry.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/loader/fetch/url_loader/url_loader_client.h"
#include "third_party/blink/renderer/platform/loader/static_data_navigation_body_loader.h"
#include "third_party/blink/renderer/platform/network/blink_schemeful_site.h"
#include "third_party/blink/renderer/platform/storage/blink_storage_key.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_loader_mock_factory.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/deque.h"

namespace blink {
namespace {

// Forwards calls from BodyDataReceived() to DecodedBodyDataReceived().
class DecodedBodyLoader : public StaticDataNavigationBodyLoader {};

class BodyLoaderTestDelegate : public URLLoaderTestDelegate {};

// This struct contains the three elements of the :visited links
// triple-parititon key for storage and comparison in this test.
struct TestVisitedLink {};

// To test (1) the abiltity to obtain and store the per-origin salt used in
// partitioning visited links and (2) the ability of VisitedLinkState to query
// for partitioned visited links using those salts, we need to override the
// Platform::Current() used in this test. Our platform will obtain and store the
// per-origin salt values locally in `salts_` and mock out calls to the
// partitioned hashtable stored in VisitedLinkReader via
// `partitioned_hashtable_`.
class VisitedLinkPlatform : public TestingPlatformSupport {};

enum TestMode {};

class DocumentLoaderTest : public testing::Test,
                           public ::testing::WithParamInterface<TestMode> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(DocumentLoaderTest, SingleChunk) {}

// Test normal case of DocumentLoader::dataReceived(): data in multiple chunks,
// with no reentrancy.
TEST_P(DocumentLoaderTest, MultiChunkNoReentrancy) {}

// Finally, test reentrant callbacks to DocumentLoader::BodyDataReceived().
TEST_P(DocumentLoaderTest, MultiChunkWithReentrancy) {}

TEST_P(DocumentLoaderTest, isCommittedButEmpty) {}

class DocumentLoaderSimTest : public SimTest {};

TEST_F(DocumentLoaderSimTest, DocumentOpenUpdatesUrl) {}

TEST_F(DocumentLoaderSimTest, FramePolicyIntegrityOnNavigationCommit) {}

TEST_P(DocumentLoaderTest, CommitsDeferredOnSameOriginNavigation) {}

TEST_P(DocumentLoaderTest,
       CommitsNotDeferredOnDifferentOriginNavigationWithCrossOriginDisabled) {}

TEST_P(DocumentLoaderTest,
       CommitsDeferredOnDifferentOriginNavigationWithCrossOriginEnabled) {}

TEST_P(DocumentLoaderTest,
       CommitsNotDeferredOnDifferentPortNavigationWithCrossOriginDisabled) {}

TEST_P(DocumentLoaderTest,
       CommitsDeferredOnDifferentPortNavigationWithCrossOriginEnabled) {}

TEST_P(DocumentLoaderTest, CommitsNotDeferredOnDataURLNavigation) {}

TEST_P(DocumentLoaderTest,
       CommitsNotDeferredOnDataURLNavigationWithCrossOriginEnabled) {}

TEST_P(DocumentLoaderTest, NavigationToAboutBlank) {}

TEST_P(DocumentLoaderTest, SameOriginNavigation) {}

TEST_P(DocumentLoaderTest, SameOriginNavigation_WithStorageAccess) {}

TEST_P(DocumentLoaderTest, CrossOriginNavigation) {}

TEST_P(DocumentLoaderTest, StorageKeyFromNavigationParams) {}

TEST_P(DocumentLoaderTest, StorageKeyCrossSiteFromNavigationParams) {}

// Tests that committing a Javascript URL keeps the storage key's nonce of the
// previous document, ensuring that
// `DocumentLoader::CreateWebNavigationParamsToCloneDocument` works correctly
// w.r.t. storage key.
TEST_P(DocumentLoaderTest, JavascriptURLKeepsStorageKeyNonce) {}

// Tests that discarding the frame keeps the storage key's nonce of the previous
// document, ensuring that
// `DocumentLoader::CreateWebNavigationParamsToCloneDocument` works correctly
// w.r.t. storage key.
TEST_P(DocumentLoaderTest, DiscardingFrameKeepsStorageKeyNonce) {}

TEST_P(DocumentLoaderTest, PublicSecureNotCounted) {}

TEST_P(DocumentLoaderTest, PublicNonSecureNotCounted) {}

TEST_P(DocumentLoaderTest, PrivateSecureNotCounted) {}

TEST_P(DocumentLoaderTest, PrivateNonSecureIsCounted) {}

TEST_P(DocumentLoaderTest, LocalNonSecureIsCounted) {}

TEST_F(DocumentLoaderSimTest, PrivateNonSecureChildFrameNotCounted) {}

TEST_P(DocumentLoaderTest, DecodedBodyData) {}

TEST_P(DocumentLoaderTest, DecodedBodyDataWithBlockedParser) {}

TEST_P(DocumentLoaderTest, EmbeddedCredentialsNavigation) {}

TEST_P(DocumentLoaderTest, VisitedLinkSalt) {}

TEST_P(DocumentLoaderTest, PartitionedVisitedLinksMainFrame) {}

}  // namespace
}  // namespace blink