chromium/third_party/blink/common/storage_key/storage_key_unittest.cc

// Copyright 2021 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/public/common/storage_key/storage_key.h"

#include <optional>
#include <string_view>
#include <utility>

#include "base/feature_list.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/unguessable_token.h"
#include "net/base/features.h"
#include "net/base/schemeful_site.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/storage_key/ancestor_chain_bit.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace blink {
namespace {

// Opaqueness here is used as a way of checking for "correctly constructed" in
// most tests.
//
// Why not call it IsValid()? Because some tests actually want to check for
// opaque origins.
bool IsOpaque(const StorageKey& key) {}

}  // namespace

class StorageKeyTest : public ::testing::Test {};

// Test when a constructed StorageKey object should be considered valid/opaque.
TEST_F(StorageKeyTest, ConstructionValidity) {}

// Test that StorageKeys are/aren't equivalent as expected when storage
// partitioning is disabled.
TEST_F(StorageKeyTest, EquivalenceUnpartitioned) {}

// Test that StorageKeys are/aren't equivalent as expected when storage
// partitioning is enabled.
TEST_F(StorageKeyTest, EquivalencePartitioned) {}

// Test that StorageKeys Serialize to the expected value with partitioning
// enabled and disabled.
TEST_F(StorageKeyTest, SerializeFirstParty) {}

TEST_F(StorageKeyTest, SerializeFirstPartyForLocalStorage) {}

// Tests that the top-level site is correctly serialized for service workers
// when kThirdPartyStoragePartitioning is enabled. This is expected to be the
// same for localStorage.
TEST_F(StorageKeyTest, SerializePartitioned) {}

TEST_F(StorageKeyTest, SerializeNonce) {}

// Test that deserialized StorageKeys are valid/opaque as expected.
TEST_F(StorageKeyTest, Deserialize) {}

// Test that string -> StorageKey test function performs as expected.
TEST_F(StorageKeyTest, CreateFromStringForTesting) {}

// Test that a StorageKey, constructed by deserializing another serialized
// StorageKey, is equivalent to the original.
TEST_F(StorageKeyTest, SerializeDeserialize) {}

// Same as SerializeDeserialize but for partitioned StorageKeys when
// kThirdPartyStoragePartitioning is enabled.
TEST_F(StorageKeyTest, SerializeDeserializePartitioned) {}

TEST_F(StorageKeyTest, SerializeDeserializeNonce) {}

TEST_F(StorageKeyTest, SerializeDeserializeOpaqueTopLevelSite) {}

TEST_F(StorageKeyTest, DeserializeNonces) {}

TEST_F(StorageKeyTest, DeserializeAncestorChainBits) {}

TEST_F(StorageKeyTest, IsThirdPartyStoragePartitioningEnabled) {}

// Test that StorageKey's top_level_site getter returns origin's site when
// storage partitioning is disabled.
TEST_F(StorageKeyTest, TopLevelSiteGetterWithPartitioningDisabled) {}

// Test that StorageKey's top_level_site getter returns the top level site when
// storage partitioning is enabled.
TEST_F(StorageKeyTest, TopLevelSiteGetterWithPartitioningEnabled) {}

// Test that cross-origin keys cannot be deserialized when partitioning is
// disabled.
TEST_F(StorageKeyTest, AncestorChainBitGetterWithPartitioningDisabled) {}

// Test that the AncestorChainBit enum class is not reordered and returns the
// correct value when storage partitioning is enabled.
TEST_F(StorageKeyTest, AncestorChainBitGetterWithPartitioningEnabled) {}

TEST_F(StorageKeyTest, IsThirdPartyContext) {}

TEST_F(StorageKeyTest, ToNetSiteForCookies) {}

TEST_F(StorageKeyTest, ToPartialNetIsolationInfo) {}

TEST_F(StorageKeyTest, CopyWithForceEnabledThirdPartyStoragePartitioning) {}

// crbug.com/328043119 remove ToCookiePartitionKeyAncestorChainBitDisabled test
// when kAncestorChainBitEnabledInPartitionedCookies is no longer needed.
TEST_F(StorageKeyTest, ToCookiePartitionKeyAncestorChainBitDisabled) {}

TEST_F(StorageKeyTest, ToCookiePartitionKeyAncestorChainEnabled) {}

TEST_F(StorageKeyTest, NonceRequiresMatchingOriginSiteAndCrossSite) {}

TEST_F(StorageKeyTest, OpaqueTopLevelSiteRequiresCrossSite) {}

TEST_F(StorageKeyTest, ShouldSkipKeyDueToPartitioning) {}

TEST_F(StorageKeyTest, OriginAndSiteMismatchRequiresCrossSite) {}

TEST_F(StorageKeyTest, WithOrigin) {}

// Tests that FromWire() returns true/false correctly.
// If you make a change here, you should probably make it in BlinkStorageKeyTest
// too.
TEST_F(StorageKeyTest, FromWireReturnValue) {}

TEST_F(StorageKeyTest, CreateFromOriginAndIsolationInfo) {}

TEST_F(StorageKeyTest, MalformedOriginsAndSchemefulSites) {}

TEST_F(StorageKeyTest, DeserializeForLocalStorageFirstParty) {}

TEST_F(StorageKeyTest,
       SerializeDeserializeWithAndWithoutThirdPartyStoragePartitioning) {}
}  // namespace blink