diff options
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt')
14 files changed, 159 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html new file mode 100644 index 000000000..b68afc49e --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html @@ -0,0 +1,10 @@ +<script> +addEventListener("beforeunload", +function() { + parent.events.push("beforeunload"); +}, false); +parent.events.push("before src change"); + +location.href = "001-2.html&pipe=trickle(d2)"; +parent.events.push("after src change"); +</script> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html new file mode 100644 index 000000000..9da0f9395 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html @@ -0,0 +1 @@ +001-2 diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html new file mode 100644 index 000000000..109dcc139 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/001.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>beforeunload event order</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); +events = []; +onload = t.step_func(function() { + assert_array_equals(events, ["before src change", "beforeunload", "after src change"]); + t.done(); +}) +</script> +<iframe src="001-1.html"></iframe> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html new file mode 100644 index 000000000..c5f57375d --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002-1.html @@ -0,0 +1,7 @@ +<script> +addEventListsner("beforeunload", parent.t.step_func( +function(e) { + parent.do_test(e); +}, false); +location.href = "001-2.html&pipe=trickle(d2)"; +</script> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html new file mode 100644 index 000000000..d8f4fc60a --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/002.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>beforeunload event properties</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); + +function do_test(e) { + assert_equals(e.type, "beforeunload"); + assert_false(e.bubbles, "bubbles"); + assert_true(e.cancelable, "bubbles"); + assert_equals(e.returnValue, ""); +} + +onload = t.step_func(function() { + t.done(); +}) +</script> +<iframe src="001-1.html"></iframe> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html new file mode 100644 index 000000000..5683f1b12 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/003.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>beforeunload event in child frame for parent navigation</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var t = async_test(); + +function do_test(e) { + assert_equals(e.type, "beforeunload"); + assert_false(e.bubbles, "bubbles"); + assert_true(e.cancelable, "bubbles"); + assert_equals(e.returnValue, ""); +} + +onload = t.step_func(function() { + t.done(); +}) +</script> +<iframe src="001-1.html"></iframe> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST new file mode 100644 index 000000000..8d93279a4 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/MANIFEST @@ -0,0 +1,14 @@ +support 001-1.html +support 001-2.html +001.html +support 002-1.html +002.html +003.html +manual manual-001.html +manual manual-002.html +manual manual-003.html +manual manual-004.html +manual manual-005.html +manual manual-006.html +support next.html +support slice-and-dice.php diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html new file mode 100644 index 000000000..3b7ef74b7 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-001.html @@ -0,0 +1,9 @@ +<!doctype html> +<title>Prompt when beforeunload is canceled</title> +<script> +addEventListener("beforeunload", +function(e) {e.preventDefault()}, +false); +</script> +<p>When clicking the link below, you should get a prompt asking if you want to unload the document</p> +<a href="next.html">Click here</a> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html new file mode 100644 index 000000000..7be8a3301 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-002.html @@ -0,0 +1,9 @@ +<!doctype html> +<title>Prompt when beforeunload has returnValue set</title> +<script> +addEventListener("beforeunload", +function(e) {e.returnValue = "PASS if you see this"}, +false); +</script> +<p>When clicking the link below, you should get a prompt asking if you want to unload the document</p> +<a href="next.html">Click here</a> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html new file mode 100644 index 000000000..ff72b6705 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-003.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>Prompt when beforeunload is canceled</title> +<script> +addEventListener("beforeunload", +function(e) {e.preventDefault()}, +false); +</script> +<p>When clicking the button below, you should get a prompt asking if you want to unload the document</p> +<form method="get" action="next.html"> +<input type="submit" value="Click here"> +</form> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html new file mode 100644 index 000000000..a4d296892 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-004.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>Prompt on form submit</title> +<script> +addEventListener("beforeunload", +function(e) {e.preventDefault()}, +false); +</script> +<p>When clicking the button below, you should get a prompt asking if you want to unload the document</p> +<form method="get" action="next.html"> +<input type="submit" value="Click here"> +</form> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html new file mode 100644 index 000000000..71ff0a241 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-005.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>Event loop pause for beforeunload</title> +<script> +var counter = 0; + +onload = function count() { + document.getElementById("log").textContent = counter++ + setTimeout(count, 200); +} + +addEventListener("beforeunload", +function(e) { + e.preventDefault() +}, +false); +</script> +<ul> +<li>Click on the link below. When the prompt appears the counter at the bottom must stop incrementing. +<li>Opt not to leave the page. The counter must start incrementing again +</ul> +<p><a href="">Click here</a> +<div id="log"></div> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html new file mode 100644 index 000000000..dae0340ad --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/manual-006.html @@ -0,0 +1,9 @@ +<!doctype html> +<title>Prompt when beforeunload returns string value</title> +<script> +addEventListener("beforeunload", +function(e) {return "PASS if you see this"}, +false); +</script> +<p>When clicking the link below, you should get a prompt asking if you want to unload the document</p> +<a href="next.html">Click here</a> diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html new file mode 100644 index 000000000..38e7cdd5e --- /dev/null +++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt/next.html @@ -0,0 +1,2 @@ +<!doctype html> +<p>You should have seen a prompt asking you to unload the previous document |