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

Add tests for javascript: URL task queuing #36358

Merged
merged 2 commits into from
Oct 10, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>javascript: URL task queuing</title>
<link rel="help" href="https://github.com/whatwg/html/issues/3730">
<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>

This file was deleted.