summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-1.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-1.html')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-1.html35
1 files changed, 35 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-1.html b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-1.html
new file mode 100644
index 0000000000..6ba1e65740
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-1.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Support page for beforeunload-canceling.html</title>
+
+<h1>If this goes away, it navigated</h1>
+
+<script>
+"use strict";
+
+window.runTest = (t, { valueToReturn, expectCancelation, setReturnValue, expectedReturnValue, cancel }) => {
+ window.onbeforeunload = t.step_func(e => {
+ if (cancel) {
+ e.preventDefault();
+ }
+
+ if (setReturnValue !== undefined) {
+ e.returnValue = setReturnValue;
+ }
+
+ return valueToReturn;
+ });
+
+ const listener = t.step_func(e => {
+ top.assert_equals(e.defaultPrevented, expectCancelation, "canceled");
+ top.assert_equals(e.returnValue, expectedReturnValue, "returnValue");
+ window.onbeforeunload = null;
+
+ t.done();
+ });
+
+ window.addEventListener("beforeunload", listener);
+
+ window.location.href = "about:blank";
+};
+</script>