Backed out changesets bb126ac7b33d and 7bbc04988e85 (bug 861495) for webconsole mochitest timeouts.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 07 May 2013 14:39:16 -0400
changeset 141972 b0f38ca2f70b210dc53bff3e8bc137bdef5c36d5
parent 141971 415c369420a944a3e2d447851258dca1198de8c8
child 141973 7372a5417a286d0b8f1e6295f401252ae21bd4ee
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs861495
milestone23.0a1
backs outbb126ac7b33d1ea7452c7eee16e5fdea913bb382
7bbc04988e85f33f4acd077c84159d5dfabd9090
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 bb126ac7b33d and 7bbc04988e85 (bug 861495) for webconsole mochitest timeouts.
dom/tests/browser/browser_ConsoleAPITests.js
toolkit/devtools/webconsole/WebConsoleUtils.jsm
--- a/dom/tests/browser/browser_ConsoleAPITests.js
+++ b/dom/tests/browser/browser_ConsoleAPITests.js
@@ -29,17 +29,17 @@ function test() {
       gTestDriver = observeConsoleTest();
       gTestDriver.next();
     });
 
   }, false);
 }
 
 function testConsoleData(aMessageObject) {
-  let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
+  let messageWindow = getWindowByWindowId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   is(aMessageObject.level, gLevel, "expected level received");
   ok(aMessageObject.arguments, "we have arguments");
 
   if (gLevel == "trace") {
     is(aMessageObject.arguments.length, 0, "arguments.length matches");
     is(aMessageObject.stacktrace.toSource(), gArgs.toSource(),
@@ -51,17 +51,17 @@ function testConsoleData(aMessageObject)
       is(aMessageObject.arguments[i], a, "correct arg " + i);
     });
   }
 
   gTestDriver.next();
 }
 
 function testLocationData(aMessageObject) {
-  let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
+  let messageWindow = getWindowByWindowId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   is(aMessageObject.level, gLevel, "expected level received");
   ok(aMessageObject.arguments, "we have arguments");
 
   is(aMessageObject.filename, gArgs[0].filename, "filename matches");
   is(aMessageObject.lineNumber, gArgs[0].lineNumber, "lineNumber matches");
   is(aMessageObject.functionName, gArgs[0].functionName, "functionName matches");
@@ -85,17 +85,17 @@ function startGroupTest() {
     }
   };
   let button = gWindow.document.getElementById("test-groups");
   ok(button, "found #test-groups button");
   EventUtils.synthesizeMouseAtCenter(button, {}, gWindow);
 }
 
 function testConsoleGroup(aMessageObject) {
-  let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
+  let messageWindow = getWindowByWindowId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   ok(aMessageObject.level == "group" ||
      aMessageObject.level == "groupCollapsed" ||
      aMessageObject.level == "groupEnd",
      "expected level received");
 
   is(aMessageObject.functionName, "testGroups", "functionName matches");
@@ -266,17 +266,17 @@ function startTimeTest() {
   ];
 
   let button = gWindow.document.getElementById("test-time");
   ok(button, "found #test-time button");
   EventUtils.synthesizeMouseAtCenter(button, {}, gWindow);
 }
 
 function testConsoleTime(aMessageObject) {
-  let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
+  let messageWindow = getWindowByWindowId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   is(aMessageObject.level, gLevel, "expected level received");
 
   is(aMessageObject.filename, gArgs[0].filename, "filename matches");
   is(aMessageObject.lineNumber, gArgs[0].lineNumber, "lineNumber matches");
   is(aMessageObject.functionName, gArgs[0].functionName, "functionName matches");
   is(aMessageObject.timer.name, gArgs[0].timer.name, "timer.name matches");
@@ -309,17 +309,17 @@ function startTimeEndTest() {
   ];
 
   let button = gWindow.document.getElementById("test-timeEnd");
   ok(button, "found #test-timeEnd button");
   EventUtils.synthesizeMouseAtCenter(button, {}, gWindow);
 }
 
 function testConsoleTimeEnd(aMessageObject) {
-  let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
+  let messageWindow = getWindowByWindowId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   is(aMessageObject.level, gLevel, "expected level received");
   ok(aMessageObject.arguments, "we have arguments");
 
   is(aMessageObject.filename, gArgs[0].filename, "filename matches");
   is(aMessageObject.lineNumber, gArgs[0].lineNumber, "lineNumber matches");
   is(aMessageObject.functionName, gArgs[0].functionName, "functionName matches");
@@ -349,17 +349,17 @@ function startEmptyTimerTest() {
   };
 
   let button = gWindow.document.getElementById("test-namelessTimer");
   ok(button, "found #test-namelessTimer button");
   EventUtils.synthesizeMouseAtCenter(button, {}, gWindow);
 }
 
 function testEmptyTimer(aMessageObject) {
-  let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
+  let messageWindow = getWindowByWindowId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   ok(aMessageObject.level == "time" || aMessageObject.level == "timeEnd",
      "expected level received");
   is(aMessageObject.arguments.length, 0, "we don't have arguments");
   ok(!aMessageObject.timer, "we don't have a timer");
 
   is(aMessageObject.functionName, "namelessTimer", "functionName matches");
@@ -393,8 +393,18 @@ var ConsoleObserver = {
 };
 
 function getWindowId(aWindow)
 {
   return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                 .getInterface(Ci.nsIDOMWindowUtils)
                 .outerWindowID;
 }
+
+function getWindowByWindowId(aId) {
+  let someWindow = Services.wm.getMostRecentWindow("navigator:browser");
+  if (someWindow) {
+    let windowUtils = someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
+                                .getInterface(Ci.nsIDOMWindowUtils);
+    return windowUtils.getOuterWindowWithId(aId);
+  }
+  return null;
+}
--- a/toolkit/devtools/webconsole/WebConsoleUtils.jsm
+++ b/toolkit/devtools/webconsole/WebConsoleUtils.jsm
@@ -153,16 +153,41 @@ this.WebConsoleUtils = {
    */
   getOuterWindowId: function WCU_getOuterWindowId(aWindow)
   {
     return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).
            getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
   },
 
   /**
+   * Gets the window that has the given outer ID.
+   *
+   * @param integer aOuterId
+   * @param nsIDOMWindow [aHintWindow]
+   *        Optional, the window object used to QueryInterface to
+   *        nsIDOMWindowUtils. If this is not given,
+   *        Services.wm.getMostRecentWindow() is used.
+   * @return nsIDOMWindow|null
+   *         The window object with the given outer ID.
+   */
+  getWindowByOuterId: function WCU_getWindowByOuterId(aOuterId, aHintWindow)
+  {
+    let someWindow = aHintWindow || Services.wm.getMostRecentWindow(null);
+    let content = null;
+
+    if (someWindow) {
+      let windowUtils = someWindow.QueryInterface(Ci.nsIInterfaceRequestor).
+                                   getInterface(Ci.nsIDOMWindowUtils);
+      content = windowUtils.getOuterWindowWithId(aOuterId);
+    }
+
+    return content;
+  },
+
+  /**
    * Abbreviates the given source URL so that it can be displayed flush-right
    * without being too distracting.
    *
    * @param string aSourceURL
    *        The source URL to shorten.
    * @return string
    *         The abbreviated form of the source URL.
    */
@@ -1301,17 +1326,18 @@ PageErrorListener.prototype =
 
     if (this.window) {
       if (!aScriptError.outerWindowID ||
           !this.isCategoryAllowed(aScriptError.category)) {
         return;
       }
 
       let errorWindow =
-        Services.wm.getOuterWindowById(aScriptError.outerWindowID);
+        WebConsoleUtils.getWindowByOuterId(aScriptError.outerWindowID,
+                                           this.window);
       if (!errorWindow || errorWindow.top != this.window) {
         return;
       }
     }
 
     this.listener.onPageError(aScriptError);
   },
 
@@ -1440,17 +1466,18 @@ ConsoleAPIListener.prototype =
   observe: function CAL_observe(aMessage, aTopic)
   {
     if (!this.owner) {
       return;
     }
 
     let apiMessage = aMessage.wrappedJSObject;
     if (this.window) {
-      let msgWindow = Services.wm.getOuterWindowById(apiMessage.ID);
+      let msgWindow = WebConsoleUtils.getWindowByOuterId(apiMessage.ID,
+                                                         this.window);
       if (!msgWindow || msgWindow.top != this.window) {
         // Not the same window!
         return;
       }
     }
 
     this.owner.onConsoleAPICall(apiMessage);
   },