mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 787102 - (2/2) - Dispatch the change event for textarea elements even if .value is set while focused. r=bz
This commit is contained in:
parent
22a7f92553
commit
45c66f71d7
@ -545,8 +545,22 @@ nsHTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::SetValue(const nsAString& aValue)
|
||||
{
|
||||
// If the value has been set by a script, we basically want to keep the
|
||||
// current change event state. If the element is ready to fire a change
|
||||
// event, we should keep it that way. Otherwise, we should make sure the
|
||||
// element will not fire any event because of the script interaction.
|
||||
//
|
||||
// NOTE: this is currently quite expensive work (too much string
|
||||
// manipulation). We should probably optimize that.
|
||||
nsAutoString currentValue;
|
||||
GetValueInternal(currentValue, true);
|
||||
|
||||
SetValueInternal(aValue, false);
|
||||
GetValueInternal(mFocusedValue, true);
|
||||
|
||||
if (mFocusedValue.Equals(currentValue)) {
|
||||
GetValueInternal(mFocusedValue, true);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599
|
||||
synthesizeKey("f", {});
|
||||
input.value = 'bar';
|
||||
input.blur();
|
||||
is(textInputChange[0], 3, "text input element should not have dispatched change event (3).");
|
||||
is(textInputChange[0], 3, "text input element should have dispatched change event (3).");
|
||||
|
||||
//focus and blur textarea
|
||||
var textarea = document.getElementById("textarea");
|
||||
@ -126,6 +126,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599
|
||||
textarea.blur();
|
||||
is(textareaChange, 1, "Textarea element should have dispatched change event.");
|
||||
|
||||
// value being set while focused
|
||||
textarea.focus();
|
||||
textarea.value = 'foo';
|
||||
textarea.blur();
|
||||
is(textareaChange, 1, "textarea should not have dispatched change event (1).");
|
||||
|
||||
// value being set while focused after being modified manually
|
||||
textarea.focus();
|
||||
synthesizeKey("f", {});
|
||||
textarea.value = 'bar';
|
||||
textarea.blur();
|
||||
is(textareaChange, 2, "textearea should have dispatched change event (2).");
|
||||
|
||||
//Non-text input tests:
|
||||
for (var i = 0; i < NonTextInputTypes.length; ++i) {
|
||||
//button, submit, image and reset input type tests.
|
||||
|
Loading…
Reference in New Issue
Block a user