1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
content / public / test / shared_storage_test_utils.h [blame]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_TEST_SHARED_STORAGE_TEST_UTILS_H_
#define CONTENT_PUBLIC_TEST_SHARED_STORAGE_TEST_UTILS_H_
#include <stddef.h>
#include <string>
#include "base/memory/weak_ptr.h"
#include "base/strings/string_split.h"
#include "components/services/storage/shared_storage/shared_storage_manager.h"
#include "content/browser/private_aggregation/private_aggregation_host.h"
#include "services/network/public/mojom/optional_bool.mojom.h"
#include "services/network/public/mojom/url_loader_network_service_observer.mojom.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/origin.h"
class GURL;
namespace content {
class RenderFrameHost;
class SharedStorageWorkletHostManager;
class StoragePartition;
class TestSharedStorageHeaderObserver;
using FencedFrameNavigationTarget = absl::variant<GURL, std::string>;
using OperationResult = storage::SharedStorageManager::OperationResult;
using OperationType = network::mojom::SharedStorageOperationType;
using OperationPtr = network::mojom::SharedStorageOperationPtr;
SharedStorageWorkletHostManager*
GetSharedStorageWorkletHostManagerForStoragePartition(
StoragePartition* storage_partition);
std::string GetFencedFrameLocalUnpartitionedDataAccessDisabledMessage();
std::string
GetFencedFrameLocalUnpartitionedDataAccessWithoutRevokeNetworkMessage();
std::string GetSharedStorageDisabledMessage();
std::string GetSharedStorageSelectURLDisabledMessage();
std::string GetSharedStorageAddModuleDisabledMessage();
size_t GetAttachedSharedStorageWorkletHostsCount(
StoragePartition* storage_partition);
size_t GetKeepAliveSharedStorageWorkletHostsCount(
StoragePartition* storage_partition);
// TODO(crbug.com/40256120): This function should be removed. Use
// `CreateFencedFrame` in fenced_frame_test_util.h instead.
RenderFrameHost* CreateFencedFrame(RenderFrameHost* root,
const FencedFrameNavigationTarget& target);
[[nodiscard]] network::mojom::OptionalBool AbslToMojomOptionalBool(
std::optional<bool> opt_bool);
// In order to use gmock matchers, it's necessary to copy the members of
// `OperationPtr` into a copyable struct or tuple. We also bundle them with the
// `request_origin` and `result`.
struct SharedStorageWriteOperationAndResult {
static SharedStorageWriteOperationAndResult SetOperation(
const url::Origin& request_origin,
std::string key,
std::string value,
std::optional<bool> ignore_if_present,
OperationResult result);
static SharedStorageWriteOperationAndResult AppendOperation(
const url::Origin& request_origin,
std::string key,
std::string value,
OperationResult result);
static SharedStorageWriteOperationAndResult DeleteOperation(
const url::Origin& request_origin,
std::string key,
OperationResult result);
static SharedStorageWriteOperationAndResult ClearOperation(
const url::Origin& request_origin,
OperationResult result);
SharedStorageWriteOperationAndResult(const url::Origin& request_origin,
OperationType operation_type,
std::optional<std::string> key,
std::optional<std::string> value,
std::optional<bool> ignore_if_present,
OperationResult result);
SharedStorageWriteOperationAndResult(
const url::Origin& request_origin,
OperationType operation_type,
std::optional<std::string> key,
std::optional<std::string> value,
network::mojom::OptionalBool ignore_if_present,
OperationResult result);
SharedStorageWriteOperationAndResult(const url::Origin& request_origin,
OperationPtr operation,
OperationResult result);
SharedStorageWriteOperationAndResult(
const SharedStorageWriteOperationAndResult&);
~SharedStorageWriteOperationAndResult();
url::Origin request_origin;
OperationType operation_type;
std::optional<std::string> key;
std::optional<std::string> value;
std::optional<bool> ignore_if_present;
OperationResult result;
};
bool operator==(const SharedStorageWriteOperationAndResult& a,
const SharedStorageWriteOperationAndResult& b);
PrivateAggregationHost::PipeResult
GetPrivateAggregationHostPipeReportSuccessValue();
PrivateAggregationHost::PipeResult
GetPrivateAggregationHostPipeApiDisabledValue();
base::WeakPtr<TestSharedStorageHeaderObserver>
CreateAndOverrideSharedStorageHeaderObserver(StoragePartition* partition);
base::StringPairs SharedStorageCrossOriginWorkletResponseHeaderReplacement(
const std::string& access_control_allow_origin_replacement,
const std::string& shared_storage_cross_origin_allowed_replacement);
} // namespace content
#endif // CONTENT_PUBLIC_TEST_SHARED_STORAGE_TEST_UTILS_H_