Title: [269528] trunk
Revision
269528
Author
[email protected]
Date
2020-11-06 12:17:03 -0800 (Fri, 06 Nov 2020)

Log Message

Text gets clobbered when assigning to input.defaultValue
https://bugs.webkit.org/show_bug.cgi?id=217156

Patch by Joey Arhar <[email protected]> on 2020-11-06
Reviewed by Darin Adler.

This fixes a bug where script assigning to the defaultValue property
of a number or email input causes the text the user entered into the
input to be clobbered when it doesn't perfectly match the sanitized
string returned by the .value property.

Test: LayoutTests/fast/forms/defaultValue-clobbering.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::parseAttribute):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/forms/defaultValue-clobbering-expected.txt (0 => 269528)


--- trunk/LayoutTests/fast/forms/defaultValue-clobbering-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/defaultValue-clobbering-expected.txt	2020-11-06 20:17:03 UTC (rev 269528)
@@ -0,0 +1,8 @@
+PASS numberinput.value == "12" is true
+PASS numberinput.value == "" is true
+PASS numberinput.validity.valid is false
+PASS numberinput.validity.valid is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/defaultValue-clobbering.html (0 => 269528)


--- trunk/LayoutTests/fast/forms/defaultValue-clobbering.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/defaultValue-clobbering.html	2020-11-06 20:17:03 UTC (rev 269528)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<script src=""
+<input type=number id=numberinput>
+<script>
+numberinput.focus();
+eventSender.keyDown('1');
+eventSender.keyDown('2');
+shouldBeTrue('numberinput.value == "12"');
+eventSender.keyDown('e');
+shouldBeTrue('numberinput.value == ""');
+
+shouldBeFalse('numberinput.validity.valid');
+numberinput.defaultValue = '12345';
+shouldBeFalse('numberinput.validity.valid');
+</script>
+<script src=""

Modified: trunk/Source/WebCore/ChangeLog (269527 => 269528)


--- trunk/Source/WebCore/ChangeLog	2020-11-06 19:37:33 UTC (rev 269527)
+++ trunk/Source/WebCore/ChangeLog	2020-11-06 20:17:03 UTC (rev 269528)
@@ -1,3 +1,20 @@
+2020-11-06  Joey Arhar  <[email protected]>
+
+        Text gets clobbered when assigning to input.defaultValue
+        https://bugs.webkit.org/show_bug.cgi?id=217156
+
+        Reviewed by Darin Adler.
+
+        This fixes a bug where script assigning to the defaultValue property
+        of a number or email input causes the text the user entered into the
+        input to be clobbered when it doesn't perfectly match the sanitized
+        string returned by the .value property.
+
+        Test: LayoutTests/fast/forms/defaultValue-clobbering.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::parseAttribute):
+
 2020-11-06  Antoine Quint  <[email protected]>
 
         Accelerated animations of individual transform properties should apply rotate before scale

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (269527 => 269528)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2020-11-06 19:37:33 UTC (rev 269527)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2020-11-06 20:17:03 UTC (rev 269528)
@@ -764,8 +764,8 @@
         if (!hasDirtyValue()) {
             updatePlaceholderVisibility();
             invalidateStyleForSubtree();
+            setFormControlValueMatchesRenderer(false);
         }
-        setFormControlValueMatchesRenderer(false);
         updateValidity();
         m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress;
     } else if (name == checkedAttr) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to