Bug 1069055 - Merge focused element deletion test to another test. r=yxl
authorTim Chien <timdream@gmail.com>
Fri, 31 Oct 2014 02:11:00 +0100
changeset 213382 2aff0325a61ace5da61b492f738659e4c890bdbd
parent 213381 0eeb6a55facb93c9a9437d431e4b1cd45ca95624
child 213383 a2e06eeccb2003db7127377adae625f53fdfbbd5
push id27748
push userryanvm@gmail.com
push dateFri, 31 Oct 2014 20:14:33 +0000
treeherdermozilla-central@12ac66e2c016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyxl
bugs1069055
milestone36.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 1069055 - Merge focused element deletion test to another test. r=yxl
dom/inputmethod/mochitest/mochitest.ini
dom/inputmethod/mochitest/test_delete_focused_element.html
dom/inputmethod/mochitest/test_two_inputs.html
--- a/dom/inputmethod/mochitest/mochitest.ini
+++ b/dom/inputmethod/mochitest/mochitest.ini
@@ -16,13 +16,12 @@ support-files =
 [test_bug949059.html]
 [test_bug953044.html]
 [test_bug960946.html]
 [test_bug978918.html]
 [test_bug1026997.html]
 [test_bug1043828.html]
 [test_bug1059163.html]
 [test_bug1066515.html]
-[test_delete_focused_element.html]
 [test_sendkey_cancel.html]
 [test_sync_edit.html]
 [test_two_inputs.html]
 [test_two_selects.html]
deleted file mode 100644
--- a/dom/inputmethod/mochitest/test_delete_focused_element.html
+++ /dev/null
@@ -1,112 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=952741
--->
-<head>
-  <title>Test focused element deletion for InputMethod API.</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=952741">Mozilla Bug 952741</a>
-<input type="text" />
-<p id="display"></p>
-<pre id="test">
-<script class="testbody" type="application/javascript;version=1.7">
-
-inputmethod_setup(function() {
-  runTest();
-});
-
-// The frame script running in file_test_app.html.
-function appFrameScript() {
-  let input = content.document.getElementById('test-input');
-  let textarea = content.document.createElement('textarea');
-  textarea.lang = 'en';
-
-  content.document.body.appendChild(textarea);
-
-  textarea.onfocus = function() {
-    content.setTimeout(function() {
-      textarea.parentNode.removeChild(textarea);
-      sendAsyncMessage('test:InputMethod:finished', {});
-    }, 10);
-  };
-
-  content.setTimeout(function() {
-    content.setTimeout(function() {
-      textarea.focus();
-    }, 10);
-
-    input.parentNode.removeChild(input);
-  }, 0);
-}
-
-function runTest() {
-  var timeoutId = null;
-
-  // Create an app frame to recieve keyboard inputs.
-  let app = document.createElement('iframe');
-  app.src = 'file_test_app.html';
-  app.setAttribute('mozbrowser', true);
-  document.body.appendChild(app);
-  app.addEventListener('mozbrowserloadend', function() {
-    let mm = SpecialPowers.getBrowserFrameMessageManager(app);
-    mm.loadFrameScript('data:,(' + appFrameScript.toString() + ')();', false);
-    mm.addMessageListener("test:InputMethod:finished", function() {
-      timeoutId = setTimeout(function() {
-        ok(false, 'No inputcontextchange event when textarea is deleted.');
-        inputmethod_cleanup();
-      }, 20000);
-    });
-  });
-
-  let im = navigator.mozInputMethod;
-  let count = 0;
-  im.oninputcontextchange = function() {
-    switch (count++) {
-      case 0:
-        if (!im.inputcontext) {
-          break;
-        }
-        is(im.inputcontext.lang, 'zh', 'input was focused.');
-        return;
-      case 1:
-        if (im.inputcontext) {
-          break;
-        }
-        ok(true, 'input was blurred.');
-        return;
-      case 2:
-        if (!im.inputcontext) {
-          break;
-        }
-        is(im.inputcontext.lang, 'en', 'textarea was focused.');
-        return;
-      case 3:
-        if (im.inputcontext) {
-          break;
-        }
-        ok(true, 'textarea was removed.');
-        clearTimeout(timeoutId);
-        inputmethod_cleanup();
-        return;
-      default:
-        return;
-    }
-    count = 100;
-    ok(false, 'Should not arrive here.');
-    inputmethod_cleanup();
-  };
-
-  // Set current page as an input method.
-  SpecialPowers.wrap(im).setActive(true);
-}
-
-</script>
-</pre>
-</body>
-</html>
-
--- a/dom/inputmethod/mochitest/test_two_inputs.html
+++ b/dom/inputmethod/mochitest/test_two_inputs.html
@@ -1,21 +1,23 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=1057898
+https://bugzilla.mozilla.org/show_bug.cgi?id=952741
 -->
 <head>
   <title>Test switching between two inputs</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=1057898">Mozilla Bug 1057898</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=952741">Mozilla Bug 952741</a>
 <p id="display"></p>
 <pre id="test">
 <script class="testbody" type="application/javascript;version=1.7">
 
 inputmethod_setup(function() {
   runTest();
 });
 
@@ -50,17 +52,27 @@ let appFrameScript = function appFrameSc
         input2.focus();
         input2.blur();
 
         input1.focus();
 
         break;
 
       case 6:
-        input1.blur();
+        content.document.body.removeChild(input1);
+
+        break;
+
+      case 7:
+        input2.focus();
+
+        break;
+
+      case 8:
+        content.document.body.removeChild(input2);
 
         break;
     }
   });
 };
 
 function runTest() {
   let im = navigator.mozInputMethod;
@@ -109,20 +121,35 @@ function runTest() {
       // focus on the first input receives the first input context.
       case 5:
         ok(!!inputcontext, 'Receving the first input context');
         is(inputcontext.textAfterCursor, 'First');
 
         mm.sendAsyncMessage('test:next');
         break;
 
-      // blur on the first input results null input context
+      // remove on the first focused input results null input context
       case 6:
         is(inputcontext, null, 'Receving null inputcontext');
 
+        mm.sendAsyncMessage('test:next');
+        break;
+
+      // input context for the second input.
+      case 7:
+        ok(!!inputcontext, 'Receving the second input context');
+        is(inputcontext.textAfterCursor, 'Second');
+
+        mm.sendAsyncMessage('test:next');
+        break;
+
+      // remove on the second focused input results null input context
+      case 8:
+        is(inputcontext, null, 'Receving null inputcontext');
+
         inputmethod_cleanup();
         break;
 
       default:
         ok(false, 'Receving extra inputcontextchange calls');
         inputmethod_cleanup();
 
         break;