Bug 1469205 [wpt PR 11411] - improve spec compliance of window.close, a=testonly
authorServo WPT Sync <32481905+servo-wpt-sync@users.noreply.github.com>
Tue, 26 Jun 2018 03:04:57 +0000
changeset 812121 ae326fcee8382d5356666a8123522aed3d0542d3
parent 812120 f88194ff3ca1ee71f02b0a147d01a14df058fc22
child 812122 46a22980d514dcd49b275bbb7907a3af39ed82ec
push id114453
push userrwood@mozilla.com
push dateThu, 28 Jun 2018 15:10:03 +0000
reviewerstestonly
bugs1469205, 11411
milestone63.0a1
Bug 1469205 [wpt PR 11411] - improve spec compliance of window.close, a=testonly Automatic update from web-platform-testsMerge pull request #11411 from web-platform-tests/sync_90693712e87eed75ff61cb67176cff92b514985c Merge pull request #11411 from sync_90693712e87eed75ff61cb67176cff92b514985c -- wpt-commits: ce1a1d374655d76feab7c308ee7c583798a1a441 wpt-pr: 11411
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html
testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable-1.html
testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -275971,16 +275971,21 @@
      {}
     ]
    ],
    "html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward-1.html": [
     [
      {}
     ]
    ],
+   "html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable-1.html": [
+    [
+     {}
+    ]
+   ],
    "html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html": [
     [
      {}
     ]
    ],
    "html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html": [
     [
      {}
@@ -338347,16 +338352,28 @@
     ]
    ],
    "html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html": [
     [
      "/html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html",
      {}
     ]
    ],
+   "html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html": [
+    [
+     "/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html",
+     {}
+    ]
+   ],
+   "html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html": [
+    [
+     "/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html",
+     {}
+    ]
+   ],
    "html/browsers/browsing-the-web/unloading-documents/prompt/001.html": [
     [
      "/html/browsers/browsing-the-web/unloading-documents/prompt/001.html",
      {}
     ]
    ],
    "html/browsers/browsing-the-web/unloading-documents/prompt/002.html": [
     [
@@ -569324,16 +569341,28 @@
   "html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward-1.html": [
    "3aa8b42fe7937a02c3319cced4319292842eb450",
    "support"
   ],
   "html/browsers/browsing-the-web/unloading-documents/pagehide-on-history-forward.html": [
    "2b3a56895dbe6450ed38ebbb31a915c9e8b7abd6",
    "testharness"
   ],
+  "html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html": [
+   "7b60961703fd447aff290aa5fedf6950b242b9d5",
+   "testharness"
+  ],
+  "html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable-1.html": [
+   "0e8cf55368a34a0367763cdf902fdf6a5dc51f28",
+   "support"
+  ],
+  "html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html": [
+   "faa25d4925073f71b3ee451427b253cc232c01f7",
+   "testharness"
+  ],
   "html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html": [
    "758c04e8df6778e435346c59280c17e02295cca6",
    "support"
   ],
   "html/browsers/browsing-the-web/unloading-documents/prompt/001-2.html": [
    "daa509f165b5ce876b0c1bd9c3115ba090c9a529",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>beforeunload and unload events fire after window.close() in script-closeable browsing context</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+beforeunload_fired = false;
+var t = async_test();
+
+onload = t.step_func(function() {
+  window.close();
+});
+
+onbeforeunload = t.step_func(function() {
+  beforeunload_fired = true;
+});
+
+onunload = t.step_func(function() {
+  assert_true(beforeunload_fired);
+  t.done()
+});
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable-1.html
@@ -0,0 +1,10 @@
+<!doctype html>
+script-uncloseable-1
+<script>
+onbeforeunload = function() {
+  parent.beforeunload_fired = true;
+};
+onunload = function() {
+  parent.unload_fired = true;
+};
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<title>beforeunload and unload events do not fire after window.close() in script-uncloseable browsing context</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var beforeunload_fired = false;
+var unload_fired = false;
+var t = async_test();
+
+onload = t.step_func(function() {
+  var iframe = document.getElementsByTagName("iframe")[0]
+  iframe.onload = t.step_func(function() {
+    iframe.contentWindow.close()
+    t.step_timeout(function() {
+      assert_false(beforeunload_fired);
+      assert_false(unload_fired);
+      t.done();
+    }, 1000);
+  });
+  iframe.src = "prompt-and-unload-script-uncloseable-1.html";
+});
+</script>
+<iframe></iframe>