Skip to content

Commit c5c8964

Browse files
Garrett Tanzermarcoscaceres
Garrett Tanzer
authored andcommitted
Fenced frames: Disable embedder-initiated fenced frame navigations after network revocation [1/2]
This CL disables the ability for embedders to initiate fenced frame config navigations after network has been revoked. The next CL in this series will prevent fenced frame config navigations that are in progress at the time of network revocation from committing. Bug: 1515599 Change-Id: Id136c27bc302c7d38d8d80034ade3cbbee9b646e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5201401 Reviewed-by: Dominic Farolino <[email protected]> Commit-Queue: Garrett Tanzer <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254507}
1 parent 22be582 commit c5c8964

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!DOCTYPE html>
2+
<title>Test that window.fence.disableUntrustedNetwork disables
3+
embedder-initiated navigation of nested fenced frames.</title>
4+
<meta name="timeout" content="long">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/common/utils.js"></script>
8+
<script src="/common/dispatcher/dispatcher.js"></script>
9+
<script src="resources/utils.js"></script>
10+
11+
<body>
12+
<script>
13+
14+
// Run a test with a fenced frame nested in a fenced frame.
15+
// If `should_disable_network` is true, window.fence.disableUntrustedNetwork
16+
// will be called before creating the nested fenced frame.
17+
async function ff_ff_test(t, should_disable_network) {
18+
const fencedframe = await attachFencedFrameContext();
19+
return Promise.race([
20+
fencedframe.execute(async (should_disable_network) => {
21+
if (should_disable_network) {
22+
await window.fence.disableUntrustedNetwork();
23+
}
24+
const nested_fenced_frame = await attachFencedFrameContext();
25+
return nested_fenced_frame.execute(() => { return 'nav success'; }); },
26+
[should_disable_network]),
27+
new Promise((resolve, reject) => t.step_timeout(
28+
() => resolve('timeout'), 3000))
29+
]);
30+
}
31+
32+
// Run a test with a fenced frame nested in an iframe nested in a fenced frame.
33+
// If `should_disable_network` is true, window.fence.disableUntrustedNetwork
34+
// will be called before creating the nested fenced frame.
35+
// If `use_urn_iframe` is true, the nested iframe will be a urn iframe.
36+
async function ff_if_ff_test(t, should_disable_network, use_urn_iframe) {
37+
const fencedframe = await attachFencedFrameContext({generator_api: 'sharedstorage'});
38+
return Promise.race([
39+
fencedframe.execute(async (should_disable_network, use_urn_iframe) => {
40+
let args = {};
41+
if (use_urn_iframe) {
42+
args = {generator_api: 'sharedstorage'};
43+
}
44+
const nested_iframe = await attachIFrameContext(args);
45+
await nested_iframe.execute(() => {});
46+
if (should_disable_network) {
47+
await window.fence.disableUntrustedNetwork();
48+
}
49+
return nested_iframe.execute(async () => {
50+
const nested_fenced_frame = await attachFencedFrameContext({
51+
generator_api: 'sharedstorage'});
52+
return nested_fenced_frame.execute(() => { return 'nav success'; });
53+
});
54+
},
55+
[should_disable_network, use_urn_iframe]),
56+
new Promise((resolve, reject) => t.step_timeout(
57+
() => resolve('timeout'), 3000))
58+
]);
59+
}
60+
61+
promise_test(async(t) => {
62+
const result = await ff_ff_test(t, /*should_disable_network=*/false);
63+
assert_equals(result, 'nav success');
64+
}, 'FF->FF navigation works');
65+
66+
promise_test(async(t) => {
67+
const result = await ff_ff_test(t, /*should_disable_network=*/true);
68+
assert_equals(result, 'timeout');
69+
}, 'window.fence.disableUntrustedNetwork disables FF->FF navigation');
70+
71+
promise_test(async(t) => {
72+
const result = await ff_if_ff_test(t, /*should_disable_network=*/false, /*use_urn_iframe=*/false);
73+
assert_equals(result, 'nav success');
74+
}, 'FF->IF->FF navigation works');
75+
76+
promise_test(async(t) => {
77+
const result = await ff_if_ff_test(t, /*should_disable_network=*/false, /*use_urn_iframe=*/true);
78+
assert_equals(result, 'nav success');
79+
}, 'FF->UIF->FF navigation works');
80+
81+
promise_test(async(t) => {
82+
const result = await ff_if_ff_test(t, /*should_disable_network=*/true, /*use_urn_iframe=*/false);
83+
assert_equals(result, 'timeout');
84+
}, 'window.fence.disableUntrustedNetwork disables FF->IF->FF navigation');
85+
86+
promise_test(async(t) => {
87+
const result = await ff_if_ff_test(t, /*should_disable_network=*/true, /*use_urn_iframe=*/true);
88+
assert_equals(result, 'timeout');
89+
}, 'window.fence.disableUntrustedNetwork disables FF->UF->FF navigation');
90+
</script>
91+
</body>

0 commit comments

Comments
 (0)