Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fenced frames: Disable popup navigations after network revocation #44552

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>