E58B Bug 1794339 [wpt PR 36358] - Add tests for javascript: URL task queui… · jwidar/LatencyZeroGithub@f4de70e · GitHub
[go: up one dir, main page]

Skip to content

Commit f4de70e

Browse files
domenicmoz-wptsync-bot
authored andcommitted
Bug 1794339 [wpt PR 36358] - Add tests for javascript: URL task queuing, a=testonly
Automatic update from web-platform-tests Add tests for javascript: URL task queuing See whatwg/html#3730. Follows the spec in whatwg/html#6315. -- Delete failing-in-all-browsers 029.html See some discussion in whatwg/html#3730 about this test. However, it is very broken, and when we remove the brokenness, it becomes redundant with the just-added javascript-url-task-queuing.html. In particular, it's assuming beforeunload will fire. But beforeunload will never fire for a javascript: URL that returns a non-string value, since we're never in danger of unloading the document. -- wpt-commits: b9d6751e534aed6a8d9eb1e7e51640f968b943bb, 1a2f69d137c5ccbaaf678bf372a1a410ced97eed wpt-pr: 36358
1 parent 0b37169 commit f4de70e

File tree

2 files changed

+58
-53
lines changed

2 files changed

+58
-53
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>javascript: URL task queuing</title>
4+
<link rel="help" href="https://github.com/whatwg/html/issues/3730">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
8+
<body>
9+
<script>
10+
"use strict";
11+
12+
testIsAsync(() => {
13+
const iframe = document.createElement("iframe");
14+
document.body.append(iframe);
15+
iframe.contentWindow.location.href = "javascript:window.top.javascriptURLRan = true; window.top.resolveTestPromise();";
16+
}, `Navigating an iframe via location.href to a javascript: URL must queue a task`);
17+
18+
testIsAsync(() => {
19+
const iframe = document.createElement("iframe");
20+
iframe.src = "javascript:window.top.javascriptURLRan = true; window.top.resolveTestPromise();";
21+
document.body.append(iframe);
22+
}, `Navigating an iframe via src="" to a javascript: URL before insertion must queue a task`);
23+
24+
testIsAsync(() => {
25+
const iframe = document.createElement("iframe");
26+
document.body.append(iframe);
27+
iframe.src = "javascript:window.top.javascriptURLRan = true; window.top.resolveTestPromise();";
28+
}, `Navigating an iframe via src="" to a javascript: URL after insertion must queue a task`);
29+
30+
testIsAsync(() => {
31+
const w = window.open();
32+
w.location.href = "javascript:window.opener.javascriptURLRan = true; window.opener.resolveTestPromise();";
33+
}, `Navigating an opened window via location.href to a javascript: URL must queue a task`);
34+
35+
testIsAsync(() => {
36+
window.open("javascript:window.opener.javascriptURLRan = true; window.opener.resolveTestPromise();");
37+
}, `Navigating an opened window as part of creation to a javascript: URL must queue a task`);
38+
39+
function testIsAsync(setupFunc, description) {
40+
promise_test(async t => {
41+
t.add_cleanup(() => {
42+
delete window.resolveTestPromise;
43+
delete window.javascriptURLRan;
44+
});
45+
46+
const ranPromise = new Promise(resolve => {
47+
window.resolveTestPromise = resolve;
48+
});
49+
50+
setupFunc();
51+
52+
assert_equals(window.javascriptURLRan, undefined, "Must not run sync");
53+
54+
// Ensure that we do actually run the code, though.
55+
await ranPromise;
56+
}, description);
57+
}
58+
</script>

testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/029.html

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0