Skip to content

Commit

Permalink
navigating-across-documents: additional revisions, and additions 010-017
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Dec 7, 2017
1 parent 9feef49 commit 1717418
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 178 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<iframe id="test" name="test"></iframe>
<form target="test" action="javascript:document.write(`<script>parent.onjsurl({data:'javascript:url'});</script>`);1"></form>
<a target="test" onclick="document.forms[0].submit();" href="href.html">Test</a>
<script>
window.onjsurl = window.onmessage = function(e) {
parent.postMessage(e.data, "*");
};
window.onload = function() {
document.querySelector("a").click();
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!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/links.html#following-hyperlinks">
<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" that document.writes a script in a 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 src="010-form-action-javascript-url-document-writes-script-element-intermediary.html"></iframe>
<script>
var test = async_test();
window.onjsurl = window.onmessage = test.step_func_done(function(e) {
assert_equals(e.data, "href", "'javascript: url' code is expected to run asynchronously.");
});
</script>

<!--
In an iframe...
1. This test creates an iframe, a form with `action="javascript: ..."` (which implicitly returns
a string containing a script element that will attempt to call a synchronous handler in the intermediary) 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 which contains the
steps to evaluate the code contents.
4. Navigating the iframe to the anchor's `href` must cancel the iframe
"javascript: url" navigation.
5. If the semantics are implemented correctly, a single message will be
received from href.html
(There will be no message from the "javascript: url" code, because it
is aborted by the navigation to "href.html")
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<iframe id="test" name="test"></iframe>
<form target="test" action="javascript:((e,n)=>{while(e()<n);return 1;})(Date.now,Date.now()+4000);"></form>
<a target="test" onclick="times.push(Date.now());document.forms[0].submit();times.push(Date.now());" href="href.html">Test</a>
<script>
var times = [];
window.onmessage = function(e) {
// Prevent further calls
window.onmessage = null;

if (times.length === 0 || times[1] - times[0] >= 4000) {
parent.postMessage("FAIL", "*");
return;
}
parent.postMessage(e.data, "*");
};
window.onload = function() {
document.querySelector("a").click();
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!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/links.html#following-hyperlinks">
<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" that executes blocking code, which should be evaluated async. Handling activation behavior/onclick should occur before the href navigation</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe src="010-form-action-javascript-url-executes-async-intermediary.html"></iframe>
<script>
var test = async_test();
window.onjsurl = window.onmessage = test.step_func_done(function(e) {
assert_equals(e.data, "href", "'javascript: url' code is expected to run asynchronously.");
});
</script>

<!--
In an iframe...
1. This test creates an iframe, a form with `action="javascript: ..."` (which implicitly returns
a string containing a script element that will attempt to call a synchronous handler in the intermediary) 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 which contains the
steps to evaluate the code contents.
4. Navigating the iframe to the anchor's `href` must cancel the iframe
"javascript: url" navigation.
5. If the semantics are implemented correctly, a single message will be
received from href.html
(There will be no message from the "javascript: url" code, because it
is aborted by the navigation to "href.html")
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<iframe id="test" name="test"></iframe>
<form target="test" action="javascript:`<script>parent.onjsurl({data:'javascript:url'});</script>`"></form>
<a target="test" onclick="document.forms[0].submit();" href="href.html">Test</a>
<script>
window.onjsurl = window.onmessage = function(e) {
parent.postMessage(e.data, "*");
};
window.onload = function() {
document.querySelector("a").click();
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!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/links.html#following-hyperlinks">
<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" that returns a string containing a script to write to a 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 src="010-form-action-javascript-url-returns-script-element-intermediary.html"></iframe>
<script>
var test = async_test();
window.onjsurl = window.onmessage = test.step_func_done(function(e) {
assert_equals(e.data, "href", "'javascript: url' code is expected to run asynchronously.");
});
</script>

<!--
In an iframe...
1. This test creates an iframe, a form with `action="javascript: ..."` (which implicitly returns
a string containing a script element that will attempt to call a synchronous handler in the intermediary) 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 which contains the
steps to evaluate the code contents.
4. Navigating the iframe to the anchor's `href` must cancel the iframe
"javascript: url" navigation.
5. If the semantics are implemented correctly, a single message will be
received from href.html
(There will be no message from the "javascript: url" code, because it
is aborted by the navigation to "href.html")
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<iframe id="test" name="test"></iframe>
<form target="test" action="javascript:`<script>parent.onjsurl({data:'javascript:url'});</script>`"></form>
<a target="test" onclick="document.forms[0].submit();" href="href.html?pipe=trickle(d2)">Test</a>
<script>
window.onjsurl = window.onmessage = function(e) {
parent.postMessage(e.data, "*");
};
window.onload = function() {
document.querySelector("a").click();
};
</script>
Original file line number Diff line number Diff line change
@@ -1,56 +1,39 @@
<!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/links.html#following-hyperlinks">
<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>
<title>Link with onclick form submit to navigate "javascript: url" that document.writes a script in a 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>
<iframe src="011-form-action-javascript-url-document-writes-script-element-delayed-href-cancels-intermediary.html"></iframe>
<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();
window.onjsurl = window.onmessage = test.step_func_done(function(e) {
assert_equals(e.data, "href", "'javascript: url' code is expected to run asynchronously.");
});
</script>

<!--
In an iframe...
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
3. The form action "javascript: url" navigation is queued in a task which contains the
steps to evaluate the code contents.
4. Navigating the iframe to the anchor's `href` must cancel the iframe
"javascript: url" navigation, regardless of the delayed response.
5. If the semantics are implemented correctly, a single message will be
received from href.html
(There will be no message from the "javascript: url" code, because it
is aborted by the navigation to "href.html")
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<iframe id="test" name="test"></iframe>
<form target="test" action="javascript:`<script>parent.onjsurl({data:'javascript:url'});</script>`"></form>
<a target="test" onclick="document.forms[0].submit();" href="href.html?pipe=trickle(d1)">Test</a>
<script>
window.onjsurl = window.onmessage = function(e) {
parent.postMessage(e.data, "*");
};
window.onload = function() {
document.querySelector("a").click();
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!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/links.html#following-hyperlinks">
<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" that returns a string containing a script to write to a 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 src="011-form-action-javascript-url-returns-script-element-delayed-href-cancels-intermediary.html"></iframe>
<script>
var test = async_test();
window.onjsurl = window.onmessage = test.step_func_done(function(e) {
assert_equals(e.data, "href", "'javascript: url' code is expected to run asynchronously.");
});
</script>

<!--
In an iframe...
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 which contains the
steps to evaluate the code contents.
4. Navigating the iframe to the anchor's `href` must cancel the iframe
"javascript: url" navigation, regardless of the delayed response.
5. If the semantics are implemented correctly, a single message will be
received from href.html
(There will be no message from the "javascript: url" code, because it
is aborted by the navigation to "href.html")
-->

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1717418

Please sign in to comment.