Skip to content

Commit 83d05ee

Browse files
josepharharwebkit-commit-queue
authored andcommitted
Text gets clobbered when assigning to input.defaultValue
https://bugs.webkit.org/show_bug.cgi?id=217156 Patch by Joey Arhar <jarhar@chromium.org> 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): Canonical link: https://commits.webkit.org/231323@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 09e9770 commit 83d05ee

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PASS numberinput.value == "12" is true
2+
PASS numberinput.value == "" is true
3+
PASS numberinput.validity.valid is false
4+
PASS numberinput.validity.valid is false
5+
PASS successfullyParsed is true
6+
7+
TEST COMPLETE
8+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<script src="../../resources/js-test-pre.js"></script>
3+
<input type=number id=numberinput>
4+
<script>
5+
numberinput.focus();
6+
eventSender.keyDown('1');
7+
eventSender.keyDown('2');
8+
shouldBeTrue('numberinput.value == "12"');
9+
eventSender.keyDown('e');
10+
shouldBeTrue('numberinput.value == ""');
11+
12+
shouldBeFalse('numberinput.validity.valid');
13+
numberinput.defaultValue = '12345';
14+
shouldBeFalse('numberinput.validity.valid');
15+
</script>
16+
<script src="../../resources/js-test-post.js"></script>

Source/WebCore/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2020-11-06 Joey Arhar <jarhar@chromium.org>
2+
3+
Text gets clobbered when assigning to input.defaultValue
4+
https://bugs.webkit.org/show_bug.cgi?id=217156
5+
6+
Reviewed by Darin Adler.
7+
8+
This fixes a bug where script assigning to the defaultValue property
9+
of a number or email input causes the text the user entered into the
10+
input to be clobbered when it doesn't perfectly match the sanitized
11+
string returned by the .value property.
12+
13+
Test: LayoutTests/fast/forms/defaultValue-clobbering.html
14+
15+
* html/HTMLInputElement.cpp:
16+
(WebCore::HTMLInputElement::parseAttribute):
17+
118
2020-11-06 Antoine Quint <graouts@webkit.org>
219

320
Accelerated animations of individual transform properties should apply rotate before scale

Source/WebCore/html/HTMLInputElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ void HTMLInputElement::parseAttribute(const QualifiedName& name, const AtomStrin
764764
if (!hasDirtyValue()) {
765765
updatePlaceholderVisibility();
766766
invalidateStyleForSubtree();
767+
setFormControlValueMatchesRenderer(false);
767768
}
768-
setFormControlValueMatchesRenderer(false);
769769
updateValidity();
770770
m_valueAttributeWasUpdatedAfterParsing = !m_parsingInProgress;
771771
} else if (name == checkedAttr) {

0 commit comments

Comments
 (0)