Title: [237413] trunk
Revision
237413
Author
[email protected]
Date
2018-10-25 07:15:21 -0700 (Thu, 25 Oct 2018)

Log Message

REGRESSION (236779) scandinaviandesigns.com product pages auto redirect to product image
https://bugs.webkit.org/show_bug.cgi?id=190891
<rdar://problem/45296796>

Reviewed by Antti Koivisto.

Source/WebCore:

When a radio element gets clicked, we should only fire the 'input' and 'change' if the checked state
of the radio element has changed.

Test: fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html

* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick):

LayoutTests:

Add layout test coverage.

* fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes-expected.txt: Added.
* fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237412 => 237413)


--- trunk/LayoutTests/ChangeLog	2018-10-25 14:03:30 UTC (rev 237412)
+++ trunk/LayoutTests/ChangeLog	2018-10-25 14:15:21 UTC (rev 237413)
@@ -1,3 +1,16 @@
+2018-10-25  Chris Dumez  <[email protected]>
+
+        REGRESSION (236779) scandinaviandesigns.com product pages auto redirect to product image
+        https://bugs.webkit.org/show_bug.cgi?id=190891
+        <rdar://problem/45296796>
+
+        Reviewed by Antti Koivisto.
+
+        Add layout test coverage.
+
+        * fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes-expected.txt: Added.
+        * fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html: Added.
+
 2018-10-25  Frederic Wang  <[email protected]>
 
         Unreviewed test gardening.

Added: trunk/LayoutTests/fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes-expected.txt (0 => 237413)


--- trunk/LayoutTests/fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes-expected.txt	2018-10-25 14:15:21 UTC (rev 237413)
@@ -0,0 +1,13 @@
+Tests that clicking a radio element only fires a 'change' event if its checked state actually changes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS a_events.toString() is "click"
+PASS b_events.toString() is ""
+PASS a_events.toString() is ""
+PASS b_events.toString() is "click,input,change"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+a b

Added: trunk/LayoutTests/fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html (0 => 237413)


--- trunk/LayoutTests/fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html	2018-10-25 14:15:21 UTC (rev 237413)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that clicking a radio element only fires a 'change' event if its checked state actually changes.");
+jsTestIsAsync = true
+
+let a_events = [];
+let b_events = [];
+
+_onload_ = () => {
+    a = document.getElementById("a");
+    b = document.getElementById("b");
+
+    a._onchange_ = () => { a_events.push('change'); }
+    a._oninput_ = () => { a_events.push('input'); }
+    a._onclick_ = () => { a_events.push('click') }
+    b._onchange_ = () => { b_events.push('change'); }
+    b._oninput_ = () => { b_events.push('input'); }
+    b._onclick_ = () => { b_events.push('click') }
+    a.click();
+
+    shouldBeEqualToString("a_events.toString()", "click");
+    shouldBeEqualToString("b_events.toString()", "");
+
+    a_events = [];
+    b_events = [];
+    b.click();
+    shouldBeEqualToString("a_events.toString()", "");
+    shouldBeEqualToString("b_events.toString()", "click,input,change");
+
+    finishJSTest();
+}
+</script>
+<input type="radio" name="foo" id="a" value="a" checked>a</input>
+<input type="radio" name="foo" id="b" value="b">b</input>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (237412 => 237413)


--- trunk/Source/WebCore/ChangeLog	2018-10-25 14:03:30 UTC (rev 237412)
+++ trunk/Source/WebCore/ChangeLog	2018-10-25 14:15:21 UTC (rev 237413)
@@ -1,3 +1,19 @@
+2018-10-25  Chris Dumez  <[email protected]>
+
+        REGRESSION (236779) scandinaviandesigns.com product pages auto redirect to product image
+        https://bugs.webkit.org/show_bug.cgi?id=190891
+        <rdar://problem/45296796>
+
+        Reviewed by Antti Koivisto.
+
+        When a radio element gets clicked, we should only fire the 'input' and 'change' if the checked state
+        of the radio element has changed.
+
+        Test: fast/dom/HTMLInputElement/radio-element-fires-change-event-only-when-checked-state-changes.html
+
+        * html/RadioInputType.cpp:
+        (WebCore::RadioInputType::didDispatchClick):
+
 2018-10-25  Joseph Pecoraro  <[email protected]>
 
         InspectorCanvas is not getting cleared properly for OffscreenCanvas

Modified: trunk/Source/WebCore/html/RadioInputType.cpp (237412 => 237413)


--- trunk/Source/WebCore/html/RadioInputType.cpp	2018-10-25 14:03:30 UTC (rev 237412)
+++ trunk/Source/WebCore/html/RadioInputType.cpp	2018-10-25 14:15:21 UTC (rev 237413)
@@ -169,7 +169,7 @@
         ASSERT(element());
         if (button && button->isRadioButton() && button->form() == element()->form() && button->name() == element()->name())
             button->setChecked(true);
-    } else
+    } else if (state.checked != element()->checked())
         fireInputAndChangeEvents();
 
     // The work we did in willDispatchClick was default handling.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to