forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
navigating-across-documents: revisions and explanations for 010-*, 01…
…1, 012-*, 013, 014 & 015
- Loading branch information
Showing
13 changed files
with
398 additions
and
86 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...web/navigating-across-documents/010-form-action-javascript-url-aborted-by-navigation.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,56 @@ | ||
<!doctype html> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#javascript-protocol"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-submit"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-get-action"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plan-to-navigate"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#planned-navigation"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#dom-manipulation-task-source"> | ||
<title>Link with onclick form submit to navigate "javascript: url" in nested browsing context, is aborted by href navigation</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<iframe id="test" name="test"></iframe> | ||
<!-- Everything seen in the action="" is necessary to prevent a blank page in Chrome --> | ||
<form target="test" action="javascript:parent.postMessage(location.href, '*');"></form> | ||
<a target="test" onclick="document.forms[0].submit();reports.push('onclick');" href="href.html">Test</a> | ||
<script> | ||
var test = async_test(); | ||
var reports = []; | ||
|
||
window.onmessage = test.step_func(function(e) { | ||
reports.push(e.data); | ||
// "href" is expected last, if this is not received last or | ||
// not received at all, the test must fail. | ||
if (e.data === "href") { | ||
assert_equals(reports[0], "click"); | ||
assert_equals(reports[1], "onclick"); | ||
assert_equals(reports[2], "href"); | ||
assert_equals(reports.length, 3); | ||
} else { | ||
|
||
|
||
} | ||
test.done(); | ||
}); | ||
|
||
test.step(function() { | ||
reports.push("click"); | ||
document.querySelector("a").click(); | ||
}); | ||
</script> | ||
|
||
<!-- | ||
1. This test creates an iframe, a form with `action="javascript:...", and | ||
an anchor with both an `onclick` and `href`. | ||
2. The test "clicks" the anchor, triggering the `onclick` handler operation, | ||
which will attempt to submit the form, which targets the iframe. | ||
3. The form action "javascript: url" navigation is queued in a task. | ||
4. Navigating the iframe to the anchor's `href` must abort the iframe | ||
"javascript: url" navigation. | ||
5. If the semantics are implemented correctly, reports will be | ||
["click", "onclick", "href"]. | ||
(There will be no report from the "javascript: url" code, because it | ||
is aborted by the navigation to "href.html") | ||
--> |
17 changes: 0 additions & 17 deletions
17
html/browsers/browsing-the-web/navigating-across-documents/010.html
This file was deleted.
Oops, something went wrong.
46 changes: 32 additions & 14 deletions
46
html/browsers/browsing-the-web/navigating-across-documents/011.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 |
---|---|---|
@@ -1,21 +1,39 @@ | ||
<!doctype html> | ||
<title>Link with onclick navigation to javascript url with document.write and href navigation </title> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents"> | ||
<title>Link with onclick that does not attempt to navigate and href navigation</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<iframe id="test" name="test"></iframe> | ||
<a target="test" onclick="javascript:(function() {document.write('<script>parent.postMessage("write", "*")</script>'); return '<script>parent.postMessage("click", "*")</script>'})()" href="href.html">Test</a> | ||
<a target="test" onclick="reports.push('onclick');" href="href.html">Test</a> | ||
<script> | ||
var t = async_test(); | ||
var events = []; | ||
t.step(function() { | ||
document.getElementsByTagName("a")[0].click()}); | ||
onmessage = t.step_func( | ||
function(e) { | ||
events.push(e.data); | ||
if (events.length === 2) { | ||
assert_array_equals(events, ["write", "href"]); | ||
t.done(); | ||
} | ||
}); | ||
var test = async_test(); | ||
var reports = []; | ||
test.step(function() { | ||
reports.push("click"); | ||
document.querySelector("a").click(); | ||
}); | ||
window.onmessage = test.step_func(function(e) { | ||
reports.push(e.data); | ||
|
||
// "href" is expected last, if this is not received last or | ||
// not received at all, the test must fail. | ||
if (e.data === "href") { | ||
assert_equals(reports[0], "click"); | ||
assert_equals(reports[1], "onclick"); | ||
assert_equals(reports[2], "href"); | ||
assert_equals(reports.length, 3); | ||
test.done(); | ||
} | ||
}); | ||
</script> | ||
|
||
<!-- | ||
1. This test creates an iframe and an anchor with both an `onclick` and `href`. | ||
2. The test "clicks" the anchor, triggering the `onclick` handler operation, | ||
which adds a message to the reports array. | ||
3. Navigate the iframe to the anchor's `href`. | ||
4. If the semantics are implemented correctly, reports will be | ||
["click", "onclick", "href"]. | ||
--> |
44 changes: 44 additions & 0 deletions
44
html/browsers/browsing-the-web/navigating-across-documents/012-async-timeout.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,44 @@ | ||
<!doctype html> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents"> | ||
<title>Link with onclick, which executes a handler containing a timeout, that then navigates the iframe, and returns true.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<iframe id="test" name="test"></iframe> | ||
<a target="test" onclick="(function(){setTimeout(()=>document.querySelector('iframe').src='call-parent-postmessage.html', 500);reports.push('onclick');})()" href="href.html">Test</a> | ||
<script> | ||
var test = async_test(); | ||
var reports = []; | ||
|
||
window.onmessage = test.step_func(function(e) { | ||
reports.push(e.data); | ||
|
||
// "call-parent-postmessage" is expected last, if this is not received last or | ||
// not received at all, the test must fail. | ||
if (e.data === "call-parent-postmessage") { | ||
assert_equals(reports[0], "click", reports); | ||
assert_equals(reports[1], "onclick", reports); | ||
assert_equals(reports[2], "href", reports); | ||
assert_equals(reports[3], "call-parent-postmessage"); | ||
assert_equals(reports.length, 4); | ||
test.done(); | ||
} | ||
}); | ||
|
||
test.step(function() { | ||
reports.push("click"); | ||
document.querySelector("a").click(); | ||
}); | ||
</script> | ||
|
||
<!-- | ||
1. This test creates an iframe and an anchor with both an `onclick` and `href`. | ||
2. The test "clicks" the anchor, triggering the `onclick` handler operation, | ||
which will attempt to navigate the iframe after an async timeout. | ||
3. Navigating the iframe to the anchor's `href` will complete successfully, | ||
then the queued timeout will execute and the next navigation will occur | ||
and also complete successfully. | ||
4. If the semantics are implemented correctly, reports will be | ||
["click", "onclick", "href", "call-parent-postmessage"]. | ||
--> |
46 changes: 46 additions & 0 deletions
46
...ers/browsing-the-web/navigating-across-documents/012-blocking-then-async-postmessage.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,46 @@ | ||
<!doctype html> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents"> | ||
<title>Link with onclick, which executes a handler containing a 100ms blocking operation, then iframe document.write, then returns true.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<iframe id="test" name="test"></iframe> | ||
<a target="test" onclick="(function() {((e,n)=>{var a=e();while(e()<a+n);})(Date.now,100); document.querySelector('iframe').contentDocument.write('<script>parent.postMessage("write-post-message", "*")</script>');reports.push('onclick');return true;})()" href="href.html">Test</a> | ||
|
||
<script> | ||
var test = async_test(); | ||
var reports = []; | ||
var iframe = document.querySelector('iframe'); | ||
|
||
window.onmessage = test.step_func(function(e) { | ||
reports.push(e.data); | ||
|
||
// "href" is expected last, if this is not received last or | ||
// not received at all, the test must fail. | ||
if (e.data === "href") { | ||
assert_equals(reports[0], "click"); | ||
assert_equals(reports[1], "onclick"); | ||
// This comes after "onclick" because it's | ||
// sent via postMessage | ||
assert_equals(reports[2], "write-post-message"); | ||
assert_equals(reports[3], "href"); | ||
assert_equals(reports.length, 4); | ||
test.done(); | ||
} | ||
}); | ||
|
||
test.step(function() { | ||
reports.push("click"); | ||
document.querySelector("a").click(); | ||
}); | ||
</script> | ||
|
||
<!-- | ||
1. This test creates an iframe and an anchor with both an `onclick` and `href`. | ||
2. The test "clicks" the anchor, triggering the `onclick` handler operation, | ||
which will document.write a script to the iframe which sends a message "write". | ||
3. Navigate the iframe to the anchor's `href` | ||
4. If the semantics are implemented correctly, reports will be | ||
["click", "onclick", "write-post-message", "href"] | ||
--> |
20 changes: 0 additions & 20 deletions
20
html/browsers/browsing-the-web/navigating-across-documents/012.html
This file was deleted.
Oops, something went wrong.
48 changes: 37 additions & 11 deletions
48
html/browsers/browsing-the-web/navigating-across-documents/013.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 |
---|---|---|
@@ -1,20 +1,46 @@ | ||
<!doctype html> | ||
<title>Link with onclick navigation to javascript url with delayed document.write and href navigation </title> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#javascript-protocol"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:about:blank"> | ||
<title>Link with href navigation to "javascript: url", order of execution</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<iframe id="test" name="test"></iframe> | ||
<a target="test" href="javascript:parent.events.push('javascript');">Test</a> | ||
<a target="test" href="javascript:parent.postMessage(location.href, '*');">Test</a> | ||
<script> | ||
var t = async_test(undefined, {timeout:4000}); | ||
var events = []; | ||
t.step(function() { | ||
document.getElementsByTagName("a")[0].click(); | ||
events.push('after script'); | ||
var test = async_test(); | ||
var reports = []; | ||
|
||
window.onmessage = test.step_func(function(e) { | ||
reports.push(e.data); | ||
// "about:blank" is expected last, if this is not received last or | ||
// not received at all, the test must fail. | ||
if (e.data === "about:blank") { | ||
assert_equals(reports[0], "click"); | ||
assert_equals(reports[1], "about:blank"); | ||
assert_equals(reports.length, 2); | ||
} else { | ||
throw new Error("'javascript: url' code is expected to run asynchronously and in the target nested browsing context"); | ||
} | ||
test.done(); | ||
}); | ||
onload = t.step_func(function() { | ||
// javascript: executions are async. | ||
assert_array_equals(events, ['after script', 'javascript']); | ||
t.done(); | ||
|
||
test.step(function() { | ||
reports.push("click"); | ||
document.querySelector("a").click(); | ||
}); | ||
</script> | ||
|
||
<!-- | ||
1. This test creates an anchor with an href containing a "javascript: url". | ||
2. The test "clicks" the anchor, triggering the "javascript: url" href navigation, | ||
which must be evaluated and executed asynchronously. | ||
3. location.href is used to prove that the "javascript: url"'s contents | ||
are executed in the iframe. | ||
4. If the semantics are implemented correctly, reports will be | ||
["click", "about:blank"] | ||
--> |
58 changes: 46 additions & 12 deletions
58
html/browsers/browsing-the-web/navigating-across-documents/014.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 |
---|---|---|
@@ -1,21 +1,55 @@ | ||
<!doctype html> | ||
<title> Link with javascript onclick form submission script order </title> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigating-across-documents"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsing-the-web.html#javascript-protocol"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-submit"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-get-action"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plan-to-navigate"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#planned-navigation"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:about:blank"> | ||
<title>Link with onclick form submit to "javascript: url", order of execution</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<iframe id="test" name="test"></iframe> | ||
<form target="test" action="javascript:parent.events.push('submit');"></form> | ||
<a target="test" onclick="document.forms[0].submit()">Test</a> | ||
<form target="test" action="javascript:parent.postMessage(location.href, '*');"></form> | ||
<a target="test" onclick="reports.push('onclick');document.forms[0].submit();">Test</a> | ||
<script> | ||
var t = async_test(undefined, {timeout:4000}); | ||
var events = []; | ||
t.step(function() { | ||
document.getElementsByTagName("a")[0].click(); | ||
events.push('after script'); | ||
var test = async_test(); | ||
var reports = []; | ||
|
||
window.onmessage = test.step_func(function(e) { | ||
reports.push(e.data); | ||
|
||
// "about:blank" is expected last, if this is not received last or | ||
// not received at all, the test must fail. | ||
if (e.data === "about:blank") { | ||
assert_equals(reports[0], "click"); | ||
assert_equals(reports[1], "onclick"); | ||
assert_equals(reports[2], "about:blank"); | ||
assert_equals(reports.length, 3); | ||
} else { | ||
throw new Error("'javascript: url' code is expected to run asynchronously and in the target nested browsing context"); | ||
} | ||
test.done(); | ||
}); | ||
onload = t.step_func(function() { | ||
// javascript: executions are async. | ||
assert_array_equals(events, ['after script', 'submit']); | ||
t.done(); | ||
|
||
test.step(function() { | ||
reports.push("click"); | ||
document.querySelector("a").click(); | ||
}); | ||
</script> | ||
|
||
<!-- | ||
1. This test creates a form with `target="test" and an anchor with both an | ||
onclick and href. | ||
2. The test clicks the anchor, which will trigger the onclick handler | ||
operation, which will attempt to submit the form. The form's `action` is | ||
a "javscript: url", which must be evaluated and executed asynchronously. | ||
3. location.href is used to prove that the "javscript: url"'s contents are | ||
executed in the iframe. | ||
4. If the semantics are implemented correctly, reports will be | ||
["click", "onclick", "about:blank"] | ||
--> |
Oops, something went wrong.