Bug 861495 - Transplant getOuterWindowWithId from nsIDOMWindowUtils to a window-related service: ConsoleAPITests.js; r=msucan
authorColby Russell <Sevenspade@gmail.com>
Wed, 08 May 2013 19:54:43 +0300
changeset 142214 1c05e7a9e51ccd5ad1748a538c45673e478a425c
parent 142213 55b00015a6605e3274057bc9ce4f8c6c5c33cdb8
child 142215 0ea128318cc839d105662a3bb327bfe4a79ff08d
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)
reviewersmsucan
bugs861495
milestone23.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 861495 - Transplant getOuterWindowWithId from nsIDOMWindowUtils to a window-related service: ConsoleAPITests.js; r=msucan
dom/tests/browser/browser_ConsoleAPITests.js
--- 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 = getWindowByWindowId(aMessageObject.ID);
+  let messageWindow = Services.wm.getOuterWindowWithId(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 = getWindowByWindowId(aMessageObject.ID);
+  let messageWindow = Services.wm.getOuterWindowWithId(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 = getWindowByWindowId(aMessageObject.ID);
+  let messageWindow = Services.wm.getOuterWindowWithId(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 = getWindowByWindowId(aMessageObject.ID);
+  let messageWindow = Services.wm.getOuterWindowWithId(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 = getWindowByWindowId(aMessageObject.ID);
+  let messageWindow = Services.wm.getOuterWindowWithId(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 = getWindowByWindowId(aMessageObject.ID);
+  let messageWindow = Services.wm.getOuterWindowWithId(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,18 +393,8 @@ 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;
-}