Bug 1476145 part 5. Stop using getInterface(nsIDOMWindowUtils) in DOM code. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 24 Jul 2018 19:47:41 -0400
changeset 485981 0fb80adfe470f1bc6d30f5d0b577f64f3ecd4874
parent 485980 640fd7808af52f03ecfac63c6eaf7af0634b61fb
child 485982 6bd61a056a6389505fa0d91e7a9350a2667fdc20
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1476145
milestone63.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 1476145 part 5. Stop using getInterface(nsIDOMWindowUtils) in DOM code. r=mccr8
dom/base/DOMRequestHelper.jsm
dom/base/contentAreaDropListener.js
dom/base/test/browser_messagemanager_unload.js
dom/base/test/browser_promiseDocumentFlushed.js
dom/base/test/browser_use_counters.js
dom/base/test/chrome/cpows_child.js
dom/base/test/chrome/test_chromeOuterWindowID.xul
dom/base/test/file_pluginAudio.html
dom/base/test/file_pluginAudioNonAutoStart.html
dom/base/test/test_audioWindowUtils.html
dom/base/test/test_blocking_image.html
dom/base/test/test_getTranslationNodes.html
dom/base/test/test_getTranslationNodes_limit.html
dom/base/test/test_sendQueryContentAndSelectionSetEvent.html
dom/browser-element/BrowserElementChildPreload.js
dom/browser-element/BrowserElementParent.js
dom/browser-element/BrowserElementPromptService.jsm
dom/canvas/test/webgl-conf/checkout/js/js-test-pre.js
dom/events/test/test_bug591249.xul
dom/events/test/test_bug617528.xul
dom/html/test/browser_content_contextmenu_userinput.js
dom/media/IdpSandbox.jsm
dom/media/PeerConnection.js
dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js
dom/plugins/test/mochitest/test_bug751809.html
dom/plugins/test/mochitest/test_convertpoint.xul
dom/push/Push.js
dom/tests/browser/browser_ConsoleStorageAPITests.js
dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
dom/tests/browser/browser_frame_elements.js
dom/tests/mochitest/chrome/489127.html
dom/tests/mochitest/chrome/file_bug1224790-2_nonmodal.xul
dom/tests/mochitest/chrome/file_bug799299.xul
dom/tests/mochitest/chrome/file_bug800817.xul
dom/tests/mochitest/chrome/file_bug830858.xul
dom/tests/mochitest/chrome/queryCaretRectUnix.html
dom/tests/mochitest/chrome/queryCaretRectWin.html
dom/tests/mochitest/chrome/selectAtPoint.html
dom/tests/mochitest/chrome/test_parsingMode.html
dom/tests/mochitest/general/test_innerScreen.xul
dom/tests/mochitest/sessionstorage/test_sessionStorageUsage.html
dom/tests/mochitest/whatwg/test_bug500328.html
dom/tests/reftest/bug798068-ref.xhtml
dom/tests/reftest/bug798068.xhtml
dom/websocket/tests/test_websocket_frame.html
dom/workers/test/test_WorkerDebugger_suspended.xul
dom/xbl/test/test_bug378518.xul
--- a/dom/base/DOMRequestHelper.jsm
+++ b/dom/base/DOMRequestHelper.jsm
@@ -150,18 +150,17 @@ DOMRequestIpcHelper.prototype = {
       this.addMessageListeners(aMessages);
     }
 
     this._id = this._getRandomId();
 
     this._window = aWindow;
     if (this._window) {
       // We don't use this.innerWindowID, but other classes rely on it.
-      let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIDOMWindowUtils);
+      let util = this._window.windowUtils;
       this.innerWindowID = util.currentInnerWindowID;
     }
 
     this._destroyed = false;
 
     Services.obs.addObserver(this, "inner-window-destroyed",
                              /* weak-ref */ true);
   },
--- a/dom/base/contentAreaDropListener.js
+++ b/dom/base/contentAreaDropListener.js
@@ -305,16 +305,15 @@ ContentAreaDropListener.prototype =
 
   _eventTargetIsDisabled: function(aEvent)
   {
     let ownerDoc = aEvent.originalTarget.ownerDocument;
     if (!ownerDoc || !ownerDoc.defaultView)
       return false;
 
     return ownerDoc.defaultView
-                   .QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils)
+                   .windowUtils
                    .isNodeDisabledForEvents(aEvent.originalTarget);
   }
 };
 
 var components = [ContentAreaDropListener];
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/dom/base/test/browser_messagemanager_unload.js
+++ b/dom/base/test/browser_messagemanager_unload.js
@@ -5,18 +5,17 @@ function frameScript()
   function eventHandler(e) {
     if (!docShell) {
       sendAsyncMessage("Test:Fail", "docShell is null");
     }
 
     sendAsyncMessage("Test:Event", [e.type, e.target === content.document, e.eventPhase]);
   }
 
