Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8">
<title>javascript: URL task queuing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
testIsAsync(() => {
const iframe = document.createElement("iframe");
document.body.append(iframe);
iframe.contentWindow.location.href = "javascript:window.top.javascriptURLRan = true; window.top.resolveTestPromise();";
}, `Navigating an iframe via location.href to a javascript: URL must queue a task`);
testIsAsync(() => {
const iframe = document.createElement("iframe");
iframe.src = "javascript:window.top.javascriptURLRan = true; window.top.resolveTestPromise();";
document.body.append(iframe);
}, `Navigating an iframe via src="" to a javascript: URL before insertion must queue a task`);
testIsAsync(() => {
const iframe = document.createElement("iframe");
document.body.append(iframe);
iframe.src = "javascript:window.top.javascriptURLRan = true; window.top.resolveTestPromise();";
}, `Navigating an iframe via src="" to a javascript: URL after insertion must queue a task`);
testIsAsync(() => {
const w = window.open();
w.location.href = "javascript:window.opener.javascriptURLRan = true; window.opener.resolveTestPromise();";
}, `Navigating an opened window via location.href to a javascript: URL must queue a task`);
testIsAsync(() => {
window.open("javascript:window.opener.javascriptURLRan = true; window.opener.resolveTestPromise();");
}, `Navigating an opened window as part of creation to a javascript: URL must queue a task`);
function testIsAsync(setupFunc, description) {
promise_test(async t => {
t.add_cleanup(() => {
delete window.resolveTestPromise;
delete window.javascriptURLRan;
});
const ranPromise = new Promise(resolve => {
window.resolveTestPromise = resolve;
});
setupFunc();
assert_equals(window.javascriptURLRan, undefined, "Must not run sync");
// Ensure that we do actually run the code, though.
await ranPromise;
}, description);
}
</script>