Bug 1476145 part 7. Stop using getInterface(nsIDOMWindowUtils) in mobile/. r=snorp
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 24 Jul 2018 19:47:42 -0400
changeset 476460 ed72643ae3ea1f626de9972d834f71efba3367aa
parent 476459 6bd61a056a6389505fa0d91e7a9350a2667fdc20
child 476461 d2df9ae93b11d29cb471fbecdf9616c277a27dd2
push id211
push userfmarier@mozilla.com
push dateWed, 01 Aug 2018 21:19:47 +0000
reviewerssnorp
bugs1476145
milestone63.0a1
Bug 1476145 part 7. Stop using getInterface(nsIDOMWindowUtils) in mobile/. r=snorp
mobile/android/chrome/content/MemoryObserver.js
mobile/android/chrome/content/PluginHelper.js
mobile/android/chrome/content/browser.js
mobile/android/chrome/geckoview/GeckoViewContent.js
mobile/android/chrome/geckoview/GeckoViewContentSettings.js
mobile/android/components/ContentDispatchChooser.js
mobile/android/components/FilePicker.js
mobile/android/components/PromptService.js
mobile/android/components/SessionStore.js
mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html
mobile/android/components/geckoview/GeckoViewPrompt.js
mobile/android/modules/geckoview/GeckoViewContent.jsm
mobile/android/tests/browser/chrome/test_awsy_lite.html
mobile/android/tests/browser/chrome/test_session_scroll_position.html
mobile/android/tests/browser/robocop/testAccessibleCarets.js
--- a/mobile/android/chrome/content/MemoryObserver.js
+++ b/mobile/android/chrome/content/MemoryObserver.js
@@ -52,17 +52,17 @@ var MemoryObserver = {
     // Re-enable the bfcache
     let defaults = Services.prefs.getDefaultBranch(null);
     if (!Services.prefs.getBoolPref("browser.sessionhistory.bfcacheIgnoreMemoryPressure")) {
       defaults.setIntPref(MAX_CONTENT_VIEWERS_PREF, this._defaultMaxContentViewers);
     }
   },
 
   gc: function() {
-    window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).garbageCollect();
+    window.windowUtils.garbageCollect();
     Cu.forceGC();
   },
 
   dumpMemoryStats: function(aLabel) {
     let memDumper = Cc["@mozilla.org/memory-info-dumper;1"].getService(Ci.nsIMemoryInfoDumper);
     memDumper.dumpMemoryInfoToTempDir(aLabel, /* anonymize = */ false,
                                       /* minimize = */ false);
   },
