Set value of m_textAsOfLastFormControlChangeEvent before triggering change event

Value updated inside change event, get overwritten by setTextAsOfLastFormControlChangeEvent.

New value if similar to previous value was not triggering change event.

R=tkent, keishi
BUG=378871
TEST=OnChange event should be fired, when value is changed inside change
handler and same text is re-entered.

Review URL: https://codereview.chromium.org/313013005

git-svn-id: svn://svn.chromium.org/blink/trunk@175565 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7a51b165
This test verifies that the change event is fired, when value is changed in change event handler.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS input.value is "foo bar baz"
PASS changeEventCounter is 1
PASS input.value is ""
PASS input.value is "foo bar baz"
PASS changeEventCounter is 2
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<input id="input" type="text" onchange="changeHandler()">
<script>
description('This test verifies that the change event is fired, when value is changed in change event handler.');
var input = document.getElementById('input');
var changeEventCounter = 0;
function changeHandler()
{
changeEventCounter++;
input.value = '';
}
input.focus();
document.execCommand('InsertText', false, 'foo bar baz');
shouldBeEqualToString('input.value', 'foo bar baz');
input.blur();
shouldBe('changeEventCounter', '1');
shouldBeEqualToString('input.value', '');
input.focus();
document.execCommand('InsertText', false, 'foo bar baz');
shouldBeEqualToString('input.value', 'foo bar baz');
input.blur();
shouldBe('changeEventCounter', '2');
</script>
</body>
</html>
...@@ -191,8 +191,8 @@ void HTMLTextFormControlElement::dispatchFormControlChangeEvent() ...@@ -191,8 +191,8 @@ void HTMLTextFormControlElement::dispatchFormControlChangeEvent()
{ {
String newValue = value(); String newValue = value();
if (shouldDispatchFormControlChangeEvent(m_textAsOfLastFormControlChangeEvent, newValue)) { if (shouldDispatchFormControlChangeEvent(m_textAsOfLastFormControlChangeEvent, newValue)) {
dispatchChangeEvent();
setTextAsOfLastFormControlChangeEvent(newValue); setTextAsOfLastFormControlChangeEvent(newValue);
dispatchChangeEvent();
} }
setChangedSinceLastFormControlChangeEvent(false); setChangedSinceLastFormControlChangeEvent(false);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment