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
|
// This is a helper file used for the attribution-reporting-*.https.html tests.
// To use this, make sure you import these scripts:
// <script src="/resources/testharness.js"></script>
// <script src="/resources/testharnessreport.js"></script>
// <script src="/common/utils.js"></script>
// <script src="/common/dispatcher/dispatcher.js"></script>
// <script src="resources/utils.js"></script>
// <script src="/common/get-host-info.sub.js"></script>
async function runDefaultEnabledFeaturesTest(t, should_load, fenced_origin,
generator_api="fledge", allow="") {
const fencedframe = await attachFencedFrameContext({
generator_api: generator_api,
attributes: [["allow", allow]],
origin: fenced_origin});
if (!should_load) {
const fencedframe_blocked = new Promise(r => t.step_timeout(r, 1000));
const fencedframe_loaded = fencedframe.execute(() => {});
assert_equals(await Promise.any([
fencedframe_blocked.then(() => "blocked"),
fencedframe_loaded.then(() => "loaded"),
]), "blocked", "The fenced frame should not be loaded.");
return;
}
await fencedframe.execute((generator_api) => {
assert_true(
document.featurePolicy.allowsFeature('attribution-reporting'),
"Attribution reporting should be allowed if the fenced " +
"frame loaded using FLEDGE or shared storage.");
if (generator_api == "fledge") {
assert_false(
document.featurePolicy.allowsFeature('shared-storage'),
"Shared storage should be disallowed if the fenced " +
"frame loaded using FLEDGE.");
} else {
assert_true(
document.featurePolicy.allowsFeature('shared-storage'),
"Shared storage should be allowed if the fenced " +
"frame loaded using shared storage.");
}
}, [generator_api]);
}
|