Backed out changesets de5cefa8e52e and 5f66ff9f11f2 (bug 1057898) for Gaia Python integration test failures. a=backout
authorRyan VanderMeulen <ryanvm@gmail.com>
Fri, 29 Aug 2014 15:22:17 -0400
changeset 224014 9b3fbc3706311126d788897df0445908d52365e1
parent 224013 8fdcd7e6ecb252f7168d69909884f55d874fff4e
child 224119 2a354048f9641f1cb71b9c94a6e7fce53a311b24
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1057898
milestone34.0a1
backs outde5cefa8e52e34a979b5fef169b55f5fa8dd027b
5f66ff9f11f2c5e2c6a8b35c9b234c0e51659e07
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
Backed out changesets de5cefa8e52e and 5f66ff9f11f2 (bug 1057898) for Gaia Python integration test failures. a=backout
dom/inputmethod/forms.js
dom/inputmethod/mochitest/mochitest.ini
dom/inputmethod/mochitest/test_delete_focused_element.html
dom/inputmethod/mochitest/test_two_inputs.html
--- a/dom/inputmethod/forms.js
+++ b/dom/inputmethod/forms.js
@@ -13,20 +13,16 @@ let Cc = Components.classes;
 let Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 XPCOMUtils.defineLazyServiceGetter(Services, "fm",
                                    "@mozilla.org/focus-manager;1",
                                    "nsIFocusManager");
 
-XPCOMUtils.defineLazyServiceGetter(Services, "threadManager",
-                                   "@mozilla.org/thread-manager;1",
-                                   "nsIThreadManager");
-
 XPCOMUtils.defineLazyGetter(this, "domWindowUtils", function () {
   return content.QueryInterface(Ci.nsIInterfaceRequestor)
                 .getInterface(Ci.nsIDOMWindowUtils);
 });
 
 const RESIZE_SCROLL_DELAY = 20;
 // In content editable node, when there are hidden elements such as <br>, it
 // may need more than one (usually less than 3 times) move/extend operations
