Bug 1186799 part.2 Add test to check if IME selections are removed by committing composition caused by clicking outside of the focused contenteditable editor r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 08 Aug 2015 09:23:04 +0900
changeset 256904 e0a8c1d52ab9e0fa0bf133350e096b9400d8e0fd
parent 256903 8ad9b87bac4da23ff549ecb2d2b602341f769f40
child 256905 84bca279a24a78b8fb94f06e299164e7df01071a
push id29194
push userphilringnalda@gmail.com
push dateSat, 08 Aug 2015 22:08:06 +0000
treeherdermozilla-central@d263ff7885e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1186799
milestone42.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 1186799 part.2 Add test to check if IME selections are removed by committing composition caused by clicking outside of the focused contenteditable editor r=smaug
editor/libeditor/tests/mochitest.ini
editor/libeditor/tests/test_bug1186799.html
--- a/editor/libeditor/tests/mochitest.ini
+++ b/editor/libeditor/tests/mochitest.ini
@@ -159,8 +159,9 @@ skip-if = toolkit == 'android' # bug 105
 [test_root_element_replacement.html]
 [test_select_all_without_body.html]
 skip-if = e10s
 [test_spellcheck_pref.html]
 skip-if = toolkit == 'android'
 [test_bug1068979.html]
 [test_bug1109465.html]
 [test_bug1162952.html]
+[test_bug1186799.html]
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1186799.html
@@ -0,0 +1,81 @@
+<!DOCTYPE>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1186799
+-->
+<head>
+  <title>Test for Bug 1186799</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<div id="content">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1186799">Mozilla Bug 1186799</a>
+<p id="display"></p>
+<div id="content">
+  <span id="span">span</span>
+  <div id="editor" contenteditable></div>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 1186799 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  var span = document.getElementById("span");
+  var editor = document.getElementById("editor");
+  editor.focus();
+
+  synthesizeCompositionChange(
+    { "composition":
+      { "string": "\u3042",
+        "clauses":
+        [
+          { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
+        ]
+      },
+      "caret": { "start": 1, "length": 0 }
+    });
+
+  ok(isThereIMESelection(), "There should be IME selection");
+
+  var compositionEnd = false;
+  editor.addEventListener("compositionend", function () { compositionEnd = true; }, true);
+
+  synthesizeMouseAtCenter(span, {});
+
+  ok(compositionEnd, "composition end should be fired at clicking outside of the editor");
+  ok(!isThereIMESelection(), "There should be no IME selection");
+
+  SimpleTest.finish();
+});
+
+function isThereIMESelection()
+{
+  var selCon = SpecialPowers.wrap(window).
+        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+        getInterface(SpecialPowers.Ci.nsIWebNavigation).
+        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
+        getInterface(SpecialPowers.Ci.nsIEditingSession).
+        getEditorForWindow(window).
+        selectionController;
+  const kIMESelections = [
+    SpecialPowers.Ci.nsISelectionController.SELECTION_IME_RAWINPUT,
+    SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDRAWTEXT,
+    SpecialPowers.Ci.nsISelectionController.SELECTION_IME_CONVERTEDTEXT,
+    SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDCONVERTEDTEXT
+  ];
+  for (var i = 0; i < kIMESelections.length; i++) {
+    var sel = selCon.getSelection(kIMESelections[i]);
+    if (sel && sel.rangeCount) {
+      return true;
+    }
+  }
+  return false;
+}
+
+</script>
+</pre>
+</body>
+</html>