Bug 1457485 [wpt PR 10686] - HTML: document.open() event listener removal, a=testonly draft
authorAnne van Kesteren <annevk@annevk.nl>
Thu, 03 May 2018 22:22:44 +0000
changeset 791487 b76caf562e12410cd6c5213c607f525de2a77b00
parent 791486 d4349e97e7798f3dddb3d4d40feb8eaf01bac9d9
child 791488 7feccba11bf0ac80ada685be93ca98bb8be6b02e
push id108825
push userbmo:james@hoppipolla.co.uk
push dateFri, 04 May 2018 14:12:31 +0000
reviewerstestonly
bugs1457485, 10686
milestone61.0a1
Bug 1457485 [wpt PR 10686] - HTML: document.open() event listener removal, a=testonly Automatic update from web-platform-testsHTML: document.open() event listener removal For https://github.com/whatwg/html/pull/3653. -- wpt-commits: 923d852c61cb50cb3be540dcbf54f2d5ec1518e1 wpt-pr: 10686
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/dom/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
@@ -333524,16 +333524,22 @@
     ]
    ],
    "html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html": [
     [
      "/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html",
      {}
     ]
    ],
+   "html/dom/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js": [
+    [
+     "/html/dom/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.html",
+     {}
+    ]
+   ],
    "html/dom/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.js": [
     [
      "/html/dom/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.html",
      {}
     ]
    ],
    "html/dom/dynamic-markup-insertion/opening-the-input-stream/type-argument-plaintext.window.js": [
     [
@@ -564389,16 +564395,20 @@
   "html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.html": [
    "bcc6a14a9c3d116d95e72d3f057d0cd7cbffd2cb",
    "support"
   ],
   "html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html": [
    "a2a5acc9dfe53c7482eeaa4be3a4819238f8e120",
    "testharness"
   ],
+  "html/dom/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js": [
+   "ccf357a8081b99de1d85e05196145e83b3de2ab5",
+   "testharness"
+  ],
   "html/dom/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.js": [
    "1e1c656e1d19c9c459faf16327e099a4c9e13872",
    "testharness"
   ],
   "html/dom/dynamic-markup-insertion/opening-the-input-stream/type-argument-plaintext-subframe.txt": [
    "8d06cea05d408d70c59b1dbc5df3bda374d869a4",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js
@@ -0,0 +1,42 @@
+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");
+
+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;
+  });
+  frame.contentDocument.addEventListener("x", t.unreached_func("second event listener not removed"));
+  frame.contentDocument.dispatchEvent(new Event("x"));
+  assert_true(once);
+  frame.contentDocument.close();
+}, "Event listeners are to be removed with immediate effect");
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe")),
+        shadow = frame.contentDocument.body.attachShadow({ mode: "closed" }),
+        shadowChild = shadow.appendChild(document.createElement("div")),
+        shadowShadow = shadowChild.attachShadow({ mode: "open" }),
+        nodes = [shadow, shadowChild, shadowShadow];
+  t.add_cleanup(() => frame.remove());
+  nodes.forEach(node => {
+    node.addEventListener("x", t.unreached_func(node + "'s event listener not removed"));
+  });
+  frame.contentDocument.open();
+  nodes.forEach(node => {
+    node.dispatchEvent(new Event("x"));
+  });
+  frame.contentDocument.close();
+}, "Event listeners are to be removed from shadow trees as well");