Title: [286898] trunk
Revision
286898
Author
shvaikal...@gmail.com
Date
2021-12-10 19:02:38 -0800 (Fri, 10 Dec 2021)

Log Message

Setting "onselectionchange" content attribute should add an event listener
https://bugs.webkit.org/show_bug.cgi?id=234167

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Import WPT tests from https://github.com/web-platform-tests/wpt/pull/32013.

* web-platform-tests/selection/textcontrols: Added.
* web-platform-tests/selection/textcontrols/onselectionchange-content-attribute-expected.txt: Added.
* web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html: Added.

Source/WebCore:

This patch implements full support for "onselectionchange" content attribute,
enabling it to add an event listener on any element, which fixes regression
introduced in r268745 and aligns "onselectionchange" with "onselectstart".

Aligns WebKit with Gecko and the spec [1].

[1] https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers-interface

Tests: fast/dom/event-handler-attributes.html
       imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html

* html/HTMLElement.cpp:
(WebCore::HTMLElement::createEventHandlerNameMap):

LayoutTests:

* fast/dom/event-handler-attributes-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286897 => 286898)


--- trunk/LayoutTests/ChangeLog	2021-12-11 02:45:31 UTC (rev 286897)
+++ trunk/LayoutTests/ChangeLog	2021-12-11 03:02:38 UTC (rev 286898)
@@ -1,3 +1,12 @@
+2021-12-10  Alexey Shvayka  <ashva...@apple.com>
+
+        Setting "onselectionchange" content attribute should add an event listener
+        https://bugs.webkit.org/show_bug.cgi?id=234167
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/event-handler-attributes-expected.txt:
+
 2021-12-10  Joonghun Park  <jh718.p...@samsung.com>
 
         Don't do simplification for percentage comparison resolution against negative reference values.

Modified: trunk/LayoutTests/fast/dom/event-handler-attributes-expected.txt (286897 => 286898)


--- trunk/LayoutTests/fast/dom/event-handler-attributes-expected.txt	2021-12-11 02:45:31 UTC (rev 286897)
+++ trunk/LayoutTests/fast/dom/event-handler-attributes-expected.txt	2021-12-11 03:02:38 UTC (rev 286898)
@@ -252,7 +252,7 @@
 PASS testElementAttribute(element, "seeked") is "target"
 PASS testElementAttribute(element, "seeking") is "target"
 PASS testElementAttribute(element, "select") is "target"
-FAIL testElementAttribute(element, "selectionchange") should be target. Was script: target; content: none.
+PASS testElementAttribute(element, "selectionchange") is "target"
 PASS testElementAttribute(element, "selectstart") is "target"
 PASS testElementAttribute(element, "stalled") is "target"
 PASS testElementAttribute(element, "submit") is "target"
@@ -345,7 +345,7 @@
 PASS testElementAttribute(inputElement, "seeked") is "target"
 PASS testElementAttribute(inputElement, "seeking") is "target"
 PASS testElementAttribute(inputElement, "select") is "target"
-FAIL testElementAttribute(inputElement, "selectionchange") should be target. Was script: target; content: none.
+PASS testElementAttribute(inputElement, "selectionchange") is "target"
 PASS testElementAttribute(inputElement, "selectstart") is "target"
 PASS testElementAttribute(inputElement, "stalled") is "target"
 PASS testElementAttribute(inputElement, "submit") is "target"
@@ -438,7 +438,7 @@
 PASS testElementAttribute(audioElement, "seeked") is "target"
 PASS testElementAttribute(audioElement, "seeking") is "target"
 PASS testElementAttribute(audioElement, "select") is "target"
-FAIL testElementAttribute(audioElement, "selectionchange") should be target. Was script: target; content: none.
+PASS testElementAttribute(audioElement, "selectionchange") is "target"
 PASS testElementAttribute(audioElement, "selectstart") is "target"
 PASS testElementAttribute(audioElement, "stalled") is "target"
 PASS testElementAttribute(audioElement, "submit") is "target"
@@ -531,7 +531,7 @@
 PASS testElementAttribute(videoElement, "seeked") is "target"
 PASS testElementAttribute(videoElement, "seeking") is "target"
 PASS testElementAttribute(videoElement, "select") is "target"
-FAIL testElementAttribute(videoElement, "selectionchange") should be target. Was script: target; content: none.
+PASS testElementAttribute(videoElement, "selectionchange") is "target"
 PASS testElementAttribute(videoElement, "selectstart") is "target"
 PASS testElementAttribute(videoElement, "stalled") is "target"
 PASS testElementAttribute(videoElement, "submit") is "target"
@@ -682,7 +682,7 @@
 
 Event names we expect to be forwarded from <frameset> element to document)
 
