From 75084036103e0ce32a854f7c3540bd00611212f4 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Wed, 8 Aug 2018 13:51:25 -0400 Subject: [PATCH] Revise event listener removal in document.open() This change aligns the event listener removal behavior with implementations, specifically in two aspects: - The event handler's value should be set to null (i.e., deactivated). - Event listeners and handlers should be removed from the Window object as well. See prior investigation around deactivation of event handlers in #3836 and #3850. See investigation around `document.open()`'s behavior in #3818. Tests: https://github.com/web-platform-tests/wpt/pull/12122 --- source | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/source b/source index 2914c18f1fc..60fb32e02a9 100644 --- a/source +++ b/source @@ -89889,8 +89889,7 @@ dictionary PromiseRejectionEventInit : EventInit {

To deactivate an event handler given an EventTarget object eventTarget and a string name that is the name of an event handler, take the following - steps:

+ name">name of an event handler, run these steps:

  1. Let handlerMap be eventTarget's event handler @@ -89911,10 +89910,24 @@ dictionary PromiseRejectionEventInit : EventInit { null.

+

To erase all event listeners and handlers given an EventTarget object + eventTarget, run these steps:

+ +
    +
  1. If eventTarget has an associated event handler map, then for each + nameeventHandler of eventTarget's associated event + handler map, deactivate an event handler given eventTarget and + name.

  2. + +
  3. Remove all event listeners given eventTarget.

  4. +
+ +

This algorithm is used to define document.open(type, replace).

+

To activate an event handler given an EventTarget object eventTarget and a string name that is the name of an event handler, take the following - steps:

+ name">name of an event handler, run these steps:

  1. Let handlerMap be eventTarget's event handler @@ -90929,6 +90942,9 @@ document.body.appendChild(frame)

  2. If document is not an active document, then return document.

  3. +
  4. Let window be document's relevant global object.

  5. +
  6. If document's origin is not same origin to the origin of the responsible document specified by the entry settings object, then throw a "SecurityError" @@ -90983,7 +90999,10 @@ document.body.appendChild(frame)

  7. Abort document.

  8. For each shadow-including inclusive descendant node of - document, remove all event listeners with node.

  9. + document, erase all event listeners and handlers given + node.

    + +
  10. Erase all event listeners and handlers given window.

  11. Remove any tasks associated with document in any task source.

  12. @@ -90998,8 +91017,8 @@ document.body.appendChild(frame) realm with the following customizations: