Backed out changeset afe0a444c182 (bug 1093153) for mochitest-2 failures. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 14 Mar 2016 17:45:36 +0100
changeset 288533 2c45f42f52c23249cae3c8c4b0c4859d6140fcb6
parent 288532 59d67fe6d470d246b3c15236563c42736b41a288
child 288534 53961d91a52be96a4f5b2d091206c3bfea3a680b
push id18160
push userarchaeopteryx@coole-files.de
push dateMon, 14 Mar 2016 16:46:01 +0000
treeherderfx-team@2c45f42f52c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1093153
milestone48.0a1
backs outafe0a444c1824bc921242c86de7af4d47405df8a
Backed out changeset afe0a444c182 (bug 1093153) for mochitest-2 failures. r=backout
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js
testing/mochitest/tests/SimpleTest/EventUtils.js
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -33,19 +33,16 @@ Cc["@mozilla.org/globalmessagemanager;1"
 XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
   "resource:///modules/E10SUtils.jsm");
 
 // For now, we'll allow tests to use CPOWs in this module for
 // some cases.
 Cu.permitCPOWsInScope(this);
 
 var gSendCharCount = 0;
-var gSynthesizeKeyCount = 0;
-var gSynthesizeCompositionCount = 0;
-var gSynthesizeCompositionChangeCount = 0;
 
 this.BrowserTestUtils = {
   /**
    * Loads a page in a new tab, executes a Task and closes the tab.
    *
    * @param options
    *        An object with the following properties:
    *        {
@@ -825,17 +822,17 @@ this.BrowserTestUtils = {
       });
 
       mut.observe(element, {attributeFilter: [attr]});
     });
   },
 
   /**
    * Version of EventUtils' `sendChar` function; it will synthesize a keypress
-   * event in a child process and returns a Promise that will resolve when the
+   * event in a child process and returns a Promise that will result when the
    * event was fired. Instead of a Window, a Browser object is required to be
    * passed to this function.
    *
    * @param {String} char
    *        A character for the keypress event that is sent to the browser.
    * @param {Browser} browser
    *        Browser element, must not be null.
    *
@@ -847,120 +844,27 @@ this.BrowserTestUtils = {
       let seq = ++gSendCharCount;
       let mm = browser.messageManager;
 
       mm.addMessageListener("Test:SendCharDone", function charMsg(message) {
         if (message.data.seq != seq)
           return;
 
         mm.removeMessageListener("Test:SendCharDone", charMsg);
-        resolve(message.data.result);
+        resolve(message.data.sendCharResult);
       });
 
       mm.sendAsyncMessage("Test:SendChar", {
         char: char,
         seq: seq
       });
     });
   },
 
   /**
-   * Version of EventUtils' `synthesizeKey` function; it will synthesize a key
-   * event in a child process and returns a Promise that will resolve when the
-   * event was fired. Instead of a Window, a Browser object is required to be
-   * passed to this function.
-   *
-   * @param {String} key
-   *        See the documentation available for EventUtils#synthesizeKey.
-   * @param {Object} event
-   *        See the documentation available for EventUtils#synthesizeKey.
-   * @param {Browser} browser
-   *        Browser element, must not be null.
-   *
-   * @returns {Promise}
-   */
-  synthesizeKey(key, event, browser) {
-    return new Promise(resolve => {
-      let seq = ++gSynthesizeKeyCount;
-      let mm = browser.messageManager;
-
-      mm.addMessageListener("Test:SynthesizeKeyDone", function keyMsg(message) {
-        if (message.data.seq != seq)
-          return;
-
-        mm.removeMessageListener("Test:SynthesizeKeyDone", keyMsg);
-        resolve();
-      });
-
-      mm.sendAsyncMessage("Test:SynthesizeKey", { key, event, seq });
-    });
-  },
-
-  /**
-   * Version of EventUtils' `synthesizeComposition` function; it will synthesize
-   * a composition event in a child process and returns a Promise that will
-   * resolve when the event was fired. Instead of a Window, a Browser object is
-   * required to be passed to this function.
-   *
-   * @param {Object} event
-   *        See the documentation available for EventUtils#synthesizeComposition.
-   * @param {Browser} browser
-   *        Browser element, must not be null.
-   *
-   * @returns {Promise}
-   * @resolves False if the composition event could not be synthesized.
-   */
-  synthesizeComposition(event, browser) {
-    return new Promise(resolve => {
-      let seq = ++gSynthesizeCompositionCount;
-      let mm = browser.messageManager;
-
-      mm.addMessageListener("Test:SynthesizeCompositionDone", function compMsg(message) {
-        if (message.data.seq != seq)
-          return;
-
-        mm.removeMessageListener("Test:SynthesizeCompositionDone", compMsg);
-        resolve(message.data.result);
-      });
-
-      mm.sendAsyncMessage("Test:SynthesizeComposition", { event, seq });
-    });
-  },
-
-  /**
-   * Version of EventUtils' `synthesizeCompositionChange` function; it will
-   * synthesize a compositionchange event in a child process and returns a
-   * Promise that will resolve when the event was fired. Instead of a Window, a
-   * Browser object is required to be passed to this function.
-   *
-   * @param {Object} event
-   *        See the documentation available for EventUtils#synthesizeCompositionChange.
-   * @param {Browser} browser
-   *        Browser element, must not be null.
-   *
-   * @returns {Promise}
-   */
-  synthesizeCompositionChange(event, browser) {
-    return new Promise(resolve => {
-      let seq = ++gSynthesizeCompositionChangeCount;
-      let mm = browser.messageManager;
-
-      mm.addMessageListener("Test:SynthesizeCompositionChangeDone", function compMsg(message) {
-        if (message.data.seq != seq)
-          return;
-
-        mm.removeMessageListener("Test:SynthesizeCompositionChangeDone", compMsg);
-        resolve();
-      });
-
-      mm.sendAsyncMessage("Test:SynthesizeCompositionChange", { event, seq });
-    });
-  },
-
-  /**
    * Will poll a condition function until it returns true.
    *
    * @param condition
    *        A condition function that must return true or false. If the
    *        condition ever throws, this is also treated as a false.
    * @param interval
    *        The time interval to poll the condition function. Defaults
    *        to 100ms.
--- a/testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js
+++ b/testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js
@@ -53,25 +53,13 @@ addMessageListener("Test:SynthesizeMouse
   } else {
     result = EventUtils.synthesizeMouseAtPoint(left, top, data.event, content);
   }
   sendAsyncMessage("Test:SynthesizeMouseDone", { defaultPrevented: result });
 });
 
 addMessageListener("Test:SendChar", message => {
   let result = EventUtils.sendChar(message.data.char, content);
-  sendAsyncMessage("Test:SendCharDone", { result, seq: message.data.seq });
-});
-
-addMessageListener("Test:SynthesizeKey", message => {
-  EventUtils.synthesizeKey(message.data.key, message.data.event || {}, content);
-  sendAsyncMessage("Test:SynthesizeKeyDone", { seq: message.data.seq });
+  sendAsyncMessage("Test:SendCharDone", {
+    sendCharResult: result,
+    seq: message.data.seq
+  });
 });
-
-addMessageListener("Test:SynthesizeComposition", message => {
-  let result = EventUtils.synthesizeComposition(message.data.event, content);
-  sendAsyncMessage("Test:SynthesizeCompositionDone", { result, seq: message.data.seq });
-});
-
-addMessageListener("Test:SynthesizeCompositionChange", message => {
-  EventUtils.synthesizeCompositionChange(message.data.event, content);
-  sendAsyncMessage("Test:SynthesizeCompositionChangeDone", { seq: message.data.seq });
-});
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -38,34 +38,16 @@ window.__defineGetter__('_EU_Cc', functi
   return c.value && !c.writable ? Components.classes : SpecialPowers.Cc;
 });
 
 window.__defineGetter__('_EU_Cu', function() {
   var c = Object.getOwnPropertyDescriptor(window, 'Components');
   return c.value && !c.writable ? Components.utils : SpecialPowers.Cu;
 });
 
-window.__defineGetter__("_EU_OS", function() {
-  delete this._EU_OS;
-  try {
-    this._EU_OS = Cu.import("resource://gre/modules/AppConstants.jsm", {}).platform;
-  } catch (ex) {
-    this._EU_OS = null;
-  }
-  return this._EU_OS;
-});
-
-function _EU_isMac(aWindow = window) {
-  return window._EU_OS ? window._EU_OS == "macosx" : aWindow.navigator.platform.indexOf("Mac") > -1;
-}
-
-function _EU_isWin(aWindow = window) {
-  return window._EU_OS ? window._EU_OS == "win" : aWindow.navigator.platform.indexOf("Win") > -1;
-}
-
 /**
  * Send a mouse event to the node aTarget (aTarget can be an id, or an
  * actual node) . The "event" passed in to aEvent is just a JavaScript
  * object with the properties set that the real mouse event object should
  * have. This includes the type of the mouse event.
  * E.g. to send an click event to the node with id 'node' you might do this:
  *
  * sendMouseEvent({type:'click'}, 'node');
@@ -250,17 +232,17 @@ function _parseModifiers(aEvent, aWindow
   }
   if (aEvent.altKey) {
     mval |= nsIDOMWindowUtils.MODIFIER_ALT;
   }
   if (aEvent.metaKey) {
     mval |= nsIDOMWindowUtils.MODIFIER_META;
   }
   if (aEvent.accelKey) {
-    mval |= _EU_isMac(aWindow) ?
+    mval |= (navigator.platform.indexOf("Mac") >= 0) ?
       nsIDOMWindowUtils.MODIFIER_META : nsIDOMWindowUtils.MODIFIER_CONTROL;
   }
   if (aEvent.altGrKey) {
     mval |= nsIDOMWindowUtils.MODIFIER_ALTGRAPH;
   }
   if (aEvent.capsLockKey) {
     mval |= nsIDOMWindowUtils.MODIFIER_CAPSLOCK;
   }
@@ -802,23 +784,26 @@ function _parseNativeModifiers(aModifier
   if (aModifiers.fnKey) {
     modifiers |= 0x00100000;
   }
   if (aModifiers.numericKeyPadKey) {
     modifiers |= 0x01000000;
   }
 
   if (aModifiers.accelKey) {
-    modifiers |= _EU_isMac(aWindow) ? 0x00004000 : 0x00000400;
+    modifiers |=
+      (navigator.platform.indexOf("Mac") == 0) ? 0x00004000 : 0x00000400;
   }
   if (aModifiers.accelRightKey) {
-    modifiers |= _EU_isMac(aWindow) ? 0x00008000 : 0x00000800;
+    modifiers |=
+      (navigator.platform.indexOf("Mac") == 0) ? 0x00008000 : 0x00000800;
   }
   if (aModifiers.altGrKey) {
-    modifiers |= _EU_isWin(aWindow) ? 0x00002800 : 0x00001000;
+    modifiers |=
+      (navigator.platform.indexOf("Win") == 0) ? 0x00002800 : 0x00001000;
   }
   return modifiers;
 }
 
 // Mac: Any unused number is okay for adding new keyboard layout.
 //      When you add new keyboard layout here, you need to modify
 //      TISInputSourceWrapper::InitByLayoutID().
 // Win: These constants can be found by inspecting registry keys under
@@ -883,19 +868,19 @@ function synthesizeNativeKey(aKeyboardLa
                              aChars, aUnmodifiedChars, aCallback, aWindow = window)
 {
   var utils = _getDOMWindowUtils(aWindow);
   if (!utils) {
     return false;
   }
   var navigator = _getNavigator(aWindow);
   var nativeKeyboardLayout = null;
-  if (_EU_isMac(aWindow)) {
+  if (navigator.platform.indexOf("Mac") == 0) {
     nativeKeyboardLayout = aKeyboardLayout.Mac;
-  } else if (_EU_isWin(aWindow)) {
+  } else if (navigator.platform.indexOf("Win") == 0) {
     nativeKeyboardLayout = aKeyboardLayout.Win;
   }
   if (nativeKeyboardLayout === null) {
     return false;
   }
 
   var observer = {
     observe: function(aSubject, aTopic, aData) {
@@ -1073,25 +1058,17 @@ function _getTIP(aWindow, aCallback)
     TIPMap.delete(aWindow);
   }
   return tip;
 }
 
 function _getKeyboardEvent(aWindow = window)
 {
   if (typeof KeyboardEvent != "undefined") {
-    try {
-      // See if the object can be instantiated; sometimes this yields
-      // 'TypeError: can't access dead object' or 'KeyboardEvent is not a constructor'.
-      new KeyboardEvent("", {});
-      return KeyboardEvent;
-    } catch (ex) {}
-  }
-  if (typeof content != "undefined" && ("KeyboardEvent" in content)) {
-    return content.KeyboardEvent;
+    return KeyboardEvent;
   }
   return aWindow.KeyboardEvent;
 }
 
 function _getNavigator(aWindow = window)
 {
   if (typeof navigator != "undefined") {
     return navigator;
@@ -1300,17 +1277,17 @@ function _emulateToActivateModifiers(aTI
       { key: "Alt",        attr: "altKey" },
       { key: "AltGraph",   attr: "altGraphKey" },
       { key: "Control",    attr: "ctrlKey" },
       { key: "Fn",         attr: "fnKey" },
       { key: "Meta",       attr: "metaKey" },
       { key: "OS",         attr: "osKey" },
       { key: "Shift",      attr: "shiftKey" },
       { key: "Symbol",     attr: "symbolKey" },
-      { key: _EU_isMac(aWindow) ? "Meta" : "Control",
+      { key: (navigator.platform.indexOf("Mac") >= 0) ? "Meta" : "Control",
                            attr: "accelKey" },
     ],
     lockable: [
       { key: "CapsLock",   attr: "capsLockKey" },
       { key: "FnLock",     attr: "fnLockKey" },
       { key: "NumLock",    attr: "numLockKey" },
       { key: "ScrollLock", attr: "scrollLockKey" },
       { key: "SymbolLock", attr: "symbolLockKey" },