Bug 1482457 [wpt PR 12413] - Implement ignore-opens-during-unload counter in Document, a=testonly
authorTimothy Gu <timothygu@chromium.org>
Mon, 20 Aug 2018 22:10:23 +0000
changeset 487801 c068c3396e147d00d16b5cb6430e54026fa59d1c
parent 487800 e3ab676a310dc46b40d08a29166c02611085d3cf
child 487802 d37a2b5f7caaf336b2810df7aa2c397bad3dbb3f
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1482457, 12413, 583586, 866274, 1169320, 583836
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1482457 [wpt PR 12413] - Implement ignore-opens-during-unload counter in Document, a=testonly Automatic update from web-platform-testsImplement ignore-opens-during-unload counter in Document The removed test fast/loader/document-destruction-within-unload.html was originally added in 8809405d796cf3023e26cefd4b06f369eb67f125, to make sure that a document.write() call that blows away the current page still works in unload event listeners and blocks any current attempt to navigate. Since we no longer allow that to happen, the test is obsolete. In fact, it can be seen as contradictory to external/wpt/html/browsers/browsing-the-web/unloading-documents/005.html, which tests that document.open() in an unload event doesn't block navigation. Bug: 583586, 866274 Change-Id: I99b35dd28c97e8603455805b31d49644bc7b23a5 Reviewed-on: https://chromium-review.googlesource.com/1169320 Commit-Queue: Timothy Gu <timothygu@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/master@{#583836} -- wpt-commits: d44f0f56d5d7d5d4b9e50be0ad2c4331f81c7bf7 wpt-pr: 12413
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -605356,17 +605356,17 @@
    "f0d133a5329017814f21b206934a554955d15f88",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js": [
    "58ec08f9ff110a458f02660ba18e97513f569173",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.js": [
-   "5de4b1421b5ef10adecb10a2d5bda0d3a2c2711c",
+   "43506a22a46da53885a2b5a0888095bc52b460ca",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.js": [
    "4efbb863c6372a3ee04d11f38d7ee56a44a2ac7d",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-basic.html": [
    "118be71af19c88d5fed0a1efe010bbd6868eae9c",
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.js
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.js
@@ -1,15 +1,60 @@
-for (const ev of ["unload", "beforeunload", "pagehide"]) {
+for (const [ev, target] of [
+  ["beforeunload", iframe => iframe.contentWindow],
+  ["pagehide", iframe => iframe.contentWindow],
+  ["unload", iframe => iframe.contentWindow],
+  ["visibilitychange", iframe => iframe.contentDocument],
+]) {
   async_test(t => {
     const iframe = document.body.appendChild(document.createElement("iframe"));
     t.add_cleanup(() => iframe.remove());
     iframe.src = "/common/blank.html";
     iframe.onload = t.step_func(() => {
-      iframe.contentWindow.addEventListener(ev, t.step_func_done(() => {
+      target(iframe).addEventListener(ev, t.step_func_done(() => {
         assert_not_equals(iframe.contentDocument.childNodes.length, 0);
         assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
         assert_not_equals(iframe.contentDocument.childNodes.length, 0);
       }));
       iframe.src = "about:blank";
     });
-  }, `document.open should bail out when ignore-opens-during-unload is greater than 0 during ${ev} event`);
+  }, `document.open should bail out when ignore-opens-during-unload is greater than 0 during ${ev} event (in top-level browsing context)`);
+
+  async_test(t => {
+    const iframe = document.body.appendChild(document.createElement("iframe"));
+    t.add_cleanup(() => iframe.remove());
+    iframe.src = "/common/blank.html?1";
+    iframe.onload = t.step_func(() => {
+      const doc = iframe.contentDocument;
+      const innerIframe = doc.body.appendChild(doc.createElement("iframe"));
+      innerIframe.src = "/common/blank.html?2";
+      innerIframe.onload = t.step_func(() => {
+        // Navigate the parent, listen on the child, and open() the parent.
+        target(innerIframe).addEventListener(ev, t.step_func_done(() => {
+          assert_not_equals(iframe.contentDocument.childNodes.length, 0);
+          iframe.contentDocument.open();
+          assert_not_equals(iframe.contentDocument.childNodes.length, 0);
+        }));
+        iframe.src = "about:blank";
+      });
+    });
+  }, `document.open should bail out when ignore-opens-during-unload is greater than 0 during ${ev} event (open(parent) while unloading parent and child)`);
+
+  async_test(t => {
+    const iframe = document.body.appendChild(document.createElement("iframe"));
+    t.add_cleanup(() => iframe.remove());
+    iframe.src = "/common/blank.html?1";
+    iframe.onload = t.step_func(() => {
+      const doc = iframe.contentDocument;
+      const innerIframe = doc.body.appendChild(doc.createElement("iframe"));
+      innerIframe.src = "/common/blank.html?2";
+      innerIframe.onload = t.step_func(() => {
+        // Navigate the child, listen on the child, and open() the parent.
+        target(innerIframe).addEventListener(ev, t.step_func_done(() => {
+          assert_not_equals(iframe.contentDocument.childNodes.length, 0);
+          iframe.contentDocument.open();
+          assert_equals(iframe.contentDocument.childNodes.length, 0);
+        }));
+        innerIframe.src = "about:blank";
+      });
+    });
+  }, `document.open should bail out when ignore-opens-during-unload is greater than 0 during ${ev} event (open(parent) while unloading child only)`);
 }