Bug 1069055 - Merge focused element deletion test to another test. r=yxl, a=test-only
authorTim Chien <timdream@gmail.com>
Fri, 31 Oct 2014 20:20:03 -0400
changeset 233595 cb81118fe830dd7447b23406cba4bb5fb0605bc1
parent 233594 7228bed65ad0eda0501e26ac9a81105ec14a7380
child 233596 26df140c486d4b6cb8983460587adc37510cc08f
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyxl, test-only
bugs1069055
milestone35.0a2
Bug 1069055 - Merge focused element deletion test to another test. r=yxl, a=test-only
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,11 +16,10 @@ 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_two_inputs.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;