Bug 1477511 [wpt PR 12122] - HTML: document.open() and event listener removal, a=testonly
authorTimothy Gu <timothygu99@gmail.com>
Wed, 15 Aug 2018 01:00:15 +0000
changeset 431709 1ee204d546351e6558e57d091f36c57cecfd1ef1
parent 431708 77273a4b047a0bf3977e31e5fe6e0d913b6e339d
child 431710 d27af016f4fc054d00c7cd424d7f6392362b62e8
push id34451
push userebalazs@mozilla.com
push dateThu, 16 Aug 2018 09:25:15 +0000
treeherdermozilla-central@161817e6d127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1477511, 12122
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 1477511 [wpt PR 12122] - HTML: document.open() and event listener removal, a=testonly Automatic update from web-platform-testsHTML: Use /common/blank.html in document open steps tests -- HTML: More event listener tests for document open steps -- wpt-commits: 3faeaa9350a80436a52e54708ec5b642c81ea380, dc0ec8ee874c2b2abf5a5e73907ddcdf27575432 wpt-pr: 12122
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004-1.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/005.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/007.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -288308,21 +288308,16 @@
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/document-writeln/original-id.json": [
     [
      {}
     ]
    ],
-   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004-1.html": [
-    [
-     {}
-    ]
-   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010-1.html": [
     [
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010-2.html": [
     [
      {}
@@ -363574,22 +363569,16 @@
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html",
      {}
     ]
    ],
-   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/007.html": [
-    [
-     "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/007.html",
-     {}
-    ]
-   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html",
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html": [
     [
@@ -603673,42 +603662,34 @@
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html": [
    "f82d80be7b6b50608699b73a6f8d1b592e0a55c6",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/002.html": [
    "5584bf9afbff034f5ea68d769afa648e31fe1aaf",
    "testharness"
   ],
-  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004-1.html": [
-   "c50eddd41faba2ecc8928e459288fe612b999170",
-   "support"
-  ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004.html": [
-   "0b3220279fd56148a36d2085563056827702018d",
+   "3fb443a99314aa26e230fe63d7f58a78141b0a71",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/005.html": [
-   "24725b76fb1c3aeb2ab4935b3fc95589375e4a4a",
+   "e849c31560e8fc55afef26023d80b7ef0886ba85",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html": [
-   "ae5edc457dacd5c1a06169fa0fda96396dfc0f21",
-   "testharness"
-  ],
-  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/007.html": [
-   "e5f0d1561ef6e9cd33393914e087e33fca73fefe",
+   "1dcb92615d085b28d3c9d2a22d744be849158d18",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html": [
-   "7471b2203169fd0cc74c9572a9c207dd4eb099a0",
+   "36c0a3f3ea11b9f96522cbba22f1006ba42900bb",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html": [
-   "3f51fa40dfa50cfaa8f6eb3b05d725255960d139",
+   "0d104c9569b37355c24d60fdcad0ca9ed792dcd0",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010-1.html": [
    "317e13691d4a94e5861bbb85d7367591d7d1c624",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010-2.html": [
    "ea537fcd6018fab07cb58132a2523d82cb8783de",
@@ -603806,17 +603787,17 @@
    "fc325d54db239d729a4b762367576494c9e93490",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/encoding.window.js": [
    "f0d133a5329017814f21b206934a554955d15f88",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js": [
-   "97334ce1bab8f15f85361f50117106a7ac1aa782",
+   "58ec08f9ff110a458f02660ba18e97513f569173",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.js": [
    "5de4b1421b5ef10adecb10a2d5bda0d3a2c2711c",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.js": [
    "4efbb863c6372a3ee04d11f38d7ee56a44a2ac7d",
