Bug 955965 - Mochitest for InputMethodManager#hide. r=fabrice
☠☠ backed out by 4cca5e45f4f9 ☠ ☠
authorYuan Xulei <xyuan@mozilla.com>
Fri, 25 Apr 2014 16:49:35 +0800
changeset 181070 d9eb3294e6d5a0e9c108b8b4541ab077cd329f39
parent 181069 bae0d4946901aa614a90a7118d4d17b51120781d
child 181071 1bde15156abafc5774a5f0d842ceaa0a875ea1b8
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersfabrice
bugs955965
milestone32.0a1
Bug 955965 - Mochitest for InputMethodManager#hide. r=fabrice
dom/inputmethod/mochitest/mochitest.ini
dom/inputmethod/mochitest/test_inputMethodManager.html
--- a/dom/inputmethod/mochitest/mochitest.ini
+++ b/dom/inputmethod/mochitest/mochitest.ini
@@ -10,8 +10,9 @@ support-files =
 
 [test_basic.html]
 [test_bug944397.html]
 [test_bug949059.html]
 [test_bug960946.html]
 [test_bug978918.html]
 [test_delete_focused_element.html]
 [test_sendkey_cancel.html]
+[test_inputMethodManager.html]
new file mode 100644
--- /dev/null
+++ b/dom/inputmethod/mochitest/test_inputMethodManager.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=955965
+-->
+<head>
+  <title>Test for InputMethodManager</title>
+  <script type="application/javascript;version=1.7" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript;version=1.7" src="inputmethod_common.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=955965">Mozilla Bug 955965</a>
+<p id="display"></p>
+<pre id="test">
+<script class="testbody" type="application/javascript;version=1.7">
+
+let gIm;
+
+inputmethod_setup(function() {
+  runTest();
+});
+
+function runTest() {
+  gIm = navigator.mozInputMethod;
+  gIm.oninputcontextchange = function() {
+    ok(true, 'inputcontextchange event was fired.');
+    gIm.oninputcontextchange = null;
+
+    if (!gIm.inputcontext) {
+      ok(false, 'Should have a non-null inputcontext.');
+      inputmethod_cleanup();
+      return;
+    }
+
+    test_hide();
+  };
+
+  // Set current page as an input method.
+  SpecialPowers.wrap(gIm).setActive(true);
+
+  let iframe = document.createElement('iframe');
+  iframe.src = 'file_test_app.html';
+  iframe.setAttribute('mozbrowser', true);
+  document.body.appendChild(iframe);
+}
+
+function test_hide() {
+  gIm.oninputcontextchange = function() {
+    is(gIm.inputcontext, null, 'Should have a null inputcontext.');
+    inputmethod_cleanup();
+  }
+  gIm.mgmt.hide();
+}
+
+</script>
+</pre>
+</body>
+</html>
+