Skip to content

Commit

Permalink
Add wpt test of form submission inside an onload handler.
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: HearVphzHsG

Upstreamed from https://bugzilla.mozilla.org/show_bug.cgi?id=1397512 [ci skip]
  • Loading branch information
freesamael authored and jgraham committed Nov 15, 2017
1 parent 3d2d43c commit b3145ac
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

<!doctype html>
<meta charset=utf-8>
<title>Navigation in onload handler</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
var testFiles = [
"navigation-in-onload_form-submission-1.tentative.html",
"navigation-in-onload_form-submission-iframe.tentative.html",
"navigation-in-onload_form-submission-dynamic-iframe.tentative.html"
]

var t = async_test();

function scheduleNextTest() {
setTimeout(runNextTest, 0);
}

function runNextTest() {
var file = testFiles.shift();
if (!file) {
t.done();
return;
}

window.open(file);
}

function verify(actual, expected, desc) {
setTimeout(t.step_func(function() {
assert_equals(actual, expected, desc);
}), 0);
}

</script>
<body onload="scheduleNextTest();"></body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Navigation in onload handler through form submission</title>
<script>
function redirect() {
document.querySelector("#redirectionForm").submit();
}
</script>
</head>
<body onload="redirect();">
<form id="redirectionForm" action="navigation-in-onload_form-submission-2.tentative.html" method="get"></form>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Navigation in onload handler through form submission</title>
<script>

// Verify is called after onload event to ensure history has been stable.
function verify() {
// Navigation in onload handler through form submission should not
// increse history length.
var testRunner = window.top.opener;
testRunner.verify(history.length, 1,
"history.length of subtest '" + top.document.title + "'.");
testRunner.scheduleNextTest();
setTimeout(window.close.bind(top), 0);
}
</script>
</head>
<body onload="setTimeout(verify, 0);">
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Navigation in onload handler through form submission in a dynamically created iframe</title>
<script>
function test() {
let testFrame = document.createElement("iframe");
testFrame.src = "navigation-in-onload_form-submission-1.tentative.html";
document.body.appendChild(testFrame);
}
</script>
</head>
<body onload="test();">
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Navigation in onload handler through form submission in an iframe</title>
</head>
<body>
<iframe id="testFrame" src="navigation-in-onload_form-submission-1.tentative.html"></iframe>
</body>
</html>

0 comments on commit b3145ac

Please sign in to comment.