@@ -249,16 +245,19 @@ let FormAssistant = {
       return;
 
     if (this.focusedElement) {
       this.focusedElement.removeEventListener('compositionend', this);
       if (this._observer) {
         this._observer.disconnect();
         this._observer = null;
       }
+      if (!element) {
+        this.focusedElement.blur();
+      }
       if (this._selectionPrivate) {
         this._selectionPrivate.removeSelectionListener(this);
         this._selectionPrivate = null;
       }
     }
 
     this._documentEncoder = null;
     if (this._editor) {
@@ -294,19 +293,18 @@ let FormAssistant = {
       let MutationObserver = element.ownerDocument.defaultView.MutationObserver;
       this._observer = new MutationObserver(function(mutations) {
         var del = [].some.call(mutations, function(m) {
           return [].some.call(m.removedNodes, function(n) {
             return n.contains(element);
           });
         });
         if (del && element === self.focusedElement) {
-          self.hideKeyboard();
-          self.selectionStart = -1;
-          self.selectionEnd = -1;
+          // item was deleted, fake a blur so all state gets set correctly
+          self.handleEvent({ target: element, type: "blur" });
         }
       });
 
       this._observer.observe(element.ownerDocument.body, {
         childList: true,
         subtree: true
       });
     }
@@ -375,24 +373,19 @@ let FormAssistant = {
       case "pagehide":
       case "beforeunload":
         // We are only interested to the pagehide and beforeunload events from
         // the root document.
         if (target && target != content.document) {
           break;
         }
         // fall through
+      case "blur":
       case "submit":
         if (this.focusedElement) {
-          this.focusedElement.blur();
-        }
-        break;
-
-      case "blur":
-        if (this.focusedElement) {
           this.hideKeyboard();
           this.selectionStart = -1;
           this.selectionEnd = -1;
         }
         break;
 
       case "resize":
         if (!this.isKeyboardOpened)
@@ -436,23 +429,16 @@ let FormAssistant = {
           break;
         }
 
         CompositionManager.onCompositionEnd();
         break;
     }
   },
 
-  waitForNextTick: function(callback) {
-    var tm = Services.threadManager;
-    tm.mainThread.dispatch({
-      run: callback,
-    }, Components.interfaces.nsIThread.DISPATCH_NORMAL);
-  },
-
   receiveMessage: function fa_receiveMessage(msg) {
     let target = this.focusedElement;
     let json = msg.json;
 
     // To not break mozKeyboard contextId is optional
     if ('contextId' in json &&
         json.contextId !== this._focusCounter &&
         json.requestId) {
@@ -545,20 +531,17 @@ let FormAssistant = {
         if (valueChanged) {
           let event = target.ownerDocument.createEvent('HTMLEvents');
           event.initEvent('change', true, true);
           target.dispatchEvent(event);
         }
         break;
 
       case "Forms:Select:Blur": {
-        if (this.focusedElement) {
-          this.focusedElement.blur();
-        }
-
+        this.setFocusedElement(null);
         break;
       }
 
       case "Forms:SetSelectionRange":  {
         CompositionManager.endComposition('');
 
         let start = json.selectionStart;
         let end =  json.selectionEnd;
@@ -667,30 +650,19 @@ let FormAssistant = {
     this.setFocusedElement(target);
 
     let kbOpened = this.sendKeyboardState(target);
     if (this.isTextInputElement(target))
       this.isKeyboardOpened = kbOpened;
   },
 
   hideKeyboard: function fa_hideKeyboard() {
-    var element = this.focusedElement;
-
-    // Wait for the next tick before unset the focused element and etc.
-    // If the user move from one input from another,
-    // the remote process should get one Forms:Input message instead of two.
-    this.waitForNextTick(function() {
-      if (element !== this.focusedElement) {
-        return;
-      }
-
-      this.isKeyboardOpened = false;
-      this.setFocusedElement(null);
-      sendAsyncMessage("Forms:Input", { "type": "blur" });
-    }.bind(this));
+    sendAsyncMessage("Forms:Input", { "type": "blur" });
+    this.isKeyboardOpened = false;
+    this.setFocusedElement(null);
   },
 
   isFocusableElement: function fa_isFocusableElement(element) {
     if (element instanceof HTMLSelectElement ||
         element instanceof HTMLTextAreaElement)
       return true;
 
     if (element instanceof HTMLOptionElement &&
@@ -761,17 +733,17 @@ let FormAssistant = {
   _selectionTimeout: null,
 
   // Notify when the selection range changes
   updateSelection: function fa_updateSelection() {
     // A call to setSelectionRange on input field causes 2 selection changes
     // one to [0,0] and one to actual value. Both are sent in same tick.
     // Prevent firing two events in that scenario, always only use the last 1.
     //
-    // It is also a workaround for Bug 1053048, which prevents
+    // It is also a workaround for Bug 1053048, which prevents 
     // getSelectionInfo() accessing selectionStart or selectionEnd in the
     // callback function of nsISelectionListener::NotifySelectionChanged().
     if (this._selectionTimeout) {
       content.clearTimeout(this._selectionTimeout);
     }
     this._selectionTimeout = content.setTimeout(function() {
       if (!this.focusedElement) {
         return;
--- a/dom/inputmethod/mochitest/mochitest.ini
+++ b/dom/inputmethod/mochitest/mochitest.ini
@@ -14,9 +14,8 @@ support-files =
 [test_bug949059.html]
 [test_bug953044.html]
 [test_bug960946.html]
 [test_bug978918.html]
 [test_bug1026997.html]
 [test_bug1043828.html]
 [test_delete_focused_element.html]
 [test_sendkey_cancel.html]
-[test_two_inputs.html]
--- a/dom/inputmethod/mochitest/test_delete_focused_element.html
+++ b/dom/inputmethod/mochitest/test_delete_focused_element.html
@@ -29,20 +29,17 @@ function appFrameScript() {
   content.document.body.appendChild(textarea);
 
   textarea.onfocus = function() {
     textarea.parentNode.removeChild(textarea);
     sendAsyncMessage('test:InputMethod:finished', {});
   };
 
   content.setTimeout(function() {
-    content.setTimeout(function() {
-      textarea.focus();
-    }, 10);
-
+    textarea.focus();
     input.parentNode.removeChild(input);
   }, 0);
 }
 
 function runTest() {
   var timeoutId = null;
 
   // Create an app frame to recieve keyboard inputs.
deleted file mode 100644
--- a/dom/inputmethod/mochitest/test_two_inputs.html
+++ /dev/null
@@ -1,106 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1057898
--->
-<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=932145">Mozilla Bug 932145</a>
-<p id="display"></p>
-<pre id="test">
-<script class="testbody" type="application/javascript;version=1.7">
-
-// The input context.
-var gContext = null;
-
-inputmethod_setup(function() {
-  runTest();
-});
-
-let appFrameScript = function appFrameScript() {
-  let input1 = content.document.body.firstElementChild;
-  let input2 = content.document.body.children[1];
-
-  let i = 0;
-
-  input1.focus();
-
-  addMessageListener('test:next', function() {
-    i++;
-    switch (i) {
-      case 1:
-        input2.focus();
-
-        break;
-
-      case 2:
-        input2.blur();
-
-        break;
-    }
-  });
-};
-
-function runTest() {
-  let im = navigator.mozInputMethod;
-
-  let i = 0;
-  im.oninputcontextchange = function(evt) {
-    var inputcontext = navigator.mozInputMethod.inputcontext;
-
-    i++;
-    switch (i) {
-      case 1:
-        ok(!!inputcontext, 'Receving the first input context');
-        is(inputcontext.textAfterCursor, 'First');
-
-        mm.sendAsyncMessage('test:next');
-        break;
-
-      case 2:
-        ok(!!inputcontext, 'Receving the second input context');
-        is(inputcontext.textAfterCursor, 'Second');
-
-
-        mm.sendAsyncMessage('test:next');
-        break;
-
-      case 3:
-        is(inputcontext, null, 'Receving null inputcontext');
-
-        inputmethod_cleanup();
-        break;
-
-      default:
-        ok(false, 'Receving extra inputcontextchange calls');
-        inputmethod_cleanup();
-
-        break;
-    }
-  };
-
-  // Set current page as an input method.
-  SpecialPowers.wrap(im).setActive(true);
-
-  let iframe = document.createElement('iframe');
-  iframe.src = 'data:text/html,<html><body><input value="First"><input value="Second"></body></html>';
-  iframe.setAttribute('mozbrowser', true);
-  document.body.appendChild(iframe);
-
-  let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
-
-  iframe.addEventListener('mozbrowserloadend', function() {
-    mm.loadFrameScript('data:,(' + encodeURIComponent(appFrameScript.toString()) + ')();', false);
-  });
-}
-
-</script>
-</pre>
-</body>
-</html>
-