deleted file mode 100644
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004-1.html
+++ /dev/null
@@ -1,1 +0,0 @@
-<!doctype html>
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <title>Reuse of document object after document.open</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
-<iframe src="004-1.html"></iframe>
+<iframe src="/common/blank.html"></iframe>
 <script>
 var t = async_test();
 var iframe;
 onload = t.step_func(function() {
   var iframe = document.getElementsByTagName("iframe")[0];
   var handle = iframe.contentDocument;
   iframe.contentDocument.test_state = 1;
   assert_equals(iframe.contentDocument.open(), handle);
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/005.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/005.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <title>Cancelling timeout after document.open</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
-<iframe src="004-1.html"></iframe>
+<iframe src="/common/blank.html"></iframe>
 <script>
 var t = async_test();
 var iframe;
 onload = t.step_func(function() {
   var iframe = document.getElementsByTagName("iframe")[0];
   iframe.contentWindow.setTimeout(t.step_func(function() {assert_unreached()}), 100);
   assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
   setTimeout(function() {t.done();}, 200);
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <title>Cancelling error after document.open</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
-<iframe src="004-1.html"></iframe>
+<iframe src="/common/blank.html"></iframe>
 <script>
 var t = async_test();
 var iframe;
 onload = t.step_func(function() {
   var iframe = document.getElementsByTagName("iframe")[0];
   var img = iframe.contentDocument.createElement("img");
   img.onerror = t.step_func(function() {assert_unreached()})
   img.src = "missing";
deleted file mode 100644
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/007.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!doctype html>
-<title>Unregistering event handlers after document.open</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<iframe src="004-1.html"></iframe>
-<script>
-var t = async_test();
-var iframe;
-onload = t.step_func(function() {
-  var iframe = document.getElementsByTagName("iframe")[0];
-  iframe.contentDocument.onclick = t.step_func(function() {assert_unreached()})
-  iframe.contentDocument.open();
-  var e = iframe.contentDocument.createEvent("mouseevents")
-  e.initEvent("click", false, false);
-  iframe.contentDocument.dispatchEvent(e);
-  setTimeout(function() {t.done();}, 500);
-});
-</script>
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <title>Replacement of document prototype object after document.open</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
-<iframe src="004-1.html"></iframe>
+<iframe src="/common/blank.html"></iframe>
 <script>
 var t = async_test();
 var iframe;
 onload = t.step_func(function() {
   var iframe = document.getElementsByTagName("iframe")[0];
   var handle = Object.getPrototypeOf(iframe.contentDocument);
   handle.test_state = 1;
   assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <title>document.open replacing singleton</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
-<iframe src="004-1.html"></iframe>
+<iframe src="/common/blank.html"></iframe>
 <script>
 var iframe = document.getElementsByTagName("iframe")[0];
 var steps;
 iframe.onload = function() {
 steps = ["window", "location", "history", "navigator", "applicationCache", "sessionStorage", "localStorage", "locationbar"].map(
 function(x) {
   var t = async_test(document.title + " " + x);
   var handle = iframe.contentWindow[x];
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js
@@ -1,19 +1,87 @@
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe")),
+        body = frame.contentDocument.body;
+  t.add_cleanup(() => frame.remove());
+  const div = body.appendChild(frame.contentDocument.createElement("div"));
+  div.addEventListener("click", t.unreached_func("element event listener not removed"));
+  frame.contentDocument.open();
+  div.click();
+  frame.contentDocument.close();
+}, "Standard event listeners are to be removed");
+
 test(t => {
   const frame = document.body.appendChild(document.createElement("iframe")),
         body = frame.contentDocument.body;
   t.add_cleanup(() => frame.remove());
   frame.contentDocument.addEventListener("x", t.unreached_func("document event listener not removed"));
   body.addEventListener("x", t.unreached_func("body event listener not removed"));
   frame.contentDocument.open();
   frame.contentDocument.dispatchEvent(new Event("x"));
   body.dispatchEvent(new Event("x"));
   frame.contentDocument.close();
-}, "Event listeners are to be removed");
+}, "Custom event listeners are to be removed");
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe")),
+        body = frame.contentDocument.body;
+  t.add_cleanup(() => frame.remove());
+  // Focus on the current window so that the frame's window is blurred.
+  window.focus();
+  assert_false(frame.contentDocument.hasFocus());
+  frame.contentWindow.addEventListener("focus", t.unreached_func("window event listener not removed"));
+  body.onfocus = t.unreached_func("body event listener not removed");
+  frame.contentDocument.open();
+  assert_equals(body.onfocus, null);
+  frame.contentWindow.focus();
+  frame.contentDocument.close();
+}, "Standard event listeners are to be removed from Window");
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe"));
+  t.add_cleanup(() => frame.remove());
+  frame.contentWindow.addEventListener("x", t.unreached_func("window event listener not removed"));
+  frame.contentDocument.open();
+  frame.contentWindow.dispatchEvent(new Event("x"));
+  frame.contentDocument.close();
+}, "Custom event listeners are to be removed from Window");
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe")),
+        body = frame.contentDocument.body;
+  t.add_cleanup(() => frame.remove());
+  const div = body.appendChild(frame.contentDocument.createElement("div"));
+  div.onclick = t.unreached_func("element event listener not removed");
+  frame.contentDocument.open();
+  assert_equals(div.onclick, null);
+  const e = frame.contentDocument.createEvent("mouseevents")
+  e.initEvent("click", false, false);
+  div.dispatchEvent(e);
+  frame.contentDocument.close();
+}, "IDL attribute event handlers are to be deactivated");
+
+var thrower;
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe")),
+        body = frame.contentDocument.body;
+  t.add_cleanup(() => frame.remove());
+  const div = body.appendChild(frame.contentDocument.createElement("div"));
+  thrower = t.step_func(() => { throw new Error('element event listener not removed'); });
+  div.setAttribute("onclick", "parent.thrower()");
+  assert_not_equals(div.onclick, null);
+  frame.contentDocument.open();
+  assert_equals(div.getAttribute("onclick"), "parent.thrower()");
+  assert_equals(div.onclick, null);
+  const e = frame.contentDocument.createEvent("mouseevents")
+  e.initEvent("click", false, false);
+  div.dispatchEvent(e);
+  frame.contentDocument.close();
+}, "Content attribute event handlers are to be deactivated");
 
 test(t => {
   const frame = document.body.appendChild(document.createElement("iframe"));
   t.add_cleanup(() => frame.remove());
   let once = false;
   frame.contentDocument.addEventListener("x", () => {
     frame.contentDocument.open();
     once = true;