Skip to content

Commit

Permalink
Fenced frames: Disable popup navigations after network revocation
Browse files Browse the repository at this point in the history
Navigations into and out of fenced frames need to be treated specially
for network revocation, because they don't have the revoked partition
nonce attached.

Previous CLs disabled embedder-initiated fenced frame root navigations
and _unfencedTop navigations; this CL disables popup navigations.

Bug: 1515599
Change-Id: Ia05e3fecb40240de1d32a3e736e42eba5f03f411
  • Loading branch information
Garrett Tanzer authored and chromium-wpt-export-bot committed Feb 14, 2024
1 parent 2329ca0 commit e521a89
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fenced-frame/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ function buildRemoteContextForObject(object, uuid, html) {
}
};

// If `object` is null (e.g. a window created with noopener), set it to a
// dummy value so that the Proxy constructor won't fail.
if (object == null) {
object = {};
}
const proxy = new Proxy(object, handler);
return proxy;
}
Expand Down
47 changes: 47 additions & 0 deletions fenced-frame/revoke-popup.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<title>Test that window.fence.disableUntrustedNetwork disables
popup navigations.</title>
<meta name="timeout" content="long">
<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="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<body>
<script>

promise_test(async(t) => {
const fencedframe = await attachFencedFrameContext({generator_api: 'fledge'});
await fencedframe.execute(() => {});

const actions = new test_driver.Actions();
await actions.setContext(window)
.pointerMove(0, 0, {origin: fencedframe.element})
.pointerDown()
.pointerUp()
.send();

await fencedframe.execute(async () => {
await window.fence.disableUntrustedNetwork();
// After disabling network, popup navigations should not work.
assert_true(navigator.userActivation.isActive,
'The frame should have user activation.');
window.popup = attachWindowContext();
});

const result = await Promise.race([
fencedframe.execute(async () => {
return await window.popup.execute(() => { return 'popup_loaded'; });
}),
new Promise((resolve) => t.step_timeout(
() => resolve('timeout'), 2000))
]);
assert_equals(result, 'timeout');
}, 'window.fence.disableUntrustedNetwork disables popup navigations');

</script>
</body>

0 comments on commit e521a89

Please sign in to comment.