Bug 1051556 - Add test for re-flushing changes; r=esawin

This patch adds a test for triggering re-flushing IME changes to
testInputConnection, by ending a composition followed by setting the
value of the input field.
This commit is contained in:
Jim Chen 2015-12-09 17:46:45 -05:00
parent bacf3d521f
commit 51fa9a0774
2 changed files with 25 additions and 0 deletions

View File

@ -23,6 +23,16 @@
input.focus();
},
test_reflush_changes: function() {
let inputEditable = SpecialPowers.wrap(input).QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement);
let inputIme = inputEditable.editor.QueryInterface(SpecialPowers.Ci.nsIEditorIMESupport);
do_check_true(inputIme.composing);
// Ending the composition then setting the input value triggers the bug.
inputIme.forceCompositionEnd();
input.value = "good";
},
focus_resetting_input: function(val) {
resetting_input.value = val;
resetting_input.focus();

View File

@ -179,6 +179,21 @@ public class testInputConnection extends UITest {
ic.deleteSurroundingText(1, 0);
assertTextAndSelectionAt("Can clear text", ic, "", 0);
// Bug 1051556, exception due to committing text changes during flushing.
ic.setComposingText("bad", 1);
assertTextAndSelectionAt("Can set the composing text", ic, "bad", 3);
js.asyncCall("test_reflush_changes");
// Wait for text change notifications to come in.
processGeckoEvents(ic);
assertTextAndSelectionAt("Can re-flush text changes", ic, "good", 4);
ic.setComposingText("done", 1);
assertTextAndSelectionAt("Can update composition after re-flushing", ic, "done", 4);
ic.finishComposingText();
assertTextAndSelectionAt("Can finish composing text", ic, "done", 4);
ic.deleteSurroundingText(4, 0);
assertTextAndSelectionAt("Can clear text", ic, "", 0);
// Make sure we don't leave behind stale events for the following test.
processGeckoEvents(ic);
processInputConnectionEvents();