Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test whether javascript: navigation aborts fetches in earlier navigation
See whatwg/html#2590. Tentative tests for now.
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...ss-documents/javascript-url-abort/javascript-url-abort-return-value-string.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<title>Aborting fetch for javascript:string navigation</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#navigate"> | ||
<link rel="help" href="https://github.com/whatwg/html/issues/2590"> | ||
<div id="log"></div> | ||
<iframe src="support/iframe-and-links.html"></iframe> | ||
<script> | ||
async_test(test => { | ||
onload = () => { | ||
const child = document.querySelector('iframe').contentWindow; | ||
child.document.querySelector("#slowLink").click(); | ||
// The step below is in a timeout. The framed page can't communicate back mid-parse because that | ||
// would involve running script, which makes that navigation "mature", and we need to do this | ||
// before it matures. | ||
test.step_timeout(() => { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
child.document.querySelector("#javascriptStringLink").click(); | ||
child.document.querySelector("iframe").onload = test.step_func_done(() => { | ||
assert_false(child.childLoaded, 'child.childLoaded'); | ||
}); | ||
}, 100); | ||
}; | ||
window.javascriptStringDocLoaded = test.step_func(() => { | ||
assert_unreached("javascript: URL doc replaced the document, should be targeted to child iframe."); | ||
}); | ||
}); | ||
</script> |
25 changes: 25 additions & 0 deletions
25
...documents/javascript-url-abort/javascript-url-abort-return-value-undefined.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!doctype html> | ||
<title>Not aborting fetch for javascript:undefined navigation</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#navigate"> | ||
<link rel="help" href="https://github.com/whatwg/html/issues/2590"> | ||
<div id="log"></div> | ||
<iframe src="support/iframe-and-links.html"></iframe> | ||
<script> | ||
async_test(test => { | ||
onload = () => { | ||
const child = document.querySelector('iframe').contentWindow; | ||
child.document.querySelector("#slowLink").click(); | ||
// The step below is in a timeout. The framed page can't communicate back mid-parse because that | ||
// would involve running script, which makes that navigation "mature", and we need to do this | ||
// before it matures. | ||
test.step_timeout(() => { | ||
child.document.querySelector("#javascriptUndefinedLink").click(); | ||
child.document.querySelector("iframe").onload = test.step_func_done(() => { | ||
assert_true(child.childLoaded, 'child.childLoaded'); | ||
}); | ||
}, 100); | ||
}; | ||
}); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
...ng-the-web/navigating-across-documents/javascript-url-abort/support/iframe-and-links.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
|
||
<iframe name="iframe"></iframe> | ||
|
||
<!-- slow link's response is delayed by 1 second --> | ||
<!-- https://wptserve.readthedocs.io/en/latest/pipes.html#trickle --> | ||
<a target="iframe" href="set-child-loaded.html?pipe=trickle(d1)" id="slowLink">slow link</a> | ||
<a target="iframe" href="javascript:'javascript:string <script> parent.javascriptStringDocLoaded(); </script>'" id="javascriptStringLink">javascript:string link</a> | ||
<a target="iframe" href="javascript:undefined" id="javascriptUndefinedLink">javascript:undefined link</a> | ||
|
||
<script> | ||
// set-child-loaded.html (the slow link) sets this to true. | ||
window.childLoaded = false; | ||
|
||
// Do nothing when the javascript:string doc has loaded, if it's correctly targeted to the above iframe. | ||
// However, if it replaces this document, it needs to fail the test (handled in the parent). | ||
function javascriptStringDocLoaded() {} | ||
</script> |
5 changes: 5 additions & 0 deletions
5
...ng-the-web/navigating-across-documents/javascript-url-abort/support/set-child-loaded.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!doctype html> | ||
set-child-loaded.html | ||
<script> | ||
parent.childLoaded = true; | ||
</script> |
What guarantees that this timeout will fire before the navigation matures? The 1s timer on the trickle is in a different process (the server). Depending on OS scheduling, it can in fact end up replying before this time fires.