--- a/mobile/android/chrome/content/PluginHelper.js
+++ b/mobile/android/chrome/content/PluginHelper.js
@@ -68,18 +68,17 @@ var PluginHelper = {
         if (this.shouldShowPluginDoorhanger) {
           PluginHelper.showDoorHanger(this);
         }
       }.bind(aTab), 500);
     }
   },
 
   playAllPlugins: function(aContentWindow) {
-    let cwu = aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIDOMWindowUtils);
+    let cwu = aContentWindow.windowUtils;
     // XXX not sure if we should enable plugins for the parent documents...
     let plugins = cwu.plugins;
     if (!plugins || !plugins.length)
       return;
 
     plugins.forEach(this.playPlugin);
   },
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1076,17 +1076,17 @@ var BrowserApp = {
 
     let tab = this.selectedTab;
     if (!tab)
       return false;
     return tab.contentDocumentIsDisplayed;
   },
 
   contentDocumentChanged: function() {
-    window.top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).isFirstPaint = true;
+    window.top.windowUtils.isFirstPaint = true;
     Services.androidBridge.contentDocumentChanged(window);
   },
 
   get tabs() {
     return this._tabs;
   },
 
   set selectedTab(aTab) {
@@ -1645,18 +1645,17 @@ var BrowserApp = {
   },
 
   scrollToFocusedInput: function(aBrowser) {
     let formHelperMode = Services.prefs.getIntPref("formhelper.mode");
     if (formHelperMode == kFormHelperModeDisabled) {
       return;
     }
 
-    let dwu = aBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIDOMWindowUtils);
+    let dwu = aBrowser.contentWindow.windowUtils;
     if (!dwu) {
       return;
     }
 
     let zoomToFocusedInput = function() {
       if (!dwu.flushApzRepaints()) {
         dwu.zoomToFocusedInput();
         return;
@@ -3819,17 +3818,17 @@ Tab.prototype = {
   },
 
   /**
    * Reloads the tab with the desktop mode setting.
    */
   reloadWithMode: function (aDesktopMode) {
     // notify desktopmode for PIDOMWindow
     let win = this.browser.contentWindow;
-    let dwi = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    let dwi = win.windowUtils;
     dwi.setDesktopModeViewport(aDesktopMode);
 
     // Set desktop mode for tab and send change to Java
     if (this.desktopMode != aDesktopMode) {
       this.desktopMode = aDesktopMode;
       GlobalEventDispatcher.sendRequest({
         type: "DesktopMode:Changed",
         desktopMode: aDesktopMode,
@@ -4776,17 +4775,17 @@ Tab.prototype = {
           tabID: this.id,
           status: status
         });
         break;
 
       case "audioFocusChanged":
       case "mediaControl":
         let win = this.browser.contentWindow;
-        let utils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        let utils = win.windowUtils;
         let suspendTypes = Ci.nsISuspendedTypes;
         switch (aData) {
           case "lostAudioFocus":
             utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE_DISPOSABLE;
             break;
           case "lostAudioFocusTransiently":
             utils.mediaSuspend = suspendTypes.SUSPENDED_PAUSE;
             break;
--- a/mobile/android/chrome/geckoview/GeckoViewContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContent.js
@@ -63,17 +63,17 @@ class GeckoViewContent extends GeckoView
   }
 
   collectSessionState() {
     let history = SessionHistory.collect(docShell);
     let [formdata, scrolldata] = this.Utils.mapFrameTree(content, FormData.collect, ScrollPosition.collect);
 
     // Save the current document resolution.
     let zoom = { value: 1 };
-    let domWindowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    let domWindowUtils = content.windowUtils;
     domWindowUtils.getResolution(zoom);
     scrolldata = scrolldata || {};
     scrolldata.zoom = {};
     scrolldata.zoom.resolution = zoom.value;
 
     // Save some data that'll help in adjusting the zoom level
     // when restoring in a different screen orientation.
     let displaySize = {};
@@ -91,33 +91,30 @@ class GeckoViewContent extends GeckoView
   }
 
   receiveMessage(aMsg) {
     debug `receiveMessage: ${aMsg.name}`;
 
     switch (aMsg.name) {
       case "GeckoView:DOMFullscreenEntered":
         if (content) {
-          content.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIDOMWindowUtils)
+          content.windowUtils
                  .handleFullscreenRequests();
         }
         break;
 
       case "GeckoView:DOMFullscreenExited":
         if (content) {
-          content.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIDOMWindowUtils)
+          content.windowUtils
                  .exitFullscreen();
         }
         break;
 
       case "GeckoView:ZoomToInput": {
-        let dwu = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIDOMWindowUtils);
+        let dwu = content.windowUtils;
 
         let zoomToFocusedInput = function() {
           if (!dwu.flushApzRepaints()) {
             dwu.zoomToFocusedInput();
             return;
           }
           Services.obs.addObserver(function apzFlushDone() {
             Services.obs.removeObserver(apzFlushDone, "apz-repaints-flushed");
@@ -289,17 +286,17 @@ class GeckoViewContent extends GeckoView
 
   // WebProgress event handler.
   onLocationChange(aWebProgress, aRequest, aLocationURI, aFlags) {
     debug `onLocationChange`;
 
     if (this._savedState) {
       const scrolldata = this._savedState.scrolldata;
       if (scrolldata && scrolldata.zoom && scrolldata.zoom.displaySize) {
-        let utils = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        let utils = content.windowUtils;
         // Restore zoom level.
         utils.setRestoreResolution(scrolldata.zoom.resolution,
                                    scrolldata.zoom.displaySize.width,
                                    scrolldata.zoom.displaySize.height);
       }
     }
 
     this.progressFilter.removeProgressListener(this);
--- a/mobile/android/chrome/geckoview/GeckoViewContentSettings.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContentSettings.js
@@ -38,18 +38,17 @@ class GeckoViewContentSettings extends G
   get useDesktopMode() {
     return this._useDesktopMode;
   }
 
   set useDesktopMode(aUse) {
     if (this.useDesktopMode === aUse) {
       return;
     }
-    let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIDOMWindowUtils);
+    let utils = content.windowUtils;
     utils.setDesktopModeViewport(aUse);
     this._useDesktopMode = aUse;
   }
 
   get displayMode() {
     const docShell = content && GeckoViewUtils.getRootDocShell(content);
     return docShell ? docShell.displayMode
                     : Ci.nsIDocShell.DISPLAY_MODE_BROWSER;
--- a/mobile/android/components/ContentDispatchChooser.js
+++ b/mobile/android/components/ContentDispatchChooser.js
@@ -78,17 +78,17 @@ ContentDispatchChooser.prototype =
           // We always want to open a fallback url
           window.location.href = data.uri;
           return;
         }
 
         // We couldn't open this. If this was from a click, it's likely that we just
         // want this to fail silently. If the user entered this on the address bar, though,
         // we want to show the neterror page.
-        let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        let dwu = window.windowUtils;
         let millis = dwu.millisSinceLastUserInput;
         if (millis < 0 || millis >= 1000) {
           window.document.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PROTOCOL, aURI, null);
         } else {
           this._closeBlankWindow(window);
         }
       });
     }
--- a/mobile/android/components/FilePicker.js
+++ b/mobile/android/components/FilePicker.js
@@ -163,28 +163,28 @@ FilePicker.prototype = {
 
   get mode() {
     return this._mode;
   },
 
   show: function() {
     if (this._domWin) {
       this.fireDialogEvent(this._domWin, "DOMWillOpenModalDialog");
-      let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = this._domWin.windowUtils;
       winUtils.enterModalState();
     }
 
     this._promptActive = true;
     this._sendMessage();
 
     Services.tm.spinEventLoopUntil(() => !this._promptActive);
     delete this._promptActive;
 
     if (this._domWin) {
-      let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = this._domWin.windowUtils;
       winUtils.leaveModalState();
       this.fireDialogEvent(this._domWin, "DOMModalDialogClosed");
     }
 
     if (this._filePath)
       return Ci.nsIFilePicker.returnOK;
 
     return Ci.nsIFilePicker.returnCancel;
@@ -270,18 +270,17 @@ FilePicker.prototype = {
 
   fireDialogEvent: function(aDomWin, aEventName) {
     // accessing the document object can throw if this window no longer exists. See bug 789888.
     try {
       if (!aDomWin.document)
         return;
       let event = aDomWin.document.createEvent("Events");
       event.initEvent(aEventName, true, true);
-      let winUtils = aDomWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = aDomWin.windowUtils;
       winUtils.dispatchEventToChromeOnly(aDomWin, event);
     } catch (ex) {
     }
   },
 
   classID: Components.ID("{18a4e042-7c7c-424b-a583-354e68553a7f}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIFilePicker, Ci.nsIObserver])
 };
--- a/mobile/android/components/PromptService.js
+++ b/mobile/android/components/PromptService.js
@@ -140,30 +140,30 @@ InternalPrompt.prototype = {
   },
 
   /* Shows a native prompt, and then spins the event loop for this thread while we wait
    * for a response
    */
   showPrompt: function showPrompt(aPrompt) {
     if (this._domWin) {
       PromptUtils.fireDialogEvent(this._domWin, "DOMWillOpenModalDialog");
-      let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = this._domWin.windowUtils;
       winUtils.enterModalState();
     }
 
     let retval = null;
     aPrompt.show(function(data) {
       retval = data;
     });
 
     // Spin this thread while we wait for a result
     Services.tm.spinEventLoopUntil(() => retval != null);
 
     if (this._domWin) {
-      let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = this._domWin.windowUtils;
       winUtils.leaveModalState();
       PromptUtils.fireDialogEvent(this._domWin, "DOMModalDialogClosed");
     }
 
     return retval;
   },
 
   /*
@@ -788,18 +788,17 @@ var PromptUtils = {
 
   fireDialogEvent: function(aDomWin, aEventName) {
     // accessing the document object can throw if this window no longer exists. See bug 789888.
     try {
       if (!aDomWin.document)
         return;
       let event = aDomWin.document.createEvent("Events");
       event.initEvent(aEventName, true, true);
-      let winUtils = aDomWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = aDomWin.windowUtils;
       winUtils.dispatchEventToChromeOnly(aDomWin, event);
     } catch (ex) {
     }
   }
 };
 
 XPCOMUtils.defineLazyGetter(PromptUtils, "passwdBundle", function() {
   return Services.strings.createBundle("chrome://browser/locale/passwordmgr.properties");
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -932,18 +932,17 @@ SessionStore.prototype = {
 
     // Save the scroll position itself.
     let content = aBrowser.contentWindow;
     let [scrolldata] = Utils.mapFrameTree(content, ScrollPosition.collect);
     scrolldata = scrolldata || {};
 
     // Save the current document resolution.
     let zoom = { value: 1 };
-    content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(
-      Ci.nsIDOMWindowUtils).getResolution(zoom);
+    content.windowUtils.getResolution(zoom);
     scrolldata.zoom = {};
     scrolldata.zoom.resolution = zoom.value;
     log("onTabScroll() zoom level: " + zoom.value);
 
     // Save some data that'll help in adjusting the zoom level
     // when restoring in a different screen orientation.
     scrolldata.zoom.displaySize = this._getContentViewerSize(content);
     log("onTabScroll() displayWidth: " + scrolldata.zoom.displaySize.width);
@@ -953,18 +952,17 @@ SessionStore.prototype = {
     log("onTabScroll() ran for tab " + aWindow.BrowserApp.getTabForBrowser(aBrowser).id);
     sendEvent(aBrowser, "SSTabScrollCaptured");
     this.saveStateDelayed();
   },
 
   _getContentViewerSize: function ss_getContentViewerSize(aWindow) {
     let displaySize = {};
     let width = {}, height = {};
-    aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(
-      Ci.nsIDOMWindowUtils).getContentViewerSize(width, height);
+    aWindow.windowUtils.getContentViewerSize(width, height);
 
     displaySize.width = width.value;
     displaySize.height = height.value;
 
     return displaySize;
   },
 
   saveStateDelayed: function ss_saveStateDelayed(aPrivateTabsOnly = false) {
@@ -1396,18 +1394,17 @@ SessionStore.prototype = {
    * Restores the zoom level of the window. This needs to be called before
    * first paint/load (whichever comes first) to take any effect.
    */
   _restoreZoom: function ss_restoreZoom(aScrollData, aBrowser) {
     if (aScrollData && aScrollData.zoom && aScrollData.zoom.displaySize) {
       log("_restoreZoom(), resolution: " + aScrollData.zoom.resolution +
           ", old displayWidth: " + aScrollData.zoom.displaySize.width);
 
-      let utils = aBrowser.contentWindow.QueryInterface(
-        Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      let utils = aBrowser.contentWindow.windowUtils;
       // Restore zoom level.
       utils.setRestoreResolution(aScrollData.zoom.resolution,
                                  aScrollData.zoom.displaySize.width,
                                  aScrollData.zoom.displaySize.height);
     }
   },
 
   /**
--- a/mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html
+++ b/mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html
@@ -22,18 +22,17 @@ async function waitAboutAddonsRendered(a
   }, `wait Addon Item for ${addonId} to be rendered`);
 }
 
 async function navigateToAddonDetails(addonId) {
   const item = content.document.querySelector(`div.addon-item[addonID="${addonId}"]`);
   let rect = item.getBoundingClientRect();
   const x = rect.left + rect.width / 2;
   const y = rect.top + rect.height / 2;
-  let domWinUtils = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
-                           .getInterface(Ci.nsIDOMWindowUtils);
+  let domWinUtils = content.window.windowUtils;
 
   domWinUtils.sendMouseEventToWindow("mousedown", x, y, 0, 1, 0);
   domWinUtils.sendMouseEventToWindow("mouseup", x, y, 0, 1, 0);
 }
 
 async function waitAddonOptionsPage([addonId, expectedText]) {
   await ContentTaskUtils.waitForCondition(() => {
     const optionsIframe = content.document.querySelector(`#addon-options`);
--- a/mobile/android/components/geckoview/GeckoViewPrompt.js
+++ b/mobile/android/components/geckoview/GeckoViewPrompt.js
@@ -360,18 +360,17 @@ PromptDelegate.prototype = {
 
   _changeModalState: function(aEntering) {
     if (!this._domWin) {
       // Allow not having a DOM window.
       return true;
     }
     // Accessing the document object can throw if this window no longer exists. See bug 789888.
     try {
-      let winUtils = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                                 .getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = this._domWin.windowUtils;
       if (!aEntering) {
         winUtils.leaveModalState();
       }
 
       let event = this._domWin.document.createEvent("Events");
       event.initEvent(aEntering ? "DOMWillOpenModalDialog" : "DOMModalDialogClosed",
                       true, true);
       winUtils.dispatchEventToChromeOnly(this._domWin, event);
--- a/mobile/android/modules/geckoview/GeckoViewContent.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContent.jsm
@@ -120,23 +120,21 @@ class GeckoViewContent extends GeckoView
   }
 
   // Message manager event handler.
   receiveMessage(aMsg) {
     debug `receiveMessage: ${aMsg.name}`;
 
     switch (aMsg.name) {
       case "GeckoView:DOMFullscreenExit":
-        this.window.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils)
+        this.window.windowUtils
                    .remoteFrameFullscreenReverted();
         break;
       case "GeckoView:DOMFullscreenRequest":
-        this.window.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIDOMWindowUtils)
+        this.window.windowUtils
                    .remoteFrameFullscreenChanged(aMsg.target);
         break;
       case "GeckoView:SaveStateFinish":
         if (!this._saveStateCallbacks || !this._saveStateCallbacks.has(aMsg.data.id)) {
           warn `Failed to save state due to missing callback`;
           return;
         }
 
--- a/mobile/android/tests/browser/chrome/test_awsy_lite.html
+++ b/mobile/android/tests/browser/chrome/test_awsy_lite.html
@@ -54,17 +54,17 @@
     },
 
     onCloseWindow: function(aWindow) {
         detachFrom(aWindow);
     },
   };
 
   function doFullGc(aCallback, aIterations) {
-    var domWindowUtils = gWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    var domWindowUtils = gWindow.windowUtils;
 
     function runSoon(f) {
         Services.tm.dispatchToMainThread({ run: f });
     }
 
     function cc() {
         if (domWindowUtils.cycleCollect) {
             domWindowUtils.cycleCollect();
--- a/mobile/android/tests/browser/chrome/test_session_scroll_position.html
+++ b/mobile/android/tests/browser/chrome/test_session_scroll_position.html
@@ -55,19 +55,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   function setScrollPosition(browser, x, y) {
     browser.contentWindow.scrollTo(x, y);
     dispatchUIEvent(browser, "scroll");
   }
 
   function setZoomLevel(browser, zoom) {
-    browser.contentWindow.QueryInterface(
-      Ci.nsIInterfaceRequestor).getInterface(
-        Ci.nsIDOMWindowUtils).setResolutionAndScaleTo(zoom);
+    browser.contentWindow.windowUtils.setResolutionAndScaleTo(zoom);
   }
 
   // Track the tabs where the tests are happening.
   let tabScroll;
 
   function cleanupTabs() {
     if (tabScroll) {
       BrowserApp.closeTab(tabScroll);
@@ -90,18 +88,17 @@ https://bugzilla.mozilla.org/show_bug.cg
         let browser = tabScroll.browser;
         yield promiseBrowserEvent(browser, "AboutReaderContentReady");
 
         // Modify scroll position.
         setScrollPosition(browser, 0, SCROLL_Y);
         yield promiseTabEvent(browser, "SSTabScrollCaptured");
 
         // Check that we've actually scrolled.
-        let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
-        let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
+        let utils = browser.contentWindow.windowUtils;
         let scrollX = {}, scrollY = {};
         utils.getScrollXY(false, scrollX, scrollY);
         is(scrollX.value, 0, "scrollX set correctly");
         is(scrollY.value, SCROLL_Y, "scrollY set correctly");
 
         // Remove the tab.
         BrowserApp.closeTab(tabScroll);
         yield promiseTabEvent(browser, "SSTabCloseProcessed");
@@ -114,18 +111,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     is(scrolldata.scroll, SCROLL_STR_Y_ONLY, "stored scroll position is correct");
 
     // Restore the closed tab.
     let closedTabData = ss.getClosedTabs(chromeWin)[0];
     let browser = ss.undoCloseTab(chromeWin, closedTabData);
     await promiseBrowserEvent(browser, "AboutReaderContentReady");
 
     // Check the scroll position.
-    let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
-    let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
+    let utils = browser.contentWindow.windowUtils;
     let scrollX = {}, scrollY = {};
     utils.getScrollXY(false, scrollX, scrollY);
     is(scrollX.value, 0, "scrollX restored correctly");
     is(scrollY.value, SCROLL_Y, "scrollY restored correctly");
 
     // Remove the tab.
     BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
   });
@@ -140,18 +136,17 @@ https://bugzilla.mozilla.org/show_bug.cg
         yield promiseBrowserEvent(browser, "pageshow");
 
         // Modify scroll position and zoom level.
         setZoomLevel(browser, ZOOM);
         setScrollPosition(browser, SCROLL_X, SCROLL_Y);
         yield promiseTabEvent(browser, "SSTabScrollCaptured");
 
         // Check that we've actually scrolled and zoomed.
-        let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
-        let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
+        let utils = browser.contentWindow.windowUtils;
         let scrollX = {}, scrollY = {}, zoom = {};
         utils.getResolution(zoom);
         utils.getScrollXY(false, scrollX, scrollY);
         ok(fuzzyEquals(zoom.value, ZOOM), "zoom set correctly");
         is(scrollX.value, SCROLL_X, "scrollX set correctly");
         is(scrollY.value, SCROLL_Y, "scrollY set correctly");
 
         // Navigate to a different page and scroll/zoom there as well.
@@ -184,18 +179,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     let closedTabData = ss.getClosedTabs(chromeWin)[0];
     let browser = ss.undoCloseTab(chromeWin, closedTabData);
     let pageshow = promiseBrowserEvent(browser, "pageshow");
     let scroll = promiseBrowserEvent(browser, "scroll");
     await pageshow;
     await scroll;
 
     // Check the scroll position and zoom level.
-    let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
-    let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
+    let utils = browser.contentWindow.windowUtils;
     let scrollX = {}, scrollY = {}, zoom = {};
     utils.getResolution(zoom);
     utils.getScrollXY(false, scrollX, scrollY);
     ok(fuzzyEquals(zoom.value, ZOOM2), "zoom restored correctly");
     is(scrollX.value, SCROLL2_X, "scrollX restored correctly");
     is(scrollY.value, SCROLL2_Y, "scrollY restored correctly");
 
     // Now go back in history and check that the scroll position
@@ -227,18 +221,17 @@ https://bugzilla.mozilla.org/show_bug.cg
         yield promiseBrowserEvent(browser, "pageshow");
 
         // Modify scroll position and zoom level.
         setZoomLevel(browser, ZOOM);
         setScrollPosition(browser, SCROLL_X, SCROLL_Y);
         yield promiseTabEvent(browser, "SSTabScrollCaptured");
 
         // Check that we've actually scrolled and zoomed.
-        let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
-        let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
+        let utils = browser.contentWindow.windowUtils;
         let scrollX = {}, scrollY = {}, zoom = {};
         utils.getResolution(zoom);
         utils.getScrollXY(false, scrollX, scrollY);
         ok(fuzzyEquals(zoom.value, ZOOM), "zoom set correctly");
         is(scrollX.value, SCROLL_X, "scrollX set correctly");
         is(scrollY.value, SCROLL_Y, "scrollY set correctly");
 
         // Remove the tab.
@@ -260,18 +253,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     closedTabData.scrolldata.zoom.displaySize.width = displayHeight;
     closedTabData.scrolldata.zoom.displaySize.height = displayWidth;
 
     // Restore the closed tab.
     let browser = ss.undoCloseTab(chromeWin, closedTabData);
     await promiseBrowserEvent(browser, "pageshow");
 
     // Check the scroll position and zoom level.
-    let ifreq = browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
-    let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
+    let utils = browser.contentWindow.windowUtils;
     let scrollX = {}, scrollY = {}, zoom = {};
     utils.getResolution(zoom);
     utils.getScrollXY(false, scrollX, scrollY);
     ok(fuzzyEquals(zoom.value, ZOOM * displayWidth / displayHeight), "recalculated zoom restored correctly");
     is(scrollX.value, SCROLL_X, "scrollX restored correctly");
     is(scrollY.value, SCROLL_Y, "scrollY restored correctly");
 
     // Remove the tab.
--- a/mobile/android/tests/browser/robocop/testAccessibleCarets.js
+++ b/mobile/android/tests/browser/robocop/testAccessibleCarets.js
@@ -104,18 +104,17 @@ function getCharPressPoint(doc, element,
 /**
  * Long press an element (RTL/LTR) at its calculated first character
  * position, and return the result.
  *
  * @param midPoint, The screen coord for the longpress.
  * @return Selection state helper-result object.
  */
 function getLongPressResult(browser, midPoint) {
-  let domWinUtils = browser.contentWindow.
-    QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+  let domWinUtils = browser.contentWindow.windowUtils;
 
   // AccessibleCarets expect longtap between touchstart/end.
   domWinUtils.sendTouchEventToWindow("touchstart", [0], [midPoint.x], [midPoint.y],
                                      [1], [1], [0], [1], 1, 0);
   domWinUtils.sendMouseEventToWindow("mouselongtap", midPoint.x, midPoint.y,
                                      0, 1, 0);
   domWinUtils.sendTouchEventToWindow("touchend", [0], [midPoint.x], [midPoint.y],
                                      [1], [1], [0], [1], 1, 0);