-FAIL testElementAttribute(framesetElement, "selectionchange") should be document. Was script: target; content: none.
+FAIL testElementAttribute(framesetElement, "selectionchange") should be document. Was target.
 
 Non-forwarded event names on <frameset> element
 
@@ -822,7 +822,7 @@
 PASS testElementAttribute(rectElement, "seeked") is "target"
 PASS testElementAttribute(rectElement, "seeking") is "target"
 PASS testElementAttribute(rectElement, "select") is "target"
-FAIL testElementAttribute(rectElement, "selectionchange") should be target. Was script: target; content: none.
+PASS testElementAttribute(rectElement, "selectionchange") is "target"
 PASS testElementAttribute(rectElement, "selectstart") is "target"
 PASS testElementAttribute(rectElement, "stalled") is "target"
 PASS testElementAttribute(rectElement, "submit") is "target"

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286897 => 286898)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-11 02:45:31 UTC (rev 286897)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-11 03:02:38 UTC (rev 286898)
@@ -1,3 +1,16 @@
+2021-12-10  Alexey Shvayka  <ashva...@apple.com>
+
+        Setting "onselectionchange" content attribute should add an event listener
+        https://bugs.webkit.org/show_bug.cgi?id=234167
+
+        Reviewed by Darin Adler.
+
+        Import WPT tests from https://github.com/web-platform-tests/wpt/pull/32013.
+
+        * web-platform-tests/selection/textcontrols: Added.
+        * web-platform-tests/selection/textcontrols/onselectionchange-content-attribute-expected.txt: Added.
+        * web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html: Added.
+
 2021-12-10  Joonghun Park  <jh718.p...@samsung.com>
 
         Don't do simplification for percentage comparison resolution against negative reference values.

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute-expected.txt (0 => 286898)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute-expected.txt	2021-12-11 03:02:38 UTC (rev 286898)
@@ -0,0 +1,4 @@
+
+PASS handler set from parser
+PASS handler set via setAttribute()
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html (0 => 286898)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html	2021-12-11 03:02:38 UTC (rev 286898)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test that setting "onselectionchange" content attribute adds an event listener</title>
+<link rel="help" href=""
+
+<script src=""
+<script src=""
+
+<body>
+<div id="testElement" _onselectionchange_="window.handlerSetFromParserWasFired()"></div>
+<script>
+  promise_test(() => {
+    return new Promise(resolve => {
+      window.handlerSetFromParserWasFired = resolve;
+      testElement.dispatchEvent(new Event("selectionchange"));
+    });
+  }, "handler set from parser");
+
+  promise_test(() => {
+    const el = document.createElement("div");
+    el.setAttribute("onselectionchange", "window.handlerSetViaSetAttributeWasFired()");
+    document.body.append(el);
+
+    return new Promise(resolve => {
+      window.handlerSetViaSetAttributeWasFired = resolve;
+      el.dispatchEvent(new Event("selectionchange"));
+    });
+  }, "handler set via setAttribute()");
+</script>

Modified: trunk/Source/WebCore/ChangeLog (286897 => 286898)


--- trunk/Source/WebCore/ChangeLog	2021-12-11 02:45:31 UTC (rev 286897)
+++ trunk/Source/WebCore/ChangeLog	2021-12-11 03:02:38 UTC (rev 286898)
@@ -1,3 +1,24 @@
+2021-12-10  Alexey Shvayka  <ashva...@apple.com>
+
+        Setting "onselectionchange" content attribute should add an event listener
+        https://bugs.webkit.org/show_bug.cgi?id=234167
+
+        Reviewed by Darin Adler.
+
+        This patch implements full support for "onselectionchange" content attribute,
+        enabling it to add an event listener on any element, which fixes regression
+        introduced in r268745 and aligns "onselectionchange" with "onselectstart".
+
+        Aligns WebKit with Gecko and the spec [1].
+
+        [1] https://w3c.github.io/selection-api/#extensions-to-globaleventhandlers-interface
+
+        Tests: fast/dom/event-handler-attributes.html
+               imported/w3c/web-platform-tests/selection/textcontrols/onselectionchange-content-attribute.html
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::createEventHandlerNameMap):
+
 2021-12-10  Joonghun Park  <jh718.p...@samsung.com>
 
         Don't do simplification for percentage comparison resolution against negative reference values.

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (286897 => 286898)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2021-12-11 02:45:31 UTC (rev 286897)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2021-12-11 03:02:38 UTC (rev 286898)
@@ -327,6 +327,7 @@
         &onseekedAttr.get(),
         &onseekingAttr.get(),
         &onselectAttr.get(),
+        &onselectionchangeAttr.get(),
         &onselectstartAttr.get(),
         &onslotchangeAttr.get(),
         &onstalledAttr.get(),
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to