Bug 1501983 - Add onslotchange event handler.r=smaug
authorSonia Singla <sonia.singla1812@gmail.com>
Fri, 27 Aug 2021 20:15:30 +0000
changeset 590165 85509bddf46fda02a1296d8c2a5b777f15978a94
parent 590164 4414779654746060da7d973f7dc6170c306b4fcb
child 590166 66f5b363f0d1c546d81c48cf937843982fdee2ba
push id148758
push useropettay@mozilla.com
push dateFri, 27 Aug 2021 20:17:51 +0000
treeherderautoland@85509bddf46f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1501983
milestone93.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 1501983 - Add onslotchange event handler.r=smaug Reflects following spec changes: - https://github.com/whatwg/html/pull/4129 - https://github.com/whatwg/dom/pull/785 Those new spec addition is already implemented in Safari and Chromium is working on it. Differential Revision: https://phabricator.services.mozilla.com/D123775
dom/base/ShadowRoot.h
dom/events/EventNameList.h
dom/webidl/EventHandler.webidl
dom/webidl/ShadowRoot.webidl
testing/web-platform/meta/dom/idlharness.window.js.ini
testing/web-platform/meta/html/dom/idlharness.https.html.ini
testing/web-platform/meta/html/webappapis/scripting/events/event-handler-all-global-events.html.ini
testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini
testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini
testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini
testing/web-platform/meta/mathml/relations/html5-tree/math-global-event-handlers.tentative.html.ini
widget/EventMessageList.h
xpcom/ds/StaticAtoms.py
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_shadowroot_h__
 #define mozilla_dom_shadowroot_h__
 
+#include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/DocumentBinding.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/DocumentOrShadowRoot.h"
 #include "mozilla/dom/NameSpaceConstants.h"
 #include "mozilla/dom/ShadowRootBinding.h"
 #include "mozilla/ServoBindings.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
@@ -158,16 +159,18 @@ class ShadowRoot final : public Document
   HTMLSlotElement* GetDefaultSlot() const {
     SlotArray* list = mSlotMap.Get(u""_ns);
     return list ? (*list)->ElementAt(0) : nullptr;
   }
 
   void PartAdded(const Element&);
   void PartRemoved(const Element&);
 
+  IMPL_EVENT_HANDLER(slotchange);
+
   const nsTArray<const Element*>& Parts() const { return mParts; }
 
   const RawServoAuthorStyles* GetServoStyles() const {
     return mServoStyles.get();
   }
 
   RawServoAuthorStyles* GetServoStyles() { return mServoStyles.get(); }
 
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -232,16 +232,17 @@ EVENT(play, ePlay, EventNameType_HTML, e
 EVENT(playing, ePlaying, EventNameType_HTML, eBasicEventClass)
 EVENT(progress, eProgress, EventNameType_HTML, eBasicEventClass)
 EVENT(ratechange, eRateChange, EventNameType_HTML, eBasicEventClass)
 EVENT(reset, eFormReset, EventNameType_HTMLXUL, eBasicEventClass)
 EVENT(seeked, eSeeked, EventNameType_HTML, eBasicEventClass)
 EVENT(seeking, eSeeking, EventNameType_HTML, eBasicEventClass)
 EVENT(select, eFormSelect, EventNameType_HTMLXUL, eBasicEventClass)
 EVENT(show, eShow, EventNameType_HTML, eBasicEventClass)
+EVENT(slotchange, eSlotChange, EventNameType_All, eBasicEventClass)
 EVENT(stalled, eStalled, EventNameType_HTML, eBasicEventClass)
 EVENT(start, eMarqueeStart, EventNameType_HTMLMarqueeOnly, eBasicEventClass)
 EVENT(submit, eFormSubmit, EventNameType_HTMLXUL, eBasicEventClass)
 EVENT(suspend, eSuspend, EventNameType_HTML, eBasicEventClass)
 EVENT(timeupdate, eTimeUpdate, EventNameType_HTML, eBasicEventClass)
 EVENT(toggle, eToggle, EventNameType_HTML, eBasicEventClass)
 EVENT(volumechange, eVolumeChange, EventNameType_HTML, eBasicEventClass)
 EVENT(waiting, eWaiting, EventNameType_HTML, eBasicEventClass)
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -80,16 +80,17 @@ interface mixin GlobalEventHandlers {
            attribute EventHandler onreset;
            attribute EventHandler onresize;
            attribute EventHandler onscroll;
            attribute EventHandler onseeked;
            attribute EventHandler onseeking;
            attribute EventHandler onselect;
            [Pref="dom.menuitem.enabled"]
            attribute EventHandler onshow;
+           attribute EventHandler onslotchange;
            //(Not implemented)attribute EventHandler onsort;
            attribute EventHandler onstalled;
            attribute EventHandler onsubmit;
            attribute EventHandler onsuspend;
            attribute EventHandler ontimeupdate;
            attribute EventHandler onvolumechange;
            attribute EventHandler onwaiting;
 
--- a/dom/webidl/ShadowRoot.webidl
+++ b/dom/webidl/ShadowRoot.webidl
@@ -22,16 +22,17 @@ enum SlotAssignmentMode { "manual", "nam
 [Exposed=Window]
 interface ShadowRoot : DocumentFragment
 {
   // Shadow DOM v1
   readonly attribute ShadowRootMode mode;
   [Pref="dom.shadowdom.slot.assign.enabled"]
   readonly attribute SlotAssignmentMode slotAssignment;
   readonly attribute Element host;
+  attribute EventHandler onslotchange;
 
   Element? getElementById(DOMString elementId);
 
   // https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin
   [CEReactions, SetterThrows]
   attribute [LegacyNullToEmptyString] DOMString innerHTML;
 
   // When JS invokes importNode or createElement, the binding code needs to
--- a/testing/web-platform/meta/dom/idlharness.window.js.ini
+++ b/testing/web-platform/meta/dom/idlharness.window.js.ini
@@ -1,14 +1,11 @@
 [idlharness.window.html?include=Node]
 
 [idlharness.window.html?exclude=Node]
   [Document interface: existence and properties of interface prototype object's @@unscopables property]
     expected: FAIL
 
-  [ShadowRoot interface: attribute onslotchange]
-    expected: FAIL
-
   [Stringification of document.createNSResolver(document.body)]
     expected: FAIL
 
   [ShadowRoot interface: attribute delegatesFocus]
     expected: FAIL
--- a/testing/web-platform/meta/html/dom/idlharness.https.html.ini
+++ b/testing/web-platform/meta/html/dom/idlharness.https.html.ini
@@ -547,19 +547,16 @@ prefs: [dom.security.featurePolicy.exper
     expected: FAIL
 
   [ElementInternals interface: attribute validity]
     expected: FAIL
 
   [SVGElement interface: attribute autofocus]
     expected: FAIL
 
-  [SVGElement interface: attribute onslotchange]
-    expected: FAIL
-
   [FormDataEvent interface object length]
     expected: FAIL
 
   [OffscreenCanvasRenderingContext2D interface: operation isPointInPath(Path2D, unrestricted double, unrestricted double, optional CanvasFillRule)]
     expected: FAIL
 
   [OffscreenCanvasRenderingContext2D interface: operation isPointInPath(unrestricted double, unrestricted double, optional CanvasFillRule)]
     expected: FAIL
@@ -745,34 +742,16 @@ prefs: [dom.security.featurePolicy.exper
     expected: FAIL
 
   [Document interface: iframe.contentDocument must inherit property "oncancel" with the proper type]
     expected: FAIL
 
   [Window interface: attribute oncancel]
     expected: FAIL
 
-  [Document interface: new Document() must inherit property "onslotchange" with the proper type]
-    expected: FAIL
-
-  [Document interface: documentWithHandlers must inherit property "onslotchange" with the proper type]
-    expected: FAIL
-
-  [Window interface: window must inherit property "onslotchange" with the proper type]
-    expected: FAIL
-
-  [Document interface: attribute onslotchange]
-    expected: FAIL
-
-  [Window interface: attribute onslotchange]
-    expected: FAIL
-
-  [Document interface: iframe.contentDocument must inherit property "onslotchange" with the proper type]
-    expected: FAIL
-
   [Window interface: operation print()]
     expected:
       if os == "android": FAIL
 
   [Window interface: window must inherit property "print()" with the proper type]
     expected:
       if os == "android": FAIL
 
@@ -942,22 +921,16 @@ prefs: [dom.security.featurePolicy.exper
     expected: FAIL
 
   [HTMLElement interface: document.createElement("noscript") must inherit property "autofocus" with the proper type]
     expected: FAIL
 
   [HTMLElement interface: attribute autofocus]
     expected: FAIL
 
-  [HTMLElement interface: attribute onslotchange]
-    expected: FAIL
-
-  [HTMLElement interface: document.createElement("noscript") must inherit property "onslotchange" with the proper type]
-    expected: FAIL
-
   [HTMLIFrameElement interface: attribute loading]
     expected: FAIL
 
   [HTMLMediaElement interface: attribute preservesPitch]
     expected: FAIL
 
   [HTMLMediaElement interface: new Audio() must inherit property "preservesPitch" with the proper type]
     expected: FAIL
--- a/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-all-global-events.html.ini
+++ b/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-all-global-events.html.ini
@@ -17,21 +17,8 @@
   [onsecuritypolicyviolation: the default value must be null]
     expected: FAIL
 
   [onsecuritypolicyviolation: the content attribute must be compiled into a function as the corresponding property]
     expected: FAIL
 
   [onsecuritypolicyviolation: the content attribute must execute when an event is dispatched]
     expected: FAIL
-
-  [onslotchange: must be on the appropriate locations for GlobalEventHandlers]
-    expected: FAIL
-
-  [onslotchange: the content attribute must be compiled into a function as the corresponding property]
-    expected: FAIL
-
-  [onslotchange: the default value must be null]
-    expected: FAIL
-
-  [onslotchange: the content attribute must execute when an event is dispatched]
-    expected: FAIL
-
--- a/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini
+++ b/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini
@@ -50,18 +50,8 @@
       if not debug and (os == "win") and (version == "6.1.7601"): FAIL
 
   [shadowed unload removal (document.createElement("body"))]
     disabled: Bug 1485887
     expected:
       if not debug and e10s and (os == "linux") and (processor == "x86_64"): FAIL
       if not debug and (os == "mac"): FAIL
       if not debug and (os == "win") and (version == "6.1.7601"): FAIL
-
-  [not shadowed slotchange (window)]
-    expected: FAIL
-
-  [not shadowed slotchange (document.createElement("body"))]
-    expected: FAIL
-
-  [not shadowed slotchange (document.body)]
-    expected: FAIL
-
--- a/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini
+++ b/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini
@@ -44,18 +44,8 @@
     disabled: Bug 1485887
     expected:
       if not debug and not webrender and e10s and (os == "linux"): FAIL
 
   [shadowed unload removal (document.createElement("frameset"))]
     disabled: Bug 1485887
     expected:
       if not debug and not webrender and e10s and (os == "linux"): FAIL
-
-  [not shadowed slotchange (window)]
-    expected: FAIL
-
-  [not shadowed slotchange (document.createElement("frameset"))]
-    expected: FAIL
-
-  [not shadowed slotchange (document.body)]
-    expected: FAIL
-
--- a/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini
+++ b/testing/web-platform/meta/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini
@@ -6,14 +6,8 @@
     expected: FAIL
 
   [cancel is unaffected on a windowless frameset]
     expected: FAIL
 
   [securitypolicyviolation is unaffected on a windowless frameset]
     expected: FAIL
 
-  [slotchange is unaffected on a windowless frameset]
-    expected: FAIL
-
-  [slotchange is unaffected on a windowless body]
-    expected: FAIL
-
--- a/testing/web-platform/meta/mathml/relations/html5-tree/math-global-event-handlers.tentative.html.ini
+++ b/testing/web-platform/meta/mathml/relations/html5-tree/math-global-event-handlers.tentative.html.ini
@@ -1,33 +1,21 @@
 [math-global-event-handlers.tentative.html]
   [onsecuritypolicyviolation: dispatching an Event at a <math> element must trigger element.onsecuritypolicyviolation]
     expected: FAIL
 
   [oncancel: the default value must be null]
     expected: FAIL
 
-  [onslotchange: the default value must be null]
-    expected: FAIL
-
   [oncancel: the content attribute must be compiled into a function as the corresponding property]
     expected: FAIL
 
-  [onslotchange: dynamic changes on the attribute]
-    expected: FAIL
-
   [oncancel: dispatching an Event at a <math> element must trigger element.oncancel]
     expected: FAIL
 
-  [onslotchange: must be on the appropriate locations for GlobalEventHandlers]
-    expected: FAIL
-
-  [onslotchange: the content attribute must be compiled into a function as the corresponding property]
-    expected: FAIL
-
   [oncancel: must be on the appropriate locations for GlobalEventHandlers]
     expected: FAIL
 
   [oncancel: dynamic changes on the attribute]
     expected: FAIL
 
   [onsecuritypolicyviolation: dynamic changes on the attribute]
     expected: FAIL
@@ -35,12 +23,8 @@
   [onsecuritypolicyviolation: the default value must be null]
     expected: FAIL
 
   [onsecuritypolicyviolation: must be on the appropriate locations for GlobalEventHandlers]
     expected: FAIL
 
   [onsecuritypolicyviolation: the content attribute must be compiled into a function as the corresponding property]
     expected: FAIL
-
-  [onslotchange: dispatching an Event at a <math> element must trigger element.onslotchange]
-    expected: FAIL
-
--- a/widget/EventMessageList.h
+++ b/widget/EventMessageList.h
@@ -452,16 +452,17 @@ NS_EVENT_MESSAGE_FIRST_LAST(eGamepadEven
 
 // input and beforeinput events.
 NS_EVENT_MESSAGE(eEditorInput)
 NS_EVENT_MESSAGE(eEditorBeforeInput)
 
 // selection events
 NS_EVENT_MESSAGE(eSelectStart)
 NS_EVENT_MESSAGE(eSelectionChange)
+NS_EVENT_MESSAGE(eSlotChange)
 
 // visibility change
 NS_EVENT_MESSAGE(eVisibilityChange)
 
 // Details element events.
 NS_EVENT_MESSAGE(eToggle)
 
 // Dialog element events.
--- a/xpcom/ds/StaticAtoms.py
+++ b/xpcom/ds/StaticAtoms.py
@@ -892,16 +892,17 @@ STATIC_ATOMS = [
     Atom("onselect", "onselect"),
     Atom("onselectionchange", "onselectionchange"),
     Atom("onselectend", "onselectend"),
     Atom("onselectstart", "onselectstart"),
     Atom("onset", "onset"),
     Atom("onshippingaddresschange", "onshippingaddresschange"),
     Atom("onshippingoptionchange", "onshippingoptionchange"),
     Atom("onshow", "onshow"),
+    Atom("onslotchange", "onslotchange"),
     Atom("onsqueeze", "onsqueeze"),
     Atom("onsqueezeend", "onsqueezeend"),
     Atom("onsqueezestart", "onsqueezestart"),
     Atom("onstatechange", "onstatechange"),
     Atom("onstorage", "onstorage"),
     Atom("onsubmit", "onsubmit"),
     Atom("onsuccess", "onsuccess"),
     Atom("ontypechange", "ontypechange"),