Bug 1051556 - Add test for re-flushing changes; r=esawin
authorJim Chen <nchen@mozilla.com>
Sat, 12 Dec 2015 10:18:43 -0500
changeset 310392 41cfa429212185d8067d1f094b20d0fc126b3883
parent 310391 983e2c0c80a81ac5b39387f1024b368cc6358f77
child 310393 362320a47dbb0415da1e4f07311a46fdec78b5d9
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1051556
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
mobile/android/tests/browser/robocop/robocop_input.html
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testInputConnection.java
--- a/mobile/android/tests/browser/robocop/robocop_input.html
+++ b/mobile/android/tests/browser/robocop/robocop_input.html
@@ -18,16 +18,26 @@
       });
 
       let test = {
         focus_input: function(val) {
           input.value = val;
           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();
         },
 
         finish_test: function() {
           java.disconnect();
         },
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testInputConnection.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testInputConnection.java
@@ -174,16 +174,31 @@ public class testInputConnection extends
 
             // Bug 1209465, cannot enter ideographic space character by itself (U+3000).
             ic.commitText("\u3000", 1);
             assertTextAndSelectionAt("Can commit ideographic space", ic, "\u3000", 1);
 
             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();
         }
     }
 
     /**
      * ResettingInputConnectionTest performs tests on the resetting input in