зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533877 - Add test for that navigating popups to a null policy fails, even if the opener is closed r=annevk
Differential Revision: https://phabricator.services.mozilla.com/D32975 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f9ee2f312f
Коммит
29b6418ffd
|
@ -118,7 +118,6 @@ async_test(t => {
|
|||
|
||||
let win = window.open(`resources/navigate_anonymous.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank", "noopener");
|
||||
|
||||
}, 500);
|
||||
}, "Top-level noopener with anonymous policy: navigating to a different policy should work");
|
||||
|
||||
promise_test(t => {
|
||||
|
@ -129,4 +128,92 @@ promise_test(t => {
|
|||
});
|
||||
}, "Fetch policy: anonymous policy no-cors fetches should be changed to cors");
|
||||
|
||||
|
||||
async_test(t => {
|
||||
let pageLoaded = false;
|
||||
const CHANNEL_NAME = "anon-null-window";
|
||||
let bc = new BroadcastChannel(CHANNEL_NAME);
|
||||
bc.onmessage = t.step_func_done((event) => {
|
||||
pageLoaded = true;
|
||||
let payload = event.data;
|
||||
assert_equals(payload, "loaded");
|
||||
});
|
||||
|
||||
const SECOND_CHANNEL = "anon-null-window-second";
|
||||
let navigated = false;
|
||||
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
|
||||
bc2.onmessage = t.step_func((event) => {
|
||||
navigated = true;
|
||||
let payload = event.data;
|
||||
assert_equals(payload, "loaded");
|
||||
});
|
||||
|
||||
let win = window.open(`resources/navigate_anonymous.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank");
|
||||
t.add_cleanup(() => win.close());
|
||||
t.step_timeout(() => {
|
||||
assert_equals(pageLoaded, true, "Opening the popup window from anon window should work");
|
||||
assert_equals(navigated, false, "Navigating the popup to a null policy should fail");
|
||||
t.done();
|
||||
}, 500);
|
||||
}, "Top-level popup with anonymous policy: Navigating the popup to a null policy should fail.");
|
||||
|
||||
async_test(t => {
|
||||
let pageLoaded = false;
|
||||
const CHANNEL_NAME = "anon-null-window";
|
||||
let bc = new BroadcastChannel(CHANNEL_NAME);
|
||||
bc.onmessage = t.step_func_done((event) => {
|
||||
pageLoaded = true;
|
||||
let payload = event.data;
|
||||
assert_equals(payload, "loaded");
|
||||
});
|
||||
|
||||
const SECOND_CHANNEL = "anon-null-window-second";
|
||||
let navigated = false;
|
||||
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
|
||||
bc2.onmessage = t.step_func((event) => {
|
||||
navigated = true;
|
||||
let payload = event.data;
|
||||
assert_equals(payload, "loaded");
|
||||
});
|
||||
|
||||
let win = window.open(`resources/navigate_anonymous.sub.html?clearOpener=true&channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank");
|
||||
t.add_cleanup(() => win.close());
|
||||
t.step_timeout(() => {
|
||||
assert_equals(pageLoaded, true, "Opening the popup window from anon window should work");
|
||||
assert_equals(navigated, false, "Navigating the popup to a null policy should fail");
|
||||
t.done();
|
||||
}, 500);
|
||||
}, "Top-level popup with anonymous policy: Navigating the popup to a null policy should fail. (even when we clear the opener)");
|
||||
|
||||
async_test(t => {
|
||||
let popupLoaded = false;
|
||||
const CHANNEL_NAME = "anon-null-window-no-opener";
|
||||
let bc = new BroadcastChannel(CHANNEL_NAME);
|
||||
bc.onmessage = t.step_func_done((event) => {
|
||||
let payload = event.data;
|
||||
if (payload == "loaded") {
|
||||
t.step_timeout(() => {
|
||||
assert_equals(popupLoaded, true, "Opening the popup window (noopener) from anon window should work");
|
||||
assert_equals(navigated, false, "Navigating the popup to a null policy should fail");
|
||||
t.done();
|
||||
}, 500);
|
||||
} else if (payload == "popup-loaded") {
|
||||
popupLoaded = true;
|
||||
} else {
|
||||
assert_unreached(`unexpected payload ${payload}`);
|
||||
}
|
||||
});
|
||||
|
||||
const SECOND_CHANNEL = "anon-null-window-second-popup";
|
||||
let navigated = false;
|
||||
let bc2 = new BroadcastChannel(SECOND_CHANNEL);
|
||||
bc2.onmessage = t.step_func((event) => {
|
||||
navigated = true;
|
||||
let payload = event.data;
|
||||
assert_equals(payload, "loaded");
|
||||
});
|
||||
|
||||
let win = window.open(`resources/popup_and_close.sub.html?channelName=${CHANNEL_NAME}&to=navigate_null.sub.html?channelName=${SECOND_CHANNEL}`, "_blank", "noopener");
|
||||
}, "Top-level popup with anonymous policy: Navigating the popup to a null policy should fail. (even opener window is closed)");
|
||||
|
||||
</script>
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
let current = new URL(window.location.href);
|
||||
let navigateTo = current.searchParams.get("to");
|
||||
let channelName = current.searchParams.get("channelName");
|
||||
let clearOpener = current.searchParams.get("clearOpener");
|
||||
|
||||
if (clearOpener) {
|
||||
window.opener = null;
|
||||
}
|
||||
|
||||
current.search = "";
|
||||
if (navigateTo) {
|
||||
let next = new URL(navigateTo, current);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<!doctype html>
|
||||
<script>
|
||||
let current = new URL(window.location.href);
|
||||
let navigateTo = current.searchParams.get("to");
|
||||
let channelName = current.searchParams.get("channelName");
|
||||
let secondChannel = current.searchParams.get("secondChannel");
|
||||
|
||||
if (channelName) {
|
||||
let bc = new BroadcastChannel(channelName);
|
||||
bc.postMessage("popup-loaded");
|
||||
}
|
||||
|
||||
let win = window.open(`navigate_anonymous.sub.html?channelName=${channelName}&to=navigate_null.sub.html?channelName=${secondChannel}`, "_blank");
|
||||
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
}, 10);
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
Cross-Origin: anonymous
|
Загрузка…
Ссылка в новой задаче