Bug 1051556 - Add test for re-flushing changes; r=esawin
☠☠ backed out by 8d22eea111d9 ☠ ☠
authorJim Chen <nchen@mozilla.com>
Wed, 09 Dec 2015 17:46:45 -0500
changeset 297697 4a83a8594ddc07b26e2afdadf90d3da07cb82c76
parent 297696 fe3d880efce840e6aed79ac66e83c8de4cd3daa6
child 297698 c3f4c2d01bad5a114f0e7d47308948af6a465e5b
push id8824
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:18:56 +0000
treeherdermozilla-aurora@e2031358e2a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1051556
milestone45.0a1
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