mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1530303 - Add WPT test for CrossOriginOpenerPolicy checking that a same-site policy window.open doesn't end up in a different process r=annevk
Differential Revision: https://phabricator.services.mozilla.com/D25158 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
dafa35cef5
commit
36f14c5fe7
@ -0,0 +1,2 @@
|
||||
[new_window_same_site.html]
|
||||
prefs: [browser.tabs.remote.useCrossOriginOpenerPolicy:true]
|
@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
const CHANNEL_NAME = "new_window_same_site";
|
||||
|
||||
async_test(t => {
|
||||
let w = window.open(`${get_host_info().HTTP_REMOTE_ORIGIN}/html/cross-origin-opener/resources/window.sub.html?channel=${CHANNEL_NAME}`, "window_name", "height=200,width=250");
|
||||
|
||||
// w will be closed by its postback iframe. When out of process,
|
||||
// window.close() does not work.
|
||||
t.add_cleanup(() => w.close());
|
||||
|
||||
let bc = new BroadcastChannel(CHANNEL_NAME);
|
||||
bc.onmessage = t.step_func_done((event) => {
|
||||
let payload = event.data;
|
||||
assert_equals(payload.name, "window_name");
|
||||
assert_equals(payload.opener, true);
|
||||
});
|
||||
}, "same-site policy works");
|
||||
|
||||
</script>
|
@ -0,0 +1 @@
|
||||
Cross-Origin-Opener-Policy: same-site
|
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
|
||||
<script>
|
||||
|
||||
let channelName = new URL(location).searchParams.get("channel");
|
||||
let bc = new BroadcastChannel(channelName);
|
||||
window.addEventListener("message", (event) => {
|
||||
bc.postMessage(event.data);
|
||||
window.parent.close();
|
||||
}, false);
|
||||
|
||||
</script>
|
@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<div id="status"> </div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.onload = () => {
|
||||
let payload = { name: self.name, opener: !!self.opener };
|
||||
iframe.contentWindow.postMessage(payload, "*");
|
||||
};
|
||||
let channelName = new URL(location).searchParams.get("channel");
|
||||
iframe.src = `${get_host_info().HTTP_ORIGIN}/html/cross-origin-opener/resources/postback.sub.html?channel=${channelName}`;
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
</script>
|
@ -0,0 +1 @@
|
||||
Cross-Origin-Opener-Policy: same-site
|
Loading…
Reference in New Issue
Block a user