Skip to content

Commit

Permalink
Add onslotchange event handler IDL attribute
Browse files Browse the repository at this point in the history
`onslotchange` IDL attribute is supported by interfaces:
- GlobalEventHandlers [1]
- ShadowRoot [2]

Reflects following spec changes:
- whatwg/html#4129
- whatwg/dom#785

Those new spec addition is already implemented in Safari and Gecko[3].

Intent to Ship mail with 3 approvals: [4]

[1] https://html.spec.whatwg.org/#globaleventhandlers
[2] https://dom.spec.whatwg.org/#interface-shadowroot
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1501983
[4] https://groups.google.com/a/chromium.org/g/blink-dev/c/cagoIboJ6Oo/m/roPoRAEDBAAJ

R=fwang@igalia.com, rego@igalia.com

Bug: 1006096
Change-Id: I3d0d7eb437aba3e40d24cca9bcf31d1db701f970
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3096889
Commit-Queue: SONIA SINGLA <ssingla@igalia.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: Manuel Rego <rego@igalia.com>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#931541}
NOKEYCHECK=True
GitOrigin-RevId: ec5cf31361e9822ad4c8999dcb34aa1bcca2907a
  • Loading branch information
Sonia Singla authored and copybara-github committed Oct 14, 2021
1 parent c9d84fe commit d4211d8
Show file tree
Hide file tree
Showing 25 changed files with 76 additions and 36 deletions.
1 change: 1 addition & 0 deletions blink/renderer/core/dom/global_event_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class GlobalEventHandlers {
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(select, kSelect)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(selectionchange, kSelectionchange)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(selectstart, kSelectstart)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(slotchange, kSlotchange)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(stalled, kStalled)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(submit, kSubmit)
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(suspend, kSuspend)
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/core/dom/global_event_handlers.idl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onslotchange;
//attribute EventHandler onsort;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
Expand Down
2 changes: 2 additions & 0 deletions blink/renderer/core/dom/shadow_root.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class CORE_EXPORT ShadowRoot final : public DocumentFragment, public TreeScope {
using TreeScope::SetDocument;
using TreeScope::SetParentTreeScope;

DEFINE_ATTRIBUTE_EVENT_LISTENER(slotchange, kSlotchange)

Element& host() const {
DCHECK(ParentOrShadowHostNode());
return *To<Element>(ParentOrShadowHostNode());
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/core/dom/shadow_root.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
interface ShadowRoot : DocumentFragment {
readonly attribute ShadowRootMode mode;
readonly attribute Element host;
attribute EventHandler onslotchange;
// TODO(lyf): Change the type to `[TreatNullAs=xxx] HTMLString` after
// https://crbug.com/1058762 has been fixed.
[CEReactions, RaisesException=Setter] attribute [TreatNullAs=EmptyString, StringContext=TrustedHTML] DOMString innerHTML;
Expand Down
1 change: 1 addition & 0 deletions blink/renderer/core/html/html_attribute_names.json5
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
"onselectstart",
"onselectionchange",
"onshow",
"onslotchange",
"onstalled",
"onstorage",
"onsuspend",
Expand Down
2 changes: 2 additions & 0 deletions blink/renderer/core/html/html_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ AttributeTriggers* HTMLElement::TriggersForAttributeName(
nullptr},
{html_names::kOnselectstartAttr, kNoWebFeature,
event_type_names::kSelectstart, nullptr},
{html_names::kOnslotchangeAttr, kNoWebFeature,
event_type_names::kSlotchange, nullptr},
{html_names::kOnstalledAttr, kNoWebFeature, event_type_names::kStalled,
nullptr},
{html_names::kOnsubmitAttr, kNoWebFeature, event_type_names::kSubmit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 1286 tests; 1282 PASS, 4 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 1286 tests; 1283 PASS, 3 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface Window: original interface defined
Expand Down Expand Up @@ -559,7 +559,7 @@ PASS ShadowRoot interface: attribute mode
PASS ShadowRoot interface: attribute delegatesFocus
PASS ShadowRoot interface: attribute slotAssignment
PASS ShadowRoot interface: attribute host
FAIL ShadowRoot interface: attribute onslotchange assert_true: The prototype object must have a property "onslotchange" expected true got false
PASS ShadowRoot interface: attribute onslotchange
PASS Element interface: existence and properties of interface object
PASS Element interface object length
PASS Element interface object name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 1459 tests; 1418 PASS, 41 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 1459 tests; 1419 PASS, 40 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface Document: original interface defined
Expand Down Expand Up @@ -1420,7 +1420,7 @@ FAIL SVGElement interface: attribute onsecuritypolicyviolation assert_true: The
PASS SVGElement interface: attribute onseeked
PASS SVGElement interface: attribute onseeking
PASS SVGElement interface: attribute onselect
FAIL SVGElement interface: attribute onslotchange assert_true: The prototype object must have a property "onslotchange" expected true got false
PASS SVGElement interface: attribute onslotchange
PASS SVGElement interface: attribute onstalled
PASS SVGElement interface: attribute onsubmit
PASS SVGElement interface: attribute onsuspend
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 984 tests; 960 PASS, 24 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 984 tests; 966 PASS, 18 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface Document: original interface defined
Expand Down Expand Up @@ -273,7 +273,7 @@ FAIL Window interface: attribute onsecuritypolicyviolation assert_own_property:
PASS Window interface: attribute onseeked
PASS Window interface: attribute onseeking
PASS Window interface: attribute onselect
FAIL Window interface: attribute onslotchange assert_own_property: The global object must have a property "onslotchange" expected property "onslotchange" missing
PASS Window interface: attribute onslotchange
PASS Window interface: attribute onstalled
PASS Window interface: attribute onsubmit
PASS Window interface: attribute onsuspend
Expand Down Expand Up @@ -428,7 +428,7 @@ FAIL Window interface: window must inherit property "onsecuritypolicyviolation"
PASS Window interface: window must inherit property "onseeked" with the proper type
PASS Window interface: window must inherit property "onseeking" with the proper type
PASS Window interface: window must inherit property "onselect" with the proper type
FAIL Window interface: window must inherit property "onslotchange" with the proper type assert_own_property: expected property "onslotchange" missing
PASS Window interface: window must inherit property "onslotchange" with the proper type
PASS Window interface: window must inherit property "onstalled" with the proper type
PASS Window interface: window must inherit property "onsubmit" with the proper type
PASS Window interface: window must inherit property "onsuspend" with the proper type
Expand Down Expand Up @@ -586,7 +586,7 @@ PASS Document interface: attribute onsecuritypolicyviolation
PASS Document interface: attribute onseeked
PASS Document interface: attribute onseeking
PASS Document interface: attribute onselect
FAIL Document interface: attribute onslotchange assert_true: The prototype object must have a property "onslotchange" expected true got false
PASS Document interface: attribute onslotchange
PASS Document interface: attribute onstalled
PASS Document interface: attribute onsubmit
PASS Document interface: attribute onsuspend
Expand Down Expand Up @@ -713,7 +713,7 @@ PASS Document interface: iframe.contentDocument must inherit property "onsecurit
PASS Document interface: iframe.contentDocument must inherit property "onseeked" with the proper type
PASS Document interface: iframe.contentDocument must inherit property "onseeking" with the proper type
PASS Document interface: iframe.contentDocument must inherit property "onselect" with the proper type
FAIL Document interface: iframe.contentDocument must inherit property "onslotchange" with the proper type assert_inherits: property "onslotchange" not found in prototype chain
PASS Document interface: iframe.contentDocument must inherit property "onslotchange" with the proper type
PASS Document interface: iframe.contentDocument must inherit property "onstalled" with the proper type
PASS Document interface: iframe.contentDocument must inherit property "onsubmit" with the proper type
PASS Document interface: iframe.contentDocument must inherit property "onsuspend" with the proper type
Expand Down Expand Up @@ -840,7 +840,7 @@ PASS Document interface: new Document() must inherit property "onsecuritypolicyv
PASS Document interface: new Document() must inherit property "onseeked" with the proper type
PASS Document interface: new Document() must inherit property "onseeking" with the proper type
PASS Document interface: new Document() must inherit property "onselect" with the proper type
FAIL Document interface: new Document() must inherit property "onslotchange" with the proper type assert_inherits: property "onslotchange" not found in prototype chain
PASS Document interface: new Document() must inherit property "onslotchange" with the proper type
PASS Document interface: new Document() must inherit property "onstalled" with the proper type
PASS Document interface: new Document() must inherit property "onsubmit" with the proper type
PASS Document interface: new Document() must inherit property "onsuspend" with the proper type
Expand Down Expand Up @@ -967,7 +967,7 @@ PASS Document interface: documentWithHandlers must inherit property "onsecurityp
PASS Document interface: documentWithHandlers must inherit property "onseeked" with the proper type
PASS Document interface: documentWithHandlers must inherit property "onseeking" with the proper type
PASS Document interface: documentWithHandlers must inherit property "onselect" with the proper type
FAIL Document interface: documentWithHandlers must inherit property "onslotchange" with the proper type assert_inherits: property "onslotchange" found on object expected in prototype chain
PASS Document interface: documentWithHandlers must inherit property "onslotchange" with the proper type
PASS Document interface: documentWithHandlers must inherit property "onstalled" with the proper type
PASS Document interface: documentWithHandlers must inherit property "onsubmit" with the proper type
PASS Document interface: documentWithHandlers must inherit property "onsuspend" with the proper type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 3772 tests; 3746 PASS, 26 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 3772 tests; 3748 PASS, 24 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface Document: original interface defined
Expand Down Expand Up @@ -291,7 +291,7 @@ FAIL HTMLElement interface: attribute onsecuritypolicyviolation assert_true: The
PASS HTMLElement interface: attribute onseeked
PASS HTMLElement interface: attribute onseeking
PASS HTMLElement interface: attribute onselect
FAIL HTMLElement interface: attribute onslotchange assert_true: The prototype object must have a property "onslotchange" expected true got false
PASS HTMLElement interface: attribute onslotchange
PASS HTMLElement interface: attribute onstalled
PASS HTMLElement interface: attribute onsubmit
PASS HTMLElement interface: attribute onsuspend
Expand Down Expand Up @@ -388,7 +388,7 @@ FAIL HTMLElement interface: document.createElement("noscript") must inherit prop
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onseeked" with the proper type
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onseeking" with the proper type
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onselect" with the proper type
FAIL HTMLElement interface: document.createElement("noscript") must inherit property "onslotchange" with the proper type assert_inherits: property "onslotchange" not found in prototype chain
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onslotchange" with the proper type
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onstalled" with the proper type
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onsubmit" with the proper type
PASS HTMLElement interface: document.createElement("noscript") must inherit property "onsuspend" with the proper type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 335 tests; 319 PASS, 16 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 335 tests; 323 PASS, 12 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS onabort: must be on the appropriate locations for GlobalEventHandlers
PASS onabort: the default value must be null
PASS onabort: the content attribute must be compiled into a function as the corresponding property
Expand Down Expand Up @@ -270,10 +270,10 @@ PASS onselect: the default value must be null
PASS onselect: the content attribute must be compiled into a function as the corresponding property
PASS onselect: the content attribute must execute when an event is dispatched
PASS onselect: dispatching an Event at a <meta> element must trigger element.onselect
FAIL onslotchange: must be on the appropriate locations for GlobalEventHandlers assert_true: Window has an own property named "onslotchange" expected true got false
FAIL onslotchange: the default value must be null assert_equals: The default value of the property is null for a Window instance expected (object) null but got (undefined) undefined
FAIL onslotchange: the content attribute must be compiled into a function as the corresponding property assert_equals: The onslotchange property must be a function expected "function" but got "undefined"
FAIL onslotchange: the content attribute must execute when an event is dispatched assert_true: Dispatching an event must run the code expected true got undefined
PASS onslotchange: must be on the appropriate locations for GlobalEventHandlers
PASS onslotchange: the default value must be null
PASS onslotchange: the content attribute must be compiled into a function as the corresponding property
PASS onslotchange: the content attribute must execute when an event is dispatched
PASS onslotchange: dispatching an Event at a <meta> element must trigger element.onslotchange
PASS onstalled: must be on the appropriate locations for GlobalEventHandlers
PASS onstalled: the default value must be null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 327 tests; 309 PASS, 18 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 327 tests; 312 PASS, 15 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS shadowed blur (document.body)
PASS shadowed error (document.body)
PASS shadowed focus (document.body)
Expand Down Expand Up @@ -71,7 +71,7 @@ FAIL not shadowed securitypolicyviolation (document.body) assert_equals: alterna
PASS not shadowed seeked (document.body)
PASS not shadowed seeking (document.body)
PASS not shadowed select (document.body)
FAIL not shadowed slotchange (document.body) assert_equals: alternative body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed slotchange (document.body)
PASS not shadowed stalled (document.body)
PASS not shadowed submit (document.body)
PASS not shadowed suspend (document.body)
Expand Down Expand Up @@ -180,7 +180,7 @@ FAIL not shadowed securitypolicyviolation (document.createElement("body")) asser
PASS not shadowed seeked (document.createElement("body"))
PASS not shadowed seeking (document.createElement("body"))
PASS not shadowed select (document.createElement("body"))
FAIL not shadowed slotchange (document.createElement("body")) assert_equals: body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed slotchange (document.createElement("body"))
PASS not shadowed stalled (document.createElement("body"))
PASS not shadowed submit (document.createElement("body"))
PASS not shadowed suspend (document.createElement("body"))
Expand Down Expand Up @@ -289,7 +289,7 @@ FAIL not shadowed securitypolicyviolation (window) assert_equals: body should re
PASS not shadowed seeked (window)
PASS not shadowed seeking (window)
PASS not shadowed select (window)
FAIL not shadowed slotchange (window) assert_equals: body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed slotchange (window)
PASS not shadowed stalled (window)
PASS not shadowed submit (window)
PASS not shadowed suspend (window)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 327 tests; 309 PASS, 18 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 327 tests; 312 PASS, 15 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS shadowed blur (document.body)
PASS shadowed error (document.body)
PASS shadowed focus (document.body)
Expand Down Expand Up @@ -71,7 +71,7 @@ FAIL not shadowed securitypolicyviolation (document.body) assert_equals: alterna
PASS not shadowed seeked (document.body)
PASS not shadowed seeking (document.body)
PASS not shadowed select (document.body)
FAIL not shadowed slotchange (document.body) assert_equals: alternative body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed slotchange (document.body)
PASS not shadowed stalled (document.body)
PASS not shadowed submit (document.body)
PASS not shadowed suspend (document.body)
Expand Down Expand Up @@ -180,7 +180,7 @@ FAIL not shadowed securitypolicyviolation (document.createElement("frameset")) a
PASS not shadowed seeked (document.createElement("frameset"))
PASS not shadowed seeking (document.createElement("frameset"))
PASS not shadowed select (document.createElement("frameset"))
FAIL not shadowed slotchange (document.createElement("frameset")) assert_equals: body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed slotchange (document.createElement("frameset"))
PASS not shadowed stalled (document.createElement("frameset"))
PASS not shadowed submit (document.createElement("frameset"))
PASS not shadowed suspend (document.createElement("frameset"))
Expand Down Expand Up @@ -289,7 +289,7 @@ FAIL not shadowed securitypolicyviolation (window) assert_equals: body should re
PASS not shadowed seeked (window)
PASS not shadowed seeking (window)
PASS not shadowed select (window)
FAIL not shadowed slotchange (window) assert_equals: body should reflect expected (object) null but got (undefined) undefined
PASS not shadowed slotchange (window)
PASS not shadowed stalled (window)
PASS not shadowed submit (window)
PASS not shadowed suspend (window)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 218 tests; 210 PASS, 8 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 218 tests; 212 PASS, 6 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Return null when getting the blur event handler of a windowless body
PASS Ignore setting of blur window event handlers on windowless body
PASS Return null when getting the error event handler of a windowless body
Expand Down Expand Up @@ -93,7 +93,7 @@ FAIL securitypolicyviolation is unaffected on a windowless body assert_equals: e
PASS seeked is unaffected on a windowless body
PASS seeking is unaffected on a windowless body
PASS select is unaffected on a windowless body
FAIL slotchange is unaffected on a windowless body assert_equals: expected (object) null but got (undefined) undefined
PASS slotchange is unaffected on a windowless body
PASS stalled is unaffected on a windowless body
PASS submit is unaffected on a windowless body
PASS suspend is unaffected on a windowless body
Expand Down Expand Up @@ -202,7 +202,7 @@ FAIL securitypolicyviolation is unaffected on a windowless frameset assert_equal
PASS seeked is unaffected on a windowless frameset
PASS seeking is unaffected on a windowless frameset
PASS select is unaffected on a windowless frameset
FAIL slotchange is unaffected on a windowless frameset assert_equals: expected (object) null but got (undefined) undefined
PASS slotchange is unaffected on a windowless frameset
PASS stalled is unaffected on a windowless frameset
PASS submit is unaffected on a windowless frameset
PASS suspend is unaffected on a windowless frameset
Expand Down
Loading

0 comments on commit d4211d8

Please sign in to comment.