-  let outerID = content.QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
+  let outerID = content.windowUtils.outerWindowID;
   function onOuterWindowDestroyed(subject, topic, data) {
     if (docShell) {
       sendAsyncMessage("Test:Fail", "docShell is non-null");
     }
 
     let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
     sendAsyncMessage("Test:Event", ["outer-window-destroyed", id == outerID]);
     if (id == outerID) {
--- a/dom/base/test/browser_promiseDocumentFlushed.js
+++ b/dom/base/test/browser_promiseDocumentFlushed.js
@@ -17,18 +17,17 @@ function dirtyStyleAndLayout(factor = 1)
 
 /**
  * Dirties style of the current browser window, but NOT layout.
  */
 function dirtyStyle() {
   gNavToolbox.style.color = "red";
 }
 
-const gWindowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+const gWindowUtils = window.windowUtils;
 
 /**
  * Asserts that no style or layout flushes are required by the
  * current window.
  */
 function assertNoFlushesRequired() {
   Assert.ok(!gWindowUtils.needsFlush(Ci.nsIDOMWindowUtils.FLUSH_STYLE),
             "No style flushes are required.");
--- a/dom/base/test/browser_use_counters.js
+++ b/dom/base/test/browser_use_counters.js
@@ -146,17 +146,17 @@ var check_use_counter_iframe = async fun
   gBrowser.selectedBrowser.loadURI(gHttpTestRoot + "file_use_counter_outer.html");
   await waitForPageLoad(gBrowser.selectedBrowser);
 
   // Inject our desired file into the iframe of the newly-loaded page.
   await ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function(opts) {
     ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
     let deferred = PromiseUtils.defer();
 
-    let wu = content.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    let wu = content.window.windowUtils;
 
     let iframe = content.document.getElementById('content');
     iframe.src = opts.file;
     let listener = (event) => {
       event.target.removeEventListener("load", listener, true);
 
       // We flush the main document first, then the iframe's document to
       // ensure any propagation that might happen from content->parent should
@@ -218,17 +218,17 @@ var check_use_counter_img = async functi
     let img = content.document.getElementById('display');
     img.src = opts.file;
     let listener = (event) => {
       img.removeEventListener("load", listener, true);
 
       // Flush for the image.  It matters what order we do these in, so that
       // the image can propagate its use counters to the document prior to the
       // document reporting its use counters.
-      let wu = content.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      let wu = content.window.windowUtils;
       wu.forceUseCounterFlush(img);
 
       // Flush for the main window.
       wu.forceUseCounterFlush(content.document);
 
       deferred.resolve();
     };
     img.addEventListener("load", listener, true);
@@ -275,17 +275,17 @@ var check_use_counter_direct = async fun
 
   gBrowser.selectedBrowser.loadURI(gHttpTestRoot + file);
   await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
     ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
     await new Promise(resolve => {
       let listener = () => {
         removeEventListener("load", listener, true);
 
-        let wu = content.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        let wu = content.window.windowUtils;
         wu.forceUseCounterFlush(content.document);
 
         setTimeout(resolve, 0);
       }
       addEventListener("load", listener, true);
     });
   });
   
--- a/dom/base/test/chrome/cpows_child.js
+++ b/dom/base/test/chrome/cpows_child.js
@@ -366,19 +366,17 @@ function dead_test(finish)
   if (!is_remote) {
     // Only run this test when running out-of-process.
     finish();
     return;
   }
 
   let gcTrigger = function() {
     // Force the GC to dead-ify the thing.
-    content.QueryInterface(Ci.nsIInterfaceRequestor)
-           .getInterface(Ci.nsIDOMWindowUtils)
-           .garbageCollect();
+    content.windowUtils.garbageCollect();
   }
 
   {
     let thing = { value: "Gonna croak" };
     sendAsyncMessage("cpows:dead", null, { thing, gcTrigger });
   }
 
   addMessageListener("cpows:dead_done", finish);
--- a/dom/base/test/chrome/test_chromeOuterWindowID.xul
+++ b/dom/base/test/chrome/test_chromeOuterWindowID.xul
@@ -24,19 +24,17 @@ windows.
   ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
   ChromeUtils.import("resource://testing-common/ContentTask.jsm");
 
   const BROWSER_DOC = "window_chromeOuterWindowID.xul";
   const TEST_PAGE = "http://example.com";
   const TEST_PAGE_2 = "http://example.com/browser";
 
   function getOuterWindowID(win) {
-    return win.QueryInterface(Ci.nsIInterfaceRequestor)
-              .getInterface(Ci.nsIDOMWindowUtils)
-              .outerWindowID;
+    return win.windowUtils.outerWindowID;
   }
 
   /**
    * Takes two <xul:browser>'s that should be in the same document, and
    * ensures that their frame script environments know the correct value
    * of the host window's outerWindowID.
    */
   async function ensureExpectedChromeOuterWindowIDs(browser1, browser2) {
@@ -128,9 +126,9 @@ windows.
 
     await ensureExpectedChromeOuterWindowIDs(remote1, nonRemote1);
     await ensureExpectedChromeOuterWindowIDs(remote2, nonRemote2);
 
     await BrowserTestUtils.closeWindow(win1);
     await BrowserTestUtils.closeWindow(win2);
   });
   ]]></script>
-</window>
\ No newline at end of file
+</window>
--- a/dom/base/test/file_pluginAudio.html
+++ b/dom/base/test/file_pluginAudio.html
@@ -8,14 +8,12 @@ onload = function() {
 function stopAudio() {
   plugin.stopAudioPlayback();
 }
 function pluginMuted() {
   return plugin.audioMuted();
 }
 function toggleMuteState(muted) {
   var Ci = SpecialPowers.Ci;
-  var utils = SpecialPowers.wrap(window).top
-                           .QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+  var utils = SpecialPowers.getDOMWindowUtils(window.top);
   utils.audioMuted = muted;
 }
 </script>
--- a/dom/base/test/file_pluginAudioNonAutoStart.html
+++ b/dom/base/test/file_pluginAudioNonAutoStart.html
@@ -12,14 +12,12 @@ function stopAudio() {
 }
 
 function pluginMuted() {
   return plugin.audioMuted();
 }
 
 function toggleMuteState(muted) {
   var Ci = SpecialPowers.Ci;
-  var utils = SpecialPowers.wrap(window).top
-                           .QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+  var utils = SpecialPowers.getDOMWindowUtils(window.top);
   utils.audioMuted = muted;
 }
 </script>
--- a/dom/base/test/test_audioWindowUtils.html
+++ b/dom/base/test/test_audioWindowUtils.html
@@ -5,19 +5,17 @@
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <iframe src="about:blank" id="iframe"></iframe>
 <script type="application/javascript">
 
 function runTest() {
-  var utils = SpecialPowers.wrap(window).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  var utils = SpecialPowers.getDOMWindowUtils(window);
   ok(utils, "nsIDOMWindowUtils");
 
   is(utils.audioMuted, false, "By default utils.audioMuted is false");
   utils.audioMuted = true;
   is(utils.audioMuted, true, "utils.audioMuted is true");
   utils.audioMuted = false;
   is(utils.audioMuted, false, "utils.audioMuted is true");
 
@@ -42,19 +40,17 @@ function runTest() {
   utils.audioVolume = 0;
   is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
   utils.audioVolume = 1.0;
   is(utils.audioVolume, 1.0, "utils.audioVolume is ok");
 
   var iframe = document.getElementById("iframe");
   ok(iframe, "IFrame exists");
 
-  utils = SpecialPowers.wrap(iframe.contentWindow).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  utils = SpecialPowers.getDOMWindowUtils(iframe.contentWindow);
   ok(utils, "nsIDOMWindowUtils");
 
   is(utils.audioMuted, false, "By default utils.audioMuted is false");
   utils.audioMuted = true;
   is(utils.audioMuted, true, "utils.audioMuted is true");
   utils.audioMuted = false;
   is(utils.audioMuted, false, "utils.audioMuted is true");
 
@@ -80,19 +76,17 @@ function runTest() {
   is(utils.audioVolume, 0.0, "utils.audioVolume is ok");
   utils.audioVolume = 0.6;
   is(utils.audioVolume.toFixed(2), "0.60", "utils.audioVolume is ok");
   utils.audioMuted = true;
 
   // Navigate the iframe to another URL, and verify that the volume and muted
   // information is preserved.
   iframe.onload = function() {
-    utils = SpecialPowers.wrap(iframe.contentWindow).
-          QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-          getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+    utils = SpecialPowers.getDOMWindowUtils(iframe.contentWindow);
     ok(utils, "nsIDOMWindowUtils");
 
     ok(utils.audioMuted, "Audio should still be muted");
     utils.audioMuted = false;
     ok(utils.audioVolume.toFixed(2), "0.60", "Volume should be preserved");
 
     SimpleTest.finish();
   };
--- a/dom/base/test/test_blocking_image.html
+++ b/dom/base/test/test_blocking_image.html
@@ -14,18 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
 function onLoad() {
   var iframe = document.createElement("iframe");
   iframe.onload = function () {
     info("iframe loaded");
-    var winUtils = iframe.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                       .getInterface(Ci.nsIDOMWindowUtils);
+    var winUtils = iframe.contentWindow.windowUtils;
     // load some styles at the agent level
     var css = `
       img:-moz-suppressed {
         color: green
       }
       img:-moz-broken {
        color: red
       }
--- a/dom/base/test/test_getTranslationNodes.html
+++ b/dom/base/test/test_getTranslationNodes.html
@@ -2,19 +2,17 @@
 <html>
 <head>
   <title>Test for nsIDOMWindowUtils.getTranslationNodes</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body onload="runTest()">
 <script type="application/javascript">
-  var utils = SpecialPowers.wrap(window).
-              QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-              getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  var utils = SpecialPowers.getDOMWindowUtils(window);
 
 
   function testTranslationRoot(rootNode) {
     var translationNodes = utils.getTranslationNodes(rootNode);
 
     var expectedResult = rootNode.getAttribute("expected");
     var expectedLength = expectedResult.split(" ").length;
 
--- a/dom/base/test/test_getTranslationNodes_limit.html
+++ b/dom/base/test/test_getTranslationNodes_limit.html
@@ -2,19 +2,17 @@
 <html>
 <head>
   <title>Test for nsIDOMWindowUtils.getTranslationNodes</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body onload="runTest()">
 <script type="application/javascript">
-  var utils = SpecialPowers.wrap(window).
-              QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-              getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  var utils = SpecialPowers.getDOMWindowUtils(window);
 
   function runTest() {
     isnot(utils, null, "nsIDOMWindowUtils");
 
     for (var i = 0; i < 16000; i++) {
       var text = document.createTextNode("a");
       var node = document.createElement("b");
       node.appendChild(text);
--- a/dom/base/test/test_sendQueryContentAndSelectionSetEvent.html
+++ b/dom/base/test/test_sendQueryContentAndSelectionSetEvent.html
@@ -18,18 +18,17 @@ var editor = document.getElementById("ed
 
 SimpleTest.waitForExplicitFinish();
 
 const kIsWin = navigator.platform.indexOf("Win") == 0;
 const kIsMac = navigator.platform.indexOf("Mac") == 0;
 
 const kLineBreak = kIsWin ? "\r\n" : "\n";
 
-var gUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils);
+var gUtils = window.windowUtils;
 
 function escape(aStr)
 {
   var result = aStr.replace("\n", "\\n");
   return result.replace("\r", "\\r");
 }
 
 function runTests()
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -351,38 +351,34 @@ BrowserElementChild.prototype = {
 
   notify: function(timer) {
     docShell.contentViewer.resumePainting();
     this._paintFrozenTimer.cancel();
     this._paintFrozenTimer = null;
   },
 
   get _windowUtils() {
-    return content.document.defaultView
-                  .QueryInterface(Ci.nsIInterfaceRequestor)
-                  .getInterface(Ci.nsIDOMWindowUtils);
+    return content.document.defaultView.windowUtils;
   },
 
   _tryGetInnerWindowID: function(win) {
-    let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils);
+    let utils = win.windowUtils;
     try {
       return utils.currentInnerWindowID;
     }
     catch(e) {
       return null;
     }
   },
 
   /**
    * Show a modal prompt.  Called by BrowserElementPromptService.
    */
   showModalPrompt: function(win, args) {
-    let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils);
+    let utils = win.windowUtils;
 
     args.windowID = { outer: utils.outerWindowID,
                       inner: this._tryGetInnerWindowID(win) };
     sendAsyncMsg('showmodalprompt', args);
 
     let returnValue = this._waitForResult(win);
 
     if (args.promptType == 'prompt' ||
@@ -393,18 +389,17 @@ BrowserElementChild.prototype = {
   },
 
   /**
    * Spin in a nested event loop until we receive a unblock-modal-prompt message for
    * this window.
    */
   _waitForResult: function(win) {
     debug("_waitForResult(" + win + ")");
-    let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils);
+    let utils = win.windowUtils;
 
     let outerWindowID = utils.outerWindowID;
     let innerWindowID = this._tryGetInnerWindowID(win);
     if (innerWindowID === null) {
       // I have no idea what waiting for a result means when there's no inner
       // window, so let's just bail.
       debug("_waitForResult: No inner window. Bailing.");
       return;
@@ -1237,26 +1232,24 @@ BrowserElementChild.prototype = {
       if (visible && this._paintFrozenTimer) {
         this.notify();
       }
     }
   },
 
   _recvSendMouseEvent: function(data) {
     let json = data.json;
-    let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIDOMWindowUtils);
+    let utils = content.windowUtils;
     utils.sendMouseEventToWindow(json.type, json.x, json.y, json.button,
                                  json.clickCount, json.modifiers);
   },
 
   _recvSendTouchEvent: function(data) {
     let json = data.json;
-    let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIDOMWindowUtils);
+    let utils = content.windowUtils;
     utils.sendTouchEventToWindow(json.type, json.identifiers, json.touchesX,
                                  json.touchesY, json.radiisX, json.radiisY,
                                  json.rotationAngles, json.forces, json.count,
                                  json.modifiers);
   },
 
   _recvCanGoBack: function(data) {
     var webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
--- a/dom/browser-element/BrowserElementParent.js
+++ b/dom/browser-element/BrowserElementParent.js
@@ -214,18 +214,17 @@ BrowserElementParent.prototype = {
            !Cu.isDeadWrapper(this._frameElement.ownerGlobal);
   },
 
   get _window() {
     return this._frameElement.ownerGlobal;
   },
 
   get _windowUtils() {
-    return this._window.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIDOMWindowUtils);
+    return this._window.windowUtils;
   },
 
   promptAuth: function(authDetail, callback) {
     let evt;
     let self = this;
     let callbackCalled = false;
     let cancelCallback = function() {
       if (!callbackCalled) {
--- a/dom/browser-element/BrowserElementPromptService.jsm
+++ b/dom/browser-element/BrowserElementPromptService.jsm
@@ -613,19 +613,17 @@ var BrowserElementPromptService = {
     Cm.registerFactory(newCID,
                        "BrowserElementPromptService's prompter;1 wrapper",
                        contractID, newFactory);
 
     debug("Done installing new prompt factory.");
   },
 
   _getOuterWindowID: function(win) {
-    return win.QueryInterface(Ci.nsIInterfaceRequestor)
-              .getInterface(Ci.nsIDOMWindowUtils)
-              .outerWindowID;
+    return win.windowUtils.outerWindowID;
   },
 
   _browserElementChildMap: {},
   mapWindowToBrowserElementChild: function(win, browserElementChild) {
     this._browserElementChildMap[this._getOuterWindowID(win)] = browserElementChild;
   },
   unmapWindowToBrowserElementChild: function(win) {
     delete this._browserElementChildMap[this._getOuterWindowID(win)];
--- a/dom/canvas/test/webgl-conf/checkout/js/js-test-pre.js
+++ b/dom/canvas/test/webgl-conf/checkout/js/js-test-pre.js
@@ -692,19 +692,17 @@ function webglHarnessCollectGarbage() {
     }
 
     if (window.opera && window.opera.collect) {
         window.opera.collect();
         return;
     }
 
     try {
-        window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-              .getInterface(Components.interfaces.nsIDOMWindowUtils)
-              .garbageCollect();
+        window.windowUtils.garbageCollect();
         return;
     } catch(e) {}
 
     if (window.gc) {
         window.gc();
         return;
     }
 
--- a/dom/events/test/test_bug591249.xul
+++ b/dom/events/test/test_bug591249.xul
@@ -25,19 +25,17 @@ SimpleTest.waitForExplicitFinish();
 
 function completeTest(aBox) {
   ok(window.getComputedStyle(aBox).backgroundColor == "rgb(255, 0, 0)", "The -moz-drag-over style should be removed.");
   SimpleTest.finish();
 }
 
 function fireEvent(target, event) {
   var win = target.ownerGlobal;
-  var utils =
-    win.QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIDOMWindowUtils);
+  var utils = win.windowUtils;
   utils.dispatchDOMEventViaPresShell(target, event, true);
 }
 
 function RunTest() {
   var image = document.getElementById("image");
   var iframe = document.getElementById("iframe");
   var iBox = iframe.contentDocument.getElementById("drop-target");
   var insideBoxX = iBox.offsetWidth + 10;
--- a/dom/events/test/test_bug617528.xul
+++ b/dom/events/test/test_bug617528.xul
@@ -68,18 +68,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     function doTest() {
       var win = browser.contentWindow;
       win.focus();
       var node = win.document.getElementById("node");
       var rect = node.getBoundingClientRect();
       var left = rect.left + rect.width / 2;
       var top = rect.top + rect.height / 2;
 
-      var wu = win.QueryInterface(Ci.nsIInterfaceRequestor)
-        .getInterface(Ci.nsIDOMWindowUtils);
+      var wu = win.windowUtils;
 
       browser.addEventListener("contextmenu", onContextMenu1, false);
       wu.sendMouseEvent("contextmenu", left, top, 2, 1, 0);
       browser.removeEventListener("contextmenu", onContextMenu1, false);
 
       browser.addEventListener("contextmenu", onContextMenu2, false);
       var shiftMask = Event.SHIFT_MASK;
       wu.sendMouseEvent("contextmenu", left, top, 2, 1, shiftMask);
--- a/dom/html/test/browser_content_contextmenu_userinput.js
+++ b/dom/html/test/browser_content_contextmenu_userinput.js
@@ -28,18 +28,17 @@ add_task(async function() {
     ok(testMenuSep && !testMenuSep.hidden,
        "User-added menu separator should be shown");
 
     let testMenuItem = testMenuSep.previousSibling;
     is(testMenuItem.label, "Test Context Menu Click", "Got context menu item");
 
     let promiseCtxMenuClick = ContentTask.spawn(aBrowser, null, async function() {
       await new Promise(resolve => {
-        let windowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                                 .getInterface(Ci.nsIDOMWindowUtils);
+        let windowUtils = content.windowUtils;
         let menuitem = content.document.getElementById("menuitem");
         menuitem.addEventListener("click", function() {
           Assert.ok(windowUtils.isHandlingUserInput,
                     "Content menu click should be a user input");
           resolve();
         });
       });
     });
--- a/dom/media/IdpSandbox.jsm
+++ b/dom/media/IdpSandbox.jsm
@@ -230,18 +230,17 @@ IdpSandbox.prototype = {
     }
     return registrar;
   },
 
   // Capture all the details from the error and log them to the console.  This
   // can't rethrow anything else because that could leak information about the
   // internal workings of the IdP across origins.
   _logError(e) {
-    let winID = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
-        .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+    let winID = this.window.windowUtils.currentInnerWindowID;
     let scriptError = Cc["@mozilla.org/scripterror;1"]
         .createInstance(Ci.nsIScriptError);
     scriptError.initWithWindowID(e.message, e.fileName, null,
                                  e.lineNumber, e.columnNumber,
                                  Ci.nsIScriptError.errorFlag,
                                  "content javascript", winID);
     Services.console.logMessage(scriptError);
   },
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -231,18 +231,17 @@ setupPrototype(RTCIceCandidate, {
   classID: PC_ICE_CID,
   contractID: PC_ICE_CONTRACT,
   QueryInterface: ChromeUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer])
 });
 
 class RTCSessionDescription {
   init(win) {
     this._win = win;
-    this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+    this._winID = this._win.windowUtils.currentInnerWindowID;
   }
 
   __init({ type, sdp }) {
     Object.assign(this, { _type: type, _sdp: sdp });
   }
 
   get type() { return this._type; }
   set type(type) {
@@ -386,18 +385,17 @@ class RTCPeerConnection {
     this._rtpSourceCache = new RTCRtpSourceCache();
   }
 
   init(win) {
     this._win = win;
   }
 
   __init(rtcConfig) {
-    this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+    this._winID = this._win.windowUtils.currentInnerWindowID;
     // TODO: Update this code once we support pc.setConfiguration, to track
     // setting from content independently from pref (Bug 1181768).
     if (rtcConfig.iceTransportPolicy == "all" &&
         Services.prefs.getBoolPref("media.peerconnection.ice.relay_only")) {
       rtcConfig.iceTransportPolicy = "relay";
     }
     this._config = Object.assign({}, rtcConfig);
 
@@ -909,18 +907,17 @@ class RTCPeerConnection {
       let privileged = this._isChrome ||
           Services.prefs.getBoolPref("media.navigator.permission.disabled");
 
       if (privileged) {
         this._havePermission = Promise.resolve();
       } else {
         this._havePermission = new Promise((resolve, reject) => {
           this._settlePermission = { allow: resolve, deny: reject };
-          let outerId = this._win.QueryInterface(Ci.nsIInterfaceRequestor).
-              getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
+          let outerId = this._win.windowUtils.outerWindowID;
 
           let chrome = new CreateOfferRequest(outerId, this._winID,
                                               this._globalPCListId, false);
           let request = this._win.CreateOfferRequest._create(this._win, chrome);
           Services.obs.notifyObservers(request, "PeerConnection:request");
         });
       }
     }
@@ -1866,18 +1863,17 @@ class PeerConnectionObserver {
 setupPrototype(PeerConnectionObserver, {
   classID: PC_OBS_CID,
   contractID: PC_OBS_CONTRACT,
   QueryInterface: ChromeUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer])
 });
 
 class RTCPeerConnectionStatic {
   init(win) {
-    this._winID = win.QueryInterface(Ci.nsIInterfaceRequestor)
-      .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+    this._winID = win.windowUtils.currentInnerWindowID;
   }
 
   registerPeerConnectionLifecycleCallback(cb) {
     _globalPCList._registerPeerConnectionLifecycleCallback(this._winID, cb);
   }
 }
 setupPrototype(RTCPeerConnectionStatic, {
   classID: PC_STATIC_CID,
--- a/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js
+++ b/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js
@@ -1,14 +1,13 @@
 var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
 
 function waitForPluginVisibility(browser, shouldBeVisible, errorMessage) {
   return new Promise((resolve, reject) => {
-    let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIDOMWindowUtils);
+    let windowUtils = window.windowUtils;
     let lastTransactionId = windowUtils.lastTransactionId;
     let listener = async (event) => {
       let visibility = await ContentTask.spawn(browser, null, async function() {
         let doc = content.document;
         let plugin = doc.getElementById("testplugin");
         return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
       });
 
--- a/dom/plugins/test/mochitest/test_bug751809.html
+++ b/dom/plugins/test/mochitest/test_bug751809.html
@@ -14,18 +14,17 @@
 
 <body onload="go();">
   <embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>
 
   <script type="application/javascript">
 
   SimpleTest.waitForExplicitFinish();
 
-  const utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
-                                    getInterface(Ci.nsIDOMWindowUtils);
+  const utils = window.windowUtils;
 
   function go() {
     var plugin = document.getElementById('plugin');
     var objLoadingContent = SpecialPowers.wrap(plugin);
     ok(!objLoadingContent.activated, "plugin should not be activated");
     
     SimpleTest.waitForFocus(afterWindowFocus);
   }
--- a/dom/plugins/test/mochitest/test_convertpoint.xul
+++ b/dom/plugins/test/mochitest/test_convertpoint.xul
@@ -22,18 +22,17 @@ function runTests() {
   // Poll to see if the plugin is in the right place yet.
   // Check if x-coordinate 0 in plugin space is 0 in window space. If it is,
   // the plugin hasn't been placed yet.
   if (pluginElement.convertPointX(1, 0, 0, 2) == 0) {
     setTimeout(runTests, 0);
     return;
   }
 
-  var domWindowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIDOMWindowUtils);
+  var domWindowUtils = window.windowUtils;
 
   var pluginRect = pluginElement.getBoundingClientRect();
   var pluginX = pluginRect.left + (window.mozInnerScreenX - window.screenX);
   var pluginY = pluginRect.top + (window.mozInnerScreenY - window.screenY);
 
   var windowX = window.screenX;
   var windowY = window.screenY;
   var windowHeight = window.outerHeight;
--- a/dom/push/Push.js
+++ b/dom/push/Push.js
@@ -194,18 +194,17 @@ Push.prototype = {
       QueryInterface: ChromeUtils.generateQI([Ci.nsIContentPermissionRequest]),
       allow: allowCallback,
       cancel: cancelCallback,
       window: this._window,
     };
 
     // Using askPermission from nsIDOMWindowUtils that takes care of the
     // remoting if needed.
-    let windowUtils = this._window.QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIDOMWindowUtils);
+    let windowUtils = this._window.windowUtils;
     windowUtils.askPermission(request);
   },
 };
 
 function PushSubscriptionCallback(pushManager, resolve, reject) {
   this.pushManager = pushManager;
   this.resolve = resolve;
   this.reject = reject;
--- a/dom/tests/browser/browser_ConsoleStorageAPITests.js
+++ b/dom/tests/browser/browser_ConsoleStorageAPITests.js
@@ -34,18 +34,17 @@ add_task(async function()
       let apiCallCount = 0;
       let ConsoleObserver = {
         QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
 
         observe: function(aSubject, aTopic, aData) {
           if (aTopic == "console-storage-cache-event") {
             apiCallCount++;
             if (apiCallCount == 4) {
-              let windowId = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
-                    .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+              let windowId = content.window.windowUtils.currentInnerWindowID;
 
               Services.obs.removeObserver(this, "console-storage-cache-event");
               ok(ConsoleAPIStorage.getEvents(windowId).length >= 4, "Some messages found in the storage service");
               ConsoleAPIStorage.clearEvents();
               is(ConsoleAPIStorage.getEvents(windowId).length, 0, "Cleared Storage");
 
               resolve(windowId);
             }
--- a/dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
+++ b/dom/tests/browser/browser_ConsoleStoragePBTest_perwindowpb.js
@@ -11,19 +11,17 @@ function test() {
   let storageShouldOccur;
   let consoleObserver;
   let testURI =
     "http://example.com/browser/dom/tests/browser/test-console-api.html";
   let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
                             .getService(Ci.nsIConsoleAPIStorage);
 
   function getInnerWindowId(aWindow) {
-    return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                  .getInterface(Ci.nsIDOMWindowUtils)
-                  .currentInnerWindowID;
+    return aWindow.windowUtils.currentInnerWindowID;
   }
 
   function whenNewWindowLoaded(aOptions, aCallback) {
     let win = OpenBrowserWindow(aOptions);
     win.addEventListener("load", function() {
       aCallback(win);
     }, {once: true});
   }
--- a/dom/tests/browser/browser_frame_elements.js
+++ b/dom/tests/browser/browser_frame_elements.js
@@ -1,70 +1,59 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const TEST_URI = "http://example.com/browser/dom/tests/browser/browser_frame_elements.html";
 
-function getWindowUtils(window) {
-  return window.
-    QueryInterface(Ci.nsIInterfaceRequestor).
-    getInterface(Ci.nsIDOMWindowUtils);
-}
-
 add_task(async function test() {
   await BrowserTestUtils.withNewTab({ gBrowser, url: TEST_URI }, async function(browser) {
     if (!browser.isRemoteBrowser) {
       // Non-e10s, access contentWindow and confirm its container is the browser:
-      let windowUtils = getWindowUtils(browser.contentWindow);
+      let windowUtils = browser.contentWindow.windowUtils;
       is (windowUtils.containerElement, browser,
           "Container element for main window is xul:browser");
 
     }
 
     await ContentTask.spawn(browser, null, startTests);
     await mozBrowserTests(browser);
   });
 });
 
 function startTests() {
-  function getWindowUtils(window) {
-    return window.
-      QueryInterface(Ci.nsIInterfaceRequestor).
-      getInterface(Ci.nsIDOMWindowUtils);
-  }
   info("Frame tests started");
 
   info("Checking top window");
   let gWindow = content;
   Assert.equal(gWindow.top, gWindow, "gWindow is top");
   Assert.equal(gWindow.parent, gWindow, "gWindow is parent");
 
   info("Checking about:blank iframe");
   let iframeBlank = gWindow.document.querySelector("#iframe-blank");
   Assert.ok(iframeBlank, "Iframe exists on page");
-  let iframeBlankUtils = getWindowUtils(iframeBlank.contentWindow);
+  let iframeBlankUtils = iframeBlank.contentWindow.windowUtils;
   Assert.equal(iframeBlankUtils.containerElement, iframeBlank, "Container element for iframe window is iframe");
   Assert.equal(iframeBlank.contentWindow.top, gWindow, "gWindow is top");
   Assert.equal(iframeBlank.contentWindow.parent, gWindow, "gWindow is parent");
 
   info("Checking iframe with data url src");
   let iframeDataUrl = gWindow.document.querySelector("#iframe-data-url");
   Assert.ok(iframeDataUrl, "Iframe exists on page");
-  let iframeDataUrlUtils = getWindowUtils(iframeDataUrl.contentWindow);
+  let iframeDataUrlUtils = iframeDataUrl.contentWindow.windowUtils;
   Assert.equal(iframeDataUrlUtils.containerElement, iframeDataUrl, "Container element for iframe window is iframe");
   Assert.equal(iframeDataUrl.contentWindow.top, gWindow, "gWindow is top");
   Assert.equal(iframeDataUrl.contentWindow.parent, gWindow, "gWindow is parent");
 
   info("Checking object with data url data attribute");
   let objectDataUrl = gWindow.document.querySelector("#object-data-url");
   Assert.ok(objectDataUrl, "Object exists on page");
-  let objectDataUrlUtils = getWindowUtils(objectDataUrl.contentWindow);
+  let objectDataUrlUtils = objectDataUrl.contentWindow.windowUtils;
   Assert.equal(objectDataUrlUtils.containerElement, objectDataUrl, "Container element for object window is the object");
   Assert.equal(objectDataUrl.contentWindow.top, gWindow, "gWindow is top");
   Assert.equal(objectDataUrl.contentWindow.parent, gWindow, "gWindow is parent");
 }
 
 async function mozBrowserTests(browser) {
   info("Granting special powers for mozbrowser");
   SpecialPowers.addPermission("browser", true, TEST_URI);
--- a/dom/tests/mochitest/chrome/489127.html
+++ b/dom/tests/mochitest/chrome/489127.html
@@ -6,18 +6,17 @@
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 <script type="application/javascript">
 
   var SimpleTest = window.opener.SimpleTest;
   function ok() { window.opener.ok.apply(window.opener, arguments); }
   function done() { window.opener.done.apply(window.opener, arguments); }
   let e = {};
 
-  let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                  .getInterface(Ci.nsIDOMWindowUtils);
+  let dwu = window.windowUtils;
 
   /*
     NodeList nodesFromRect(in float aX,
                            in float aY,
                            in float aTopSize, 
                            in float aRightSize,
                            in float aBottomSize,
                            in float aLeftSize,
--- a/dom/tests/mochitest/chrome/file_bug1224790-2_nonmodal.xul
+++ b/dom/tests/mochitest/chrome/file_bug1224790-2_nonmodal.xul
@@ -20,18 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   function runTests() {
     opener.wrappedJSObject.nonModalOpened()
   }
 
   function modalClosed(grandparent) {
     // Request cycle collection to trigger destructor for parent modal window,
     // that mutates mAncestorLink of this window.
     var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
-    var windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
-      getInterface(Ci.nsIDOMWindowUtils);
+    var windowUtils = window.windowUtils;
 
     Services.obs.notifyObservers(null, "child-cc-request");
     windowUtils.cycleCollect();
 
     // Wait for a while.
     setTimeout(function() {
       window.close();
       grandparent.wrappedJSObject.nonModalClosed();
--- a/dom/tests/mochitest/chrome/file_bug799299.xul
+++ b/dom/tests/mochitest/chrome/file_bug799299.xul
@@ -16,18 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 799299 **/
 
   function sendClick(win) {
-    var wu = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                .getInterface(Ci.nsIDOMWindowUtils);
+    var wu = win.windowUtils;
     wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
     wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
   }
 
   function runTests() {
     var b1 = document.getElementById("b1");
     var b2 = document.getElementById("b2");
     b1.contentWindow.focus();
--- a/dom/tests/mochitest/chrome/file_bug800817.xul
+++ b/dom/tests/mochitest/chrome/file_bug800817.xul
@@ -16,18 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 800817 **/
 
   function sendClick(win) {
-    var wu = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                .getInterface(Ci.nsIDOMWindowUtils);
+    var wu = win.windowUtils;
     wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
     wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
   }
 
   function runTests() {
     var b1 = document.getElementById("b1");
     var b2 = document.getElementById("b2");
 
--- a/dom/tests/mochitest/chrome/file_bug830858.xul
+++ b/dom/tests/mochitest/chrome/file_bug830858.xul
@@ -19,18 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 830858 **/
 
   function runTests() {
     var b = document.getElementById("b");
     var win = b.contentWindow;
     var doc = win.document;
-    var wu = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                .getInterface(Ci.nsIDOMWindowUtils);
+    var wu = win.windowUtils;
 
     var docListenerCalled = 0;
     doc.addEventListener("foo", function() { ++docListenerCalled; }, true);
     var winListenerCalled = 0;
     win.addEventListener("foo", function() { ++winListenerCalled; }, true);
     var iframeListenerCalled = 0;
     b.addEventListener("foo", function() { ++iframeListenerCalled; }, true);
 
--- a/dom/tests/mochitest/chrome/queryCaretRectUnix.html
+++ b/dom/tests/mochitest/chrome/queryCaretRectUnix.html
@@ -80,18 +80,17 @@
 
     ok(rect.left > aRectDims.min.left, "rect.left > " + aRectDims.min.left);
     ok(rect.left < aRectDims.max.left, "rect.left < " + aRectDims.max.left);
     ok(rect.top > aRectDims.min.top, "rect.top > " + aRectDims.min.top);
     ok(rect.top < aRectDims.max.top, "rect.top < " + aRectDims.max.top);
   }
 
   function doTest() {
-    let domWinUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIDOMWindowUtils);
+    let domWinUtils = window.windowUtils;
 
     let text = document.getElementById("text");
 
     text.focus();
 
     let textrect = text.getBoundingClientRect();
 
     let cp = document.caretPositionFromPoint(10, 395);
--- a/dom/tests/mochitest/chrome/queryCaretRectWin.html
+++ b/dom/tests/mochitest/chrome/queryCaretRectWin.html
@@ -89,18 +89,17 @@
 
     ok(rect.left > aRectDims.min.left, "rect.left > " + aRectDims.min.left);
     ok(rect.left < aRectDims.max.left, "rect.left < " + aRectDims.max.left);
     ok(rect.top > aRectDims.min.top, "rect.top > " + aRectDims.min.top);
     ok(rect.top < aRectDims.max.top, "rect.top < " + aRectDims.max.top);
   }
 
   function doTest() {
-    let domWinUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIDOMWindowUtils);
+    let domWinUtils = window.windowUtils;
 
     let text = document.getElementById("text");
 
     text.focus();
 
     let textrect = text.getBoundingClientRect();
 
     let cp = document.caretPositionFromPoint(10, 395);
--- a/dom/tests/mochitest/chrome/selectAtPoint.html
+++ b/dom/tests/mochitest/chrome/selectAtPoint.html
@@ -61,18 +61,17 @@
     let result = (text == aExpectedSelectionText);
     ok(result, aSelectTypeStr + " selection text matches?");
     if (!result) {
       dumpLn(aSelectTypeStr + " selection text:", "[" + text + "] expected:[" + aExpectedSelectionText + "]" );
     }
   }
 
   function doTest() {
-    let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                    .getInterface(Ci.nsIDOMWindowUtils);
+    let dwu = window.windowUtils;
 
     let os = Cc["@mozilla.org/xre/app-info;1"]
                .getService(Ci.nsIXULRuntime).OS;
     let isLinux = (os == "Linux");
     let isMac = (os == "Darwin");
     let isWindows = (os == "WINNT");
 
     if (!isLinux && !isMac && !isWindows) {
@@ -151,18 +150,17 @@
 
     //
     // Inner IFRAME selection tests
     //
 
     let frame = document.getElementById("frame1");
     let dwuFrame = frame.contentDocument
                         .defaultView
-                        .QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIDOMWindowUtils);
+                        .windowUtils;
 
     frame.contentWindow.scrollTo(0, 0);
 
     rect = frame.getBoundingClientRect();
 
     targetPoint = { xPos: charDims.width / 2,
                     yPos: charDims.height / 2 };
     setSingle(dwuFrame, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORDNOSPACE);
--- a/dom/tests/mochitest/chrome/test_parsingMode.html
+++ b/dom/tests/mochitest/chrome/test_parsingMode.html
@@ -4,18 +4,17 @@
   <title>CSSStyleSheet parsingMode test - bug 1230491</title>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 <script type="application/javascript">
   SimpleTest.waitForExplicitFinish();
   function run() {
     const sss = Cc["@mozilla.org/content/style-sheet-service;1"]
       .getService(Ci.nsIStyleSheetService);
-    const utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-      .getInterface(Ci.nsIDOMWindowUtils);
+    const utils = window.windowUtils;
 
     const userUrl = encodeURI("data:text/css,body { color: seagreen; -moz-window-transform: none }");
     utils.loadSheetUsingURIString(userUrl, sss.USER_SHEET);
 
     const agentUrl = encodeURI("data:text/css,body { color: tomato; }");
     utils.loadSheetUsingURIString(agentUrl, sss.AGENT_SHEET);
 
     const authorUrl = "chrome://mochikit/content/tests/SimpleTest/test.css";
--- a/dom/tests/mochitest/general/test_innerScreen.xul
+++ b/dom/tests/mochitest/general/test_innerScreen.xul
@@ -30,18 +30,17 @@ function doTests()
   try
   {
     mozScreenPixelsPerCSSPixel;
     readable = true;
   }
   catch(ex) { }
   ok(!readable, "window pixels per css pixel shouldn't be readable to content");
 
-  var domWindowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+  var domWindowUtils = window.windowUtils;
   var devPxPerCSSPx = domWindowUtils.screenPixelsPerCSSPixel;
 
   is(window.devicePixelRatio, devPxPerCSSPx, "window.devicePixelRatio");
 
   var windowBO = document.documentElement.boxObject;
   isRounded(window.mozInnerScreenX*devPxPerCSSPx, windowBO.screenX,
             "window screen X");
   isRounded(window.mozInnerScreenY*devPxPerCSSPx, windowBO.screenY,
@@ -56,18 +55,17 @@ function doTests()
   isRounded(f.contentWindow.mozInnerScreenX,
             window.mozInnerScreenX + fBounds.left,
             "frame screen X");
   isRounded(f.contentWindow.mozInnerScreenY,
             window.mozInnerScreenY + fBounds.top,
             "frame screen Y");
 
   fmudv.fullZoom *= 2;
-  var frameDomWindowUtils = f.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIDOMWindowUtils);
+  var frameDomWindowUtils = f.contentWindow.windowUtils;
   is(frameDomWindowUtils.screenPixelsPerCSSPixel, 2*devPxPerCSSPx,
      "frame screen pixels per CSS pixel");
 
   is(f.contentWindow.devicePixelRatio, 2*devPxPerCSSPx, "frame devicePixelRatio");
 
   isRounded(f.contentWindow.mozInnerScreenX*2,
             window.mozInnerScreenX + fBounds.left,
             "zoomed frame screen X");
--- a/dom/tests/mochitest/sessionstorage/test_sessionStorageUsage.html
+++ b/dom/tests/mochitest/sessionstorage/test_sessionStorageUsage.html
@@ -9,19 +9,17 @@
 
 function setup() {
   sessionStorage.clear();
   SimpleTest.executeSoon(startTest);
 }
 
 function startTest()
 {
-  var util = SpecialPowers.wrap(window)
-               .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-               .getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  var util = SpecialPowers.getDOMWindowUtils(window);
 
   // Check initial state.
   is(sessionStorage.length, 0, "storage is empty");
   is(util.getStorageUsage(sessionStorage), 0, "usage is zero");
 
   // Add some data.
   sessionStorage.setItem("one", "data");
   var usage = util.getStorageUsage(sessionStorage);
--- a/dom/tests/mochitest/whatwg/test_bug500328.html
+++ b/dom/tests/mochitest/whatwg/test_bug500328.html
@@ -148,19 +148,17 @@ function noPopStateExpected(msg) {
 }
 
 function popstateExpected(msg) {
   is(gNumPopStates, 1, msg);
   gNumPopStates = 0;
 }
 
 function getColor(elem) {
-  var utils = SpecialPowers.wrap(document).defaultView.
-                QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-                getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
+  var utils = SpecialPowers.getDOMWindowUtils(document.defaultView);
   return utils.getVisitedDependentComputedStyle(elem, "", "color");
 }
 
 function getSHistory(theWindow)
 {
   const Ci = SpecialPowers.Ci;
   var sh = SpecialPowers.wrap(theWindow.QueryInterface(Ci.nsIInterfaceRequestor))
                         .getInterface(Ci.nsIWebNavigation)
--- a/dom/tests/reftest/bug798068-ref.xhtml
+++ b/dom/tests/reftest/bug798068-ref.xhtml
@@ -1,15 +1,15 @@
 <?xml version = '1.0' encoding = 'utf-8'?>
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <script>
       function doTest() {
         var defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom ={}, width = {}, height = {}, autoSize = {};
-        var windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        var windowUtils = window.windowUtils;
         windowUtils.getViewportInfo(1, 1, defaultZoom, allowZoom, minZoom, maxZoom, width, height, autoSize);
         document.getElementById("minZoom").innerHTML = minZoom.value.toPrecision(10);
         document.getElementById("maxZoom").innerHTML = maxZoom.value.toPrecision(10);
       }
     </script>
   </head>
   <body onload="doTest();">
   MinZoom: <span id="minZoom"></span><br />
--- a/dom/tests/reftest/bug798068.xhtml
+++ b/dom/tests/reftest/bug798068.xhtml
@@ -1,16 +1,16 @@
 <?xml version = '1.0' encoding = 'utf-8'?>
 <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <script>
       function doTest() {
         var defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom ={}, width = {}, height = {}, autoSize = {};
-        var windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        var windowUtils = window.windowUtils;
         windowUtils.getViewportInfo(1, 1, defaultZoom, allowZoom, minZoom, maxZoom, width, height, autoSize);
         document.getElementById("minZoom").innerHTML = minZoom.value.toPrecision(10);
         document.getElementById("maxZoom").innerHTML = maxZoom.value.toPrecision(10);
       }
     </script>
   </head>
   <body onload="doTest();">
   MinZoom: <span id="minZoom"></span><br />
--- a/dom/websocket/tests/test_websocket_frame.html
+++ b/dom/websocket/tests/test_websocket_frame.html
@@ -21,19 +21,17 @@ var webSocketClosedCounter = 0;
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var tests = [
   { payload: "Hello world!" },
   { payload: (function() { var buffer = ""; for (var i = 0; i < 120; ++i) buffer += i; return buffer; }()) },
 ]
 
-var innerId =
-  window.top.QueryInterface(Ci.nsIInterfaceRequestor)
-        .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
+var innerId = window.top.windowUtils.currentInnerWindowID;
 ok(innerId, "We have a valid innerWindowID: " + innerId);
 
 var service = Cc["@mozilla.org/websocketevent/service;1"]
                 .getService(Ci.nsIWebSocketEventService);
 ok(!!service, "We have the nsIWebSocketEventService");
 
 var listener = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIWebSocketEventListener]),
--- a/dom/workers/test/test_WorkerDebugger_suspended.xul
+++ b/dom/workers/test/test_WorkerDebugger_suspended.xul
@@ -36,18 +36,17 @@
           waitForDebuggerMessage(dbg, "debugger")
         ]);
         worker.postMessage("ping");
         await promise;
 
         info("Suspend the workers for this window, and send another request " +
              "to the worker. This should cause only the worker debugger to " +
              "send a response.");
-        let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                                .getInterface(Ci.nsIDOMWindowUtils);
+        let windowUtils = window.windowUtils;
         windowUtils.suspendTimeouts();
         function onmessage() {
           ok(false, "The worker should not send a response.");
         };
         worker.addEventListener("message", onmessage);
         promise = waitForDebuggerMessage(dbg, "debugger");
         worker.postMessage("ping");
         await promise;
--- a/dom/xbl/test/test_bug378518.xul
+++ b/dom/xbl/test/test_bug378518.xul
@@ -47,19 +47,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     SimpleTest.expectAssertions(1);
 
     var myBoxClicked = false;
     var myCheckBoxClicked = false;
     var myExtendedBoxClicked = false;
 
     function testClick(elemName) {
-      var wu  =
-        window.QueryInterface(Ci.nsIInterfaceRequestor)
-              .getInterface(Ci.nsIDOMWindowUtils);
+      var wu = window.windowUtils;
 
       var a = document.getElementById(elemName).getBoundingClientRect();
       wu.sendMouseEvent('mousedown',  a.left + 1, a.top + 1, 0, 1, 0);
       wu.sendMouseEvent('mouseup',  a.left + 1, a.top + 1, 0, 1, 0);
     }
 
     function doTest() {
       testClick('myBox');