Bug 1446940 part 5. Stop getting docshells from windows via getInterface in dom/editor/etc code. r=kmag
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 01 Aug 2018 13:07:11 -0400
changeset 484793 3b1489be7f57607ec39de27f4bc9b4770d569109
parent 484792 f5a747a896fc23b76715acc50b03aceb8f9ed09f
child 484794 9873d9aa413f1224247466ccc6943b53912f6f23
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1446940
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 1446940 part 5. Stop getting docshells from windows via getInterface in dom/editor/etc code. r=kmag
accessible/tests/mochitest/common.js
accessible/tests/mochitest/layout.js
caps/tests/mochitest/test_disableScript.xul
docshell/test/browser/browser_bug655273.js
docshell/test/browser/browser_bug673467.js
docshell/test/browser/browser_tab_touch_events.js
docshell/test/browser/frame-head.js
docshell/test/chrome/bug662200_window.xul
docshell/test/chrome/mozFrameType_window.xul
docshell/test/chrome/test_allowContentRetargeting.html
docshell/test/chrome/test_bug909218.html
docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul
docshell/test/navigation/NavigationUtils.js
docshell/test/navigation/browser_bug343515.js
docshell/test/navigation/browser_test-content-chromeflags.js
docshell/test/navigation/file_bug1300461.html
docshell/test/navigation/file_bug1300461_back.html
docshell/test/navigation/file_bug1326251.html
docshell/test/navigation/file_bug1326251_evict_cache.html
docshell/test/navigation/test_bug1375833.html
docshell/test/test_bug509055.html
docshell/test/test_bug590573.html
dom/animation/test/mozilla/file_restyles.html
dom/base/test/browser_promiseDocumentFlushed.js
dom/base/test/chrome/file_bug1209621.xul
dom/base/test/chrome/file_bug549682.xul
dom/base/test/chrome/test_bug1339722.html
dom/base/test/copypaste.js
dom/base/test/test_bug1101364.html
dom/base/test/test_bug166235.html
dom/base/test/test_copyimage.html
dom/base/test/test_copypaste.xul
dom/base/test/test_postMessage_originAttributes.html
dom/browser-element/BrowserElementChildPreload.js
dom/browser-element/BrowserElementCopyPaste.js
dom/events/test/test_bug1412775.xul
dom/events/test/test_paste_image.html
dom/html/test/browser_bug649778.js
dom/html/test/test_bug460568.html
dom/html/test/test_bug512367.html
dom/ipc/remote-test.js
dom/ipc/tests/test_child_docshell.html
dom/serviceworkers/test/test_devtools_bypass_serviceworker.html
dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html
dom/tests/mochitest/ajax/offline/offlineTests.js
dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html
dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html
dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html
dom/tests/mochitest/general/test_innerScreen.xul
dom/tests/mochitest/whatwg/test_bug500328.html
dom/websocket/tests/websocket_tests.js
editor/AsyncSpellCheckTestHelper.jsm
editor/composer/test/test_bug1266815.html
editor/composer/test/test_bug519928.html
editor/libeditor/tests/test_CF_HTML_clipboard.html
editor/libeditor/tests/test_bug1100966.html
editor/libeditor/tests/test_bug1140105.html
editor/libeditor/tests/test_bug1154791.html
editor/libeditor/tests/test_bug1186799.html
editor/libeditor/tests/test_bug1230473.html
editor/libeditor/tests/test_bug1268736.html
editor/libeditor/tests/test_bug1330796.html
editor/libeditor/tests/test_bug1397412.xul
editor/libeditor/tests/test_bug366682.html
editor/libeditor/tests/test_bug432225.html
editor/libeditor/tests/test_bug484181.html
editor/libeditor/tests/test_bug489202.xul
editor/libeditor/tests/test_bug520189.html
editor/libeditor/tests/test_bug525389.html
editor/libeditor/tests/test_bug596333.html
editor/libeditor/tests/test_bug790475.html
editor/libeditor/tests/test_bug857487.html
editor/libeditor/tests/test_bug974309.html
editor/libeditor/tests/test_contenteditable_focus.html
editor/libeditor/tests/test_css_chrome_load_access.html
editor/libeditor/tests/test_documentCharacterSet.html
editor/libeditor/tests/test_htmleditor_keyevent_handling.html
editor/libeditor/tests/test_root_element_replacement.html
editor/spellchecker/tests/test_bug1205983.html
editor/spellchecker/tests/test_bug1219928.html
gfx/tests/browser/browser_windowless_troubleshoot_crash.js
layout/base/tests/chrome/bug1041200_window.html
layout/base/tests/chrome/file_bug1018265.xul
layout/base/tests/chrome/test_bug396367-1.html
layout/base/tests/chrome/test_bug396367-2.html
layout/base/tests/chrome/test_bug420499.xul
layout/base/tests/chrome/test_bug514660.xul
layout/base/tests/chrome/test_bug708062.html
layout/base/tests/test_bug449781.html
layout/generic/test/frame_selection_underline-ref.xhtml
layout/generic/test/frame_selection_underline.xhtml
layout/generic/test/test_bug263683.html
layout/generic/test/test_selection_touchevents.html
layout/mathml/crashtests/400157.xhtml
layout/style/test/chrome/test_display_mode.html
layout/style/test/test_restyles_in_smil_animation.html
layout/xul/test/test_popupZoom.xul
security/manager/ssl/tests/mochitest/mixedcontent/backward.html
security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
testing/marionette/listener.js
testing/mochitest/browser-test.js
testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html
testing/specialpowers/content/specialpowersAPI.js
testing/talos/talos/tests/cpstartup/content/cpstartup.html
testing/talos/talos/tests/tabpaint/content/tabpaint.html
testing/talos/talos/tests/tabpaint/content/target.html
uriloader/exthandler/tests/mochitest/handlerApps.js
widget/nsITransferable.idl
widget/tests/test_bug444800.xul
widget/tests/test_bug466599.xul
widget/tests/test_bug565392.html
widget/tests/test_bug673301.xul
widget/tests/test_bug760802.xul
widget/tests/test_clipboard.xul
widget/tests/test_imestate.html
widget/tests/test_keycodes.xul
widget/tests/window_composition_text_querycontent.xul
widget/tests/window_imestate_iframes.html
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -707,19 +707,17 @@ function eventTypeToString(aEventType) {
 /**
  * Convert relation type to human readable string.
  */
 function relationTypeToString(aRelationType) {
   return gAccService.getStringRelationType(aRelationType);
 }
 
 function getLoadContext() {
-  return window.QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 /**
  * Return text from clipboard.
  */
 function getTextFromClipboard() {
   var trans = Cc["@mozilla.org/widget/transferable;1"].
     createInstance(Ci.nsITransferable);
--- a/accessible/tests/mochitest/layout.js
+++ b/accessible/tests/mochitest/layout.js
@@ -54,20 +54,17 @@ function testOffsetAtPoint(aHyperTextID,
      "Wrong offset at given point (" + aX + ", " + aY + ") for " +
      prettyName(aHyperTextID));
 }
 
 /**
  * Zoom the given document.
  */
 function zoomDocument(aDocument, aZoom) {
-  var docShell = aDocument.defaultView.
-    QueryInterface(Ci.nsIInterfaceRequestor).
-    getInterface(Ci.nsIWebNavigation).
-    QueryInterface(Ci.nsIDocShell);
+  var docShell = aDocument.defaultView.docShell;
   var docViewer = docShell.contentViewer;
 
   docViewer.fullZoom = aZoom;
 }
 
 /**
  * Set the relative resolution of this document. This is what apz does.
  * On non-mobile platforms you won't see a visible change.
--- a/caps/tests/mochitest/test_disableScript.xul
+++ b/caps/tests/mochitest/test_disableScript.xul
@@ -46,21 +46,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     });
   }
 
   function navigateBack(ifr) {
     return new Promise(resolve => {
 
       // pageshow events don't fire on the iframe element, so we need to use the
       // chrome event handler for the docshell.
-      var browser = ifr.contentWindow
-                       .QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIWebNavigation)
-                       .QueryInterface(Ci.nsIDocShell)
-                       .chromeEventHandler;
+      var browser = ifr.contentWindow.docShell.chromeEventHandler;
       function onpageshow(evt) {
         info("Navigated back. Persisted: " + evt.persisted);
         browser.removeEventListener('pageshow', onpageshow);
         resolve();
       }
       browser.addEventListener('pageshow', onpageshow, false);
       ifr.contentWindow.history.back();
     });
@@ -84,19 +80,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   function checkScriptEnabled(win, expectEnabled) {
     win.wrappedJSObject.gFiredOnclick = false;
     win.document.body.dispatchEvent(new win.Event('click'));
     is(win.wrappedJSObject.gFiredOnclick, expectEnabled, "Checking script-enabled for " + win.name + " (" + win.location + ")");
   }
 
   function setScriptEnabledForDocShell(win, enabled) {
-    win.QueryInterface(Ci.nsIInterfaceRequestor)
-       .getInterface(Ci.nsIDocShell)
-       .allowJavascript = enabled;
+    win.docShell.allowJavascript = enabled;
   }
 
   function testList(expectEnabled, win, list, idx) {
     idx = idx || 0;
     return new Promise(resolve => {
       let target = list[idx] + path;
       info("Testing scriptability for: " + target + ". expecting " + expectEnabled);
       navigateFrame(win.frameElement, target).then(function() {
--- a/docshell/test/browser/browser_bug655273.js
+++ b/docshell/test/browser/browser_bug655273.js
@@ -14,17 +14,17 @@ add_task(async function test() {
   await BrowserTestUtils.withNewTab({ gBrowser, url: "http://example.com" },
     async function(browser) {
       await ContentTask.spawn(browser, null, async function() {
         let cw = content;
         let oldTitle = cw.document.title;
         ok(oldTitle, 'Content window should initially have a title.');
         cw.history.pushState('', '', 'new_page');
 
-        let shistory = cw.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation)
+        let shistory = cw.docShell
+                         .QueryInterface(Ci.nsIWebNavigation)
                          .sessionHistory;
 
         is(shistory.legacySHistory.getEntryAtIndex(shistory.index, false).title,
            oldTitle, 'SHEntry title after pushstate.');
       });
     });
 });
--- a/docshell/test/browser/browser_bug673467.js
+++ b/docshell/test/browser/browser_bug673467.js
@@ -29,19 +29,18 @@ function test() {
           let iframe = content.document.getElementById('iframe');
           iframe.addEventListener('load', function listener(aEvent) {
 
             // Wait for the iframe to load the new document, not about:blank.
             if (!iframe.src)
               return;
 
             iframe.removeEventListener('load', listener, true);
-            let shistory = content
-                            .QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIWebNavigation)
+            let shistory = content.docShell
+                            .QueryInterface(Ci.nsIWebNavigation)
                             .sessionHistory;
 
             Assert.equal(shistory.count, 1, "shistory count should be 1.");
             resolve();
           }, true);
         }, true);
       });
     });
--- a/docshell/test/browser/browser_tab_touch_events.js
+++ b/docshell/test/browser/browser_tab_touch_events.js
@@ -17,33 +17,27 @@ async function test_body() {
   is(docshell.touchEventsOverride, Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_NONE,
     "touchEventsOverride flag should be initially set to NONE");
 
   docshell.touchEventsOverride = Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_DISABLED;
   is(docshell.touchEventsOverride, Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_DISABLED,
     "touchEventsOverride flag should be changed to DISABLED");
 
   let frameWin = content.document.querySelector("#test-iframe").contentWindow;
-  docshell = frameWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                     .getInterface(Ci.nsIWebNavigation)
-                     .QueryInterface(Ci.nsIDocShell);
+  docshell = frameWin.docShell;
   is(docshell.touchEventsOverride, Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_DISABLED,
     "touchEventsOverride flag should be passed on to frames.");
 
   let newFrame = content.document.createElement("iframe");
   content.document.body.appendChild(newFrame);
 
   let newFrameWin = newFrame.contentWindow;
-  docshell = newFrameWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIDocShell);
+  docshell = newFrameWin.docShell;
   is(docshell.touchEventsOverride, Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_DISABLED,
     "Newly created frames should use the new touchEventsOverride flag");
 
   newFrameWin.location.reload();
   await ContentTaskUtils.waitForEvent(newFrameWin, "load");
 
-  docshell = newFrameWin.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIDocShell);
+  docshell = newFrameWin.docShell;
   is(docshell.touchEventsOverride, Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_DISABLED,
     "New touchEventsOverride flag should persist across reloads");
 }
--- a/docshell/test/browser/frame-head.js
+++ b/docshell/test/browser/frame-head.js
@@ -42,19 +42,17 @@ this.finish = function() {
  *             true.
  *        setup is a function that takes the docshell as an argument.
  *             It should start the test.
  *        check is a function that takes an array of markers
  *             as an argument and checks the results of the test.
  */
 this.timelineContentTest = function(tests) {
   (async function() {
-    let docShell = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIWebNavigation)
-                          .QueryInterface(Ci.nsIDocShell);
+    let docShell = content.docShell;
 
     info("Start recording");
     docShell.recordProfileTimelineMarkers = true;
 
     for (let {desc, searchFor, setup, check} of tests) {
 
       info("Running test: " + desc);
 
--- a/docshell/test/chrome/bug662200_window.xul
+++ b/docshell/test/chrome/bug662200_window.xul
@@ -82,22 +82,20 @@
                            title: "C"},
                           {type: "pageshow", 
                            title: "B"} ],
         onNavComplete: nextTest
       };
       doPageNavigation(navData);
       yield undefined;
 
-      var docshell = TestWindow.getWindow()
-                               .QueryInterface(Ci.nsIInterfaceRequestor)
-                               .getInterface(Ci.nsIWebNavigation)
-                               .QueryInterface(Ci.nsIDocShell);
-      var shistory = docshell.QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsISHistory)
+      var docshell = TestWindow.getWindow().docShell;
+      var shistory = docshell.QueryInterface(Ci.nsIWebNavigation)
+                             .sessionHistory
+                             .legacySHistory
                              .QueryInterface(Ci.nsIWebNavigation);
 
       // Reload.
       navData = {
         eventsToListenFor: ["pageshow", "pagehide"],
         expectedEvents: [ {type: "pagehide", 
                            title: "B"},
                           {type: "pageshow", 
--- a/docshell/test/chrome/mozFrameType_window.xul
+++ b/docshell/test/chrome/mozFrameType_window.xul
@@ -11,20 +11,17 @@
 
   <script type="application/javascript" src="docshell_helpers.js" />
   <script type="application/javascript"><![CDATA[
     function runTests() {
       let opener = window.opener;
       let SimpleTest = opener.wrappedJSObject.SimpleTest;
 
       function getDocShellType(frame) {
-        return frame.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                  .getInterface(Ci.nsIDocShell)
-                                  .QueryInterface(Ci.nsIDocShellTreeItem)
-                                  .itemType;
+        return frame.contentWindow.docShell.itemType;
       }
 
       var normalFrame = document.getElementById("normalFrame");
       var typeContentFrame = document.getElementById("typeContentFrame");
 
       SimpleTest.is(getDocShellType(normalFrame), Ci.nsIDocShellTreeItem.typeChrome,
                     "normal iframe in chrome document is typeChrome");
       SimpleTest.is(getDocShellType(typeContentFrame), Ci.nsIDocShellTreeItem.typeContent,
--- a/docshell/test/chrome/test_allowContentRetargeting.html
+++ b/docshell/test/chrome/test_allowContentRetargeting.html
@@ -21,45 +21,38 @@ function runNextTest() {
 }
 
 var tests = [
 
   // Set allowContentRetargeting = false, load a downloadable URL, verify the
   // downloadable stops loading.
   function basic() {
     var iframe = insertIframe();
-    docshellForWindow(iframe.contentWindow).allowContentRetargeting = false;
+    iframe.contentWindow.docShell.allowContentRetargeting = false;
     loadIframe(iframe);
   },
 
   // Set allowContentRetargeting = false on parent docshell, load a downloadable
   // URL, verify the downloadable stops loading.
   function inherit() {
-    var docshell = docshellForWindow(window);
+    var docshell = window.docShell;
     docshell.allowContentRetargeting = false;
     loadIframe(insertIframe());
   },
 ];
 
-function docshellForWindow(win) {
-  return win.
-         QueryInterface(Ci.nsIInterfaceRequestor).
-         getInterface(Ci.nsIWebNavigation).
-         QueryInterface(Ci.nsIDocShell);
-}
-
 function insertIframe() {
   var iframe = document.createElement("iframe");
   document.body.appendChild(iframe);
   return iframe;
 }
 
 function loadIframe(iframe) {
   iframe.setAttribute("src", TEST_URL);
-  docshellForWindow(iframe.contentWindow).
+  iframe.contentWindow.docShell.
     QueryInterface(Ci.nsIInterfaceRequestor).
     getInterface(Ci.nsIWebProgress).
     addProgressListener(progressListener,
                         Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
 }
 
 var progressListener = {
   onStateChange: function (webProgress, req, flags, status) {
--- a/docshell/test/chrome/test_bug909218.html
+++ b/docshell/test/chrome/test_bug909218.html
@@ -25,17 +25,17 @@ var TEST_URL = "http://mochi.test:8888/c
 // The test entry-point.  The basic outline is:
 // * Create an iframe and set defaultLoadFlags on its docShell.
 // * Add a web progress listener to observe each request as the iframe is
 //   loaded, and check that each request has the flags we specified.
 // * Load our test URL into the iframe and wait for the load to complete.
 function test() {
   var iframe = document.createElement("iframe");
   document.body.appendChild(iframe);
-  var docShell = docshellForWindow(iframe.contentWindow);
+  var docShell = iframe.contentWindow.docShell;
   // Add our progress listener - when it notices the top-level document is
   // complete, the test will end.
   RequestWatcher.init(docShell, SimpleTest.finish);
   // Set the flags we care about, then load our test URL.
   docShell.defaultLoadFlags = TEST_FLAGS;
   iframe.setAttribute("src", TEST_URL);
 }
 
@@ -110,18 +110,11 @@ RequestWatcher = {
     }
   },
   QueryInterface: ChromeUtils.generateQI([
     Ci.nsIWebProgressListener,
     Ci.nsISupportsWeakReference,
   ])
 }
 
-function docshellForWindow(win) {
-  return win.
-         QueryInterface(Ci.nsIInterfaceRequestor).
-         getInterface(Ci.nsIWebNavigation).
-         QueryInterface(Ci.nsIDocShell);
-}
-
 </script>
 </head>
 </html>
--- a/docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul
+++ b/docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul
@@ -58,18 +58,17 @@ https://bugzilla.mozilla.org/show_bug.cg
           var errorMsg = matchArray[1];
           resolve(decodeURIComponent(errorMsg));
         },
 
         QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
                                                 Ci.nsISupportsWeakReference])
       };
 
-      frame.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation)
+      frame.contentWindow.docShell
                          .QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIWebProgress)
                          .addProgressListener(progressListener,
                                               Ci.nsIWebProgress.NOTIFY_LOCATION |
                                               Ci.nsIWebProgress.NOTIFY_STATE_REQUEST);
     });
   }
 
--- a/docshell/test/navigation/NavigationUtils.js
+++ b/docshell/test/navigation/NavigationUtils.js
@@ -104,19 +104,17 @@ function xpcEnumerateContentWindows(call
                         .getService(Ci.nsIWindowWatcher);
   var enumerator = ww.getWindowEnumerator();
 
   var contentWindows = [];
 
   while (enumerator.hasMoreElements()) {
     var win = enumerator.getNext();
     if (win.isChromeWindow) {
-      var docshellTreeNode = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                                .getInterface(Ci.nsIWebNavigation)
-                                .QueryInterface(Ci.nsIDocShellTreeItem);
+      var docshellTreeNode = win.docShell;
       var childCount = docshellTreeNode.childCount;
       for (var i = 0; i < childCount; ++i) {
         var childTreeNode = docshellTreeNode.getChildAt(i);
 
         // we're only interested in content docshells
         if (SpecialPowers.unwrap(childTreeNode.itemType) != Ci.nsIDocShellTreeItem.typeContent)
           continue;
 
--- a/docshell/test/navigation/browser_bug343515.js
+++ b/docshell/test/navigation/browser_bug343515.js
@@ -90,19 +90,17 @@ function step3() {
   ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
 
   // Tab 2's window _and_ its iframes should be inactive
   ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
   ContentTask.spawn(ctx.tab2Browser, null, async function() {
     Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes");
     for (var i = 0; i < content.frames.length; i++) {
       info("step 3, frame " + i + " info: " + content.frames[i].location);
-      let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor)
-                                      .getInterface(Ci.nsIWebNavigation)
-                                      .QueryInterface(Ci.nsIDocShell);
+      let docshell = content.frames[i].docShell;
 
       Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
     }
   }).then(() => {
     // Navigate tab 2 to a different page
     ctx.tab2Browser.loadURI(testPath + "bug343515_pg3.html");
 
     // bug343515_pg3.html consists of a page with two iframes, one of which
@@ -110,19 +108,17 @@ function step3() {
     nShotsListener(ctx.tab2Browser, "load", step4, 4);
   });
 }
 
 function step4() {
   function checkTab2Active(expected) {
     return ContentTask.spawn(ctx.tab2Browser, expected, async function(expected) {
       function isActive(aWindow) {
-        var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIWebNavigation)
-                              .QueryInterface(Ci.nsIDocShell);
+        var docshell = aWindow.docShell;
         return docshell.isActive;
       }
 
       let active = expected ? "active" : "inactive";
       Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes");
       for (var i = 0; i < content.frames.length; i++)
         info("step 4, frame " + i + " info: " + content.frames[i].location);
       Assert.equal(content.frames[0].frames.length, 1, "Tab 2 iframe 0 should have 1 iframes");
@@ -160,19 +156,17 @@ function step4() {
 
 function step5() {
   // Check everything
   ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
   ok(!ctx.tab1Browser.docShellIsActive, "Tab 1 should be inactive");
   ok(ctx.tab2Browser.docShellIsActive, "Tab 2 should be active");
   ContentTask.spawn(ctx.tab2Browser, null, async function() {
     for (var i = 0; i < content.frames.length; i++) {
-      let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor)
-                                      .getInterface(Ci.nsIWebNavigation)
-                                      .QueryInterface(Ci.nsIDocShell);
+      let docshell = content.frames[i].docShell;
 
       Assert.ok(docShell.isActive, `Tab2 iframe ${i} should be active`);
     }
   }).then(() => {
     // Switch to tab 1
     return BrowserTestUtils.switchTab(gBrowser, ctx.tab1);
   }).then(() => {
     // Navigate to page 3
@@ -186,51 +180,45 @@ function step5() {
 
 function step6() {
 
   // Check everything
   ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
   ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
   ContentTask.spawn(ctx.tab1Browser, null, async function() {
     function isActive(aWindow) {
-      var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIWebNavigation)
-                            .QueryInterface(Ci.nsIDocShell);
+      var docshell = aWindow.docShell;
       return docshell.isActive;
     }
 
     Assert.ok(isActive(content.frames[0]), "Tab1 iframe 0 should be active");
     Assert.ok(isActive(content.frames[0].frames[0]), "Tab1 iframe 0 subiframe 0 should be active");
     Assert.ok(isActive(content.frames[1]), "Tab1 iframe 1 should be active");
   }).then(() => {
     ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
     return ContentTask.spawn(ctx.tab2Browser, null, async function() {
       for (var i = 0; i < content.frames.length; i++) {
-        let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor)
-                                        .getInterface(Ci.nsIWebNavigation)
-                                        .QueryInterface(Ci.nsIDocShell);
+        let docshell = content.frames[i].docShell;
 
         Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
       }
     });
   }).then(() => {
     // Go forward on tab 2
     waitForPageshow(ctx.tab2Browser, step7);
     ctx.tab2Browser.goForward();
   });
 }
 
 function step7() {
   function checkBrowser(browser, tabNum, active) {
     return ContentTask.spawn(browser, { tabNum, active },
                              async function({ tabNum, active }) {
              function isActive(aWindow) {
-               var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                     .getInterface(Ci.nsIWebNavigation)
-                                     .QueryInterface(Ci.nsIDocShell);
+               var docshell = aWindow.docShell;
                return docshell.isActive;
              }
 
              let activestr = active ? "active" : "inactive";
              Assert.equal(isActive(content.frames[0]), active,
                 `Tab${tabNum} iframe 0 should be ${activestr}`);
              Assert.equal(isActive(content.frames[0].frames[0]), active,
                 `Tab${tabNum} iframe 0 subiframe 0 should be ${activestr}`);
--- a/docshell/test/navigation/browser_test-content-chromeflags.js
+++ b/docshell/test/navigation/browser_test-content-chromeflags.js
@@ -20,19 +20,17 @@ add_task(async function() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: TEST_PAGE
   }, async function(browser) {
     let openedPromise = BrowserTestUtils.waitForNewWindow();
     BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, browser);
     let win = await openedPromise;
 
-    let chromeFlags = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation)
-                         .QueryInterface(Ci.nsIDocShellTreeItem)
+    let chromeFlags = win.docShell
                          .treeOwner
                          .QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIXULWindow)
                          .chromeFlags;
 
     // In the multi-process case, the new window will have the
     // CHROME_REMOTE_WINDOW flag set.
     const EXPECTED = gMultiProcessBrowser ? CHROME_ALL | CHROME_REMOTE_WINDOW
--- a/docshell/test/navigation/file_bug1300461.html
+++ b/docshell/test/navigation/file_bug1300461.html
@@ -20,18 +20,18 @@
        * 4) file_bug1300461_redirect.html redirects UA to
        *    file_bug1300461_back.html through HTTP 301 header.
        *
        * We verify the history index, canGoBack, canGoForward, etc. keep correct
        * in this process.
        */
       let Ci = SpecialPowers.Ci;
       let webNav = SpecialPowers.wrap(window)
-                     .QueryInterface(Ci.nsIInterfaceRequestor)
-                     .getInterface(Ci.nsIWebNavigation);
+                     .docShell
+                     .QueryInterface(Ci.nsIWebNavigation);
       let shistory = webNav.sessionHistory;
       let testSteps = [
         function() {
           opener.is(shistory.count, 1, 'check history length');
           opener.is(shistory.index, 0, 'check history index');
           opener.ok(!webNav.canGoForward, 'check canGoForward');
           setTimeout(() => window.location = 'file_bug1300461_back.html', 0);
         },
--- a/docshell/test/navigation/file_bug1300461_back.html
+++ b/docshell/test/navigation/file_bug1300461_back.html
@@ -4,18 +4,18 @@
     <meta http-equiv="content-type" content="text/html; charset=utf-8">
     <title>Bug 1300461</title>
   </head>
   <!-- The empty unload handler is to prevent bfcache. -->
   <body onload="test();" onunload="">
     <script>
       let Ci = SpecialPowers.Ci;
       let webNav = SpecialPowers.wrap(window)
-                     .QueryInterface(Ci.nsIInterfaceRequestor)
-                     .getInterface(Ci.nsIWebNavigation);
+                     .docShell
+                     .QueryInterface(Ci.nsIWebNavigation);
       let shistory = webNav.sessionHistory;
       function test() {
         if (opener) {
           opener.info("file_bug1300461_back.html");
           opener.is(shistory.count, 2, 'check history length');
           opener.is(shistory.index, 1, 'check history index');
           opener.is(shistory.legacySHistory.requestedIndex, -1, 'check requestedIndex');
           opener.ok(webNav.canGoBack, 'check canGoBack');
--- a/docshell/test/navigation/file_bug1326251.html
+++ b/docshell/test/navigation/file_bug1326251.html
@@ -17,18 +17,18 @@
         await loadUriInFrame(document.getElementById('dynamicFrame'), 'frame1.html');
         await loadUriInFrame(document.getElementById('staticFrame'), 'frame2.html');
         await loadUriInFrame(document.getElementById('dynamicFrame'), 'frame2.html');
         opener.is(history.length, 5, 'history.length');
         window.location = 'goback.html';
       },
       async function() {
         let webNav = SpecialPowers.wrap(window)
-                       .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                       .getInterface(SpecialPowers.Ci.nsIWebNavigation);
+                       .docShell
+                       .QueryInterface(SpecialPowers.Ci.nsIWebNavigation);
         let shistory = webNav.sessionHistory;
         opener.is(webNav.canGoForward, true, 'canGoForward');
         opener.is(shistory.index, 4, 'shistory.index');
         opener.is(history.length, 6, 'history.length');
         opener.is(document.getElementById('staticFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'staticFrame location');
         opener.is(document.getElementById('dynamicFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'dynamicFrame location');
 
         // Test 2: Load another page in dynamic iframe, canGoForward should be
@@ -39,21 +39,20 @@
         opener.is(history.length, 6, 'history.length');
 
         // Test 3: Navigate to antoher page with bfcache disabled, all dynamic
         // iframe entries should be removed.
         window.onunload = function(){}; // disable bfcache
         window.location = 'goback.html';
       },
       async function() {
-        let windowWrap = SpecialPowers.wrap(window)
-                         .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor);
-        let docShell = windowWrap.getInterface(SpecialPowers.Ci.nsIDocShell);
-        let shistory = windowWrap.getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                                 .sessionHistory;
+        let windowWrap = SpecialPowers.wrap(window);
+        let docShell = windowWrap.docShell;
+        let shistory = docShell.QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
+                               .sessionHistory;
         // Now staticFrame has frame0 -> frame1 -> frame2.
         opener.is(docShell.previousTransIndex, 3, 'docShell.previousTransIndex');
         opener.is(docShell.loadedTransIndex, 2, 'docShell.loadedTransIndex');
         opener.is(shistory.index, 2, 'shistory.index');
         opener.is(history.length, 4, 'history.length');
         opener.is(document.getElementById('staticFrame').contentWindow.location.href, BASE_URL + 'frame2.html', 'staticFrame location');
         opener.ok(!document.getElementById('dynamicFrame'), 'dynamicFrame should not exist');
 
@@ -99,21 +98,20 @@
         // staticFrame:       frame0 -> frame1 -> frame2 -> iframe_static
         // innerStaticFrame:                                frame0        -> frame1
         // innerDynamicFrame:                                                frame2 -> frame3
         opener.is(shistory.index, 5, 'shistory.index');
         opener.is(history.length, 6, 'history.length');
         window.location = 'file_bug1326251_evict_cache.html';
       },
       async function() {
-        let windowWrap = SpecialPowers.wrap(window)
-                         .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor);
-        let docShell = windowWrap.getInterface(SpecialPowers.Ci.nsIDocShell);
-        let shistory = windowWrap.getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                                 .sessionHistory;
+        let windowWrap = SpecialPowers.wrap(window);
+        let docShell = windowWrap.docShell;
+        let shistory = docShell.QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
+                               .sessionHistory;
         // staticFrame:       frame0 -> frame1 -> frame2 -> iframe_static
         // innerStaticFrame:                                frame0        -> frame1
         opener.is(docShell.previousTransIndex, 5, 'docShell.previousTransIndex');
         opener.is(docShell.loadedTransIndex, 4, 'docShell.loadedTransIndex');
         opener.is(shistory.index, 4, 'shistory.index');
         opener.is(history.length, 6, 'history.length');
         let staticFrame = document.getElementById('staticFrame');
         let innerStaticFrame = staticFrame.contentDocument.getElementById('staticFrame');
--- a/docshell/test/navigation/file_bug1326251_evict_cache.html
+++ b/docshell/test/navigation/file_bug1326251_evict_cache.html
@@ -4,18 +4,18 @@
     <meta charset="utf-8">
     <title>Bug 1326251</title>
     <script>
     SpecialPowers.Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 
     // Evict bfcache and then go back.
     async function evictCache() {
       let shistory = SpecialPowers.wrap(window)
-                       .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                       .getInterface(SpecialPowers.Ci.nsIWebNavigation)
+                       .docShell
+                       .QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
                        .sessionHistory;
       let shPrivate = shistory.legacySHistory.QueryInterface(SpecialPowers.Ci.nsISHistoryInternal);
       shPrivate.evictAllContentViewers();
       history.back();
     }
     </script>
   </head>
   <body onload="setTimeout(evictCache, 0);">
--- a/docshell/test/navigation/test_bug1375833.html
+++ b/docshell/test/navigation/test_bug1375833.html
@@ -24,18 +24,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   let webNav, shistory;
   let frameDocShellId;
   window.addEventListener("message", e => {
     switch (count++) {
     case 0:
       ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
 
       webNav = SpecialPowers.wrap(testWin)
-               .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-               .getInterface(SpecialPowers.Ci.nsIWebNavigation);
+               .docShell
+               .QueryInterface(SpecialPowers.Ci.nsIWebNavigation);
       shistory = webNav.sessionHistory;
       is(shistory.count, 2, "check history length");
       is(shistory.index, 1, "check history index");
 
       frameDocShellId = String(getFrameDocShell().historyID);
       ok(frameDocShellId, "sanity check for docshell ID");
 
       testWin.location.reload();
@@ -77,19 +77,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       is(shistory.index, 0, "check history index");
 
       testWin.close();
       SimpleTest.finish();
     }
   });
 
   function getFrameDocShell() {
-    return SpecialPowers.wrap(testWin.window[0])
-           .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-           .getInterface(SpecialPowers.Ci.nsIDocShell)
+    return SpecialPowers.wrap(testWin.window[0]).docShell;
   }
 
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1375833">Mozilla Bug 1375833</a>
 <p id="display"></p>
 <div id="content" style="display: none">
--- a/docshell/test/test_bug509055.html
+++ b/docshell/test/test_bug509055.html
@@ -66,18 +66,18 @@ function* runTest() {
   popup.document.title = "Changed";
 
   // Wait for listeners to be notified of the title change.
   shortWait();
   dump('Got second hashchange.  Spinning event loop.\n');
   yield undefined;
 
   var sh = SpecialPowers.wrap(popup)
-                        .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                        .getInterface(SpecialPowers.Ci.nsIWebNavigation)
+                        .docShell
+                        .QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
                         .sessionHistory;
 
   // Get the title of the inner popup's current SHEntry
   var sheTitle = sh.legacySHistory.getEntryAtIndex(sh.index, false).title;
   is(sheTitle, "Changed", "SHEntry's title should change when we change.");
 
   popup.close();
 
--- a/docshell/test/test_bug590573.html
+++ b/docshell/test/test_bug590573.html
@@ -91,18 +91,18 @@ function page2PageShow()
   }
   else {
     dump('Ignoring page2 pageshow.\n');
   }
 }
 
 function dumpSHistory(theWindow)
 {
-  let sh = SpecialPowers.wrap(theWindow).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                    .getInterface(SpecialPowers.Ci.nsIWebNavigation)
+  let sh = SpecialPowers.wrap(theWindow).docShell
+                    .QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
                     .sessionHistory;
   if (!sh) {
     dump(" window has no shistory.\n");
     return;
   }
 
   dump(" count: " + sh.count + "\n");
   dump(" index: " + sh.index + "\n");
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -55,21 +55,17 @@ body {
 }
 </style>
 </head>
 <body>
 <script>
 'use strict';
 
 function getDocShellForObservingRestylesForWindow(aWindow) {
-  const docShell =
-    SpecialPowers.wrap(aWindow)
-                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                 .QueryInterface(SpecialPowers.Ci.nsIDocShell);
+  const docShell = SpecialPowers.wrap(aWindow).docShell;
 
   docShell.recordProfileTimelineMarkers = true;
   docShell.popProfileTimelineMarkers();
 
   return docShell;
 }
 
 // Returns the animation restyle markers observed during |frameCount| refresh
--- a/dom/base/test/browser_promiseDocumentFlushed.js
+++ b/dom/base/test/browser_promiseDocumentFlushed.js
@@ -119,19 +119,17 @@ add_task(async function test_can_get_res
       reflow() {
         Assert.ok(false, "A reflow should not have occurred.");
       },
       reflowInterruptible() {},
       QueryInterface: ChromeUtils.generateQI([Ci.nsIReflowObserver,
                                               Ci.nsISupportsWeakReference])
     };
 
-    let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation)
-                         .QueryInterface(Ci.nsIDocShell);
+    let docShell = window.docShell;
     docShell.addWeakReflowObserver(observer);
 
     let toolboxRect = gNavToolbox.getBoundingClientRect();
 
     docShell.removeWeakReflowObserver(observer);
     return toolboxRect;
   });
 
@@ -152,18 +150,17 @@ add_task(async function test_can_get_res
  * tick, the promiseDocumentFlushed Promise is still resolved, and
  * the callback is still called.
  */
 add_task(async function test_resolved_in_window_close() {
   let win = await BrowserTestUtils.openNewBrowserWindow();
 
   await win.promiseDocumentFlushed(() => {});
 
-  let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                    .getInterface(Ci.nsIDocShell);
+  let docShell = win.docShell;
   docShell.contentViewer.pausePainting();
 
   win.gNavToolbox.style.padding = "5px";
 
   const EXPECTED = 1234;
   let promise = win.promiseDocumentFlushed(() => {
     // Despite the window not painting before closing, this
     // callback should be fired when the window gets torn
--- a/dom/base/test/chrome/file_bug1209621.xul
+++ b/dom/base/test/chrome/file_bug1209621.xul
@@ -15,17 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     opener.wrappedJSObject.ok(cond, msg);
   }
 
   function is(actual, expected, msg) {
     opener.wrappedJSObject.is(actual, expected, msg);
   }
 
   function run() {
-    var docshell = window.getInterface(Ci.nsIDocShell);
+    var docshell = window.docShell;
     ok(docshell, "Active window should have a DocShell");
     var treeOwner = docshell.treeOwner;
     ok(treeOwner, "Active docshell should have a TreeOwner!");
 
     is(treeOwner.primaryContentShell, null,
        "There shouldn't be primaryContentShell because no browser has primary=true.");
     is(treeOwner.primaryTabParent, null,
        "There shouldn't be primaryTabParent because no remote browser has primary=true.");
--- a/dom/base/test/chrome/file_bug549682.xul
+++ b/dom/base/test/chrome/file_bug549682.xul
@@ -135,21 +135,19 @@ https://bugzilla.mozilla.org/show_bug.cg
       sendAsyncMessage('weak', {});\
       sendAsyncMessage('weak', {});\
       sendAsyncMessage('weakdone', {});", false);
   }
 
   function run() {
     var localmm = document.getElementById('ifr').messageManager;
 
-    var wn = document.getElementById('ifr').contentWindow
-      .getInterface(Ci.nsIWebNavigation)
-      .QueryInterface(Ci.nsIInterfaceRequestor);
-    ok(wn, "Should have webnavigation");
-    var cfmm = wn.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager);
+    var docShell = document.getElementById('ifr').contentWindow.docShell;
+    ok(docShell, "Should have docshell");
+    var cfmm = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager);
     ok(cfmm, "Should have content messageManager");
 
     var didGetSyncMessage = false;
     function syncContinueTestFn() {
       didGetSyncMessage = true;
     }
     localmm.addMessageListener("syncContinueTest", syncContinueTestFn);
     cfmm.sendSyncMessage("syncContinueTest", {});
--- a/dom/base/test/chrome/test_bug1339722.html
+++ b/dom/base/test/chrome/test_bug1339722.html
@@ -29,19 +29,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       Services.obs.removeObserver(this, TOPIC);
 
       // Query window proxy so it triggers DOMWindowCreated.
       let channel = subject.QueryInterface(Ci.nsIHttpChannel);
       let win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy);
     }
   }, TOPIC);
 
-  let docShell = SpecialPowers.wrap(window)
-                              .QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIDocShell);
+  let docShell = SpecialPowers.wrap(window).docShell;
   docShell.chromeEventHandler.addEventListener('DOMWindowCreated', function handler(e) {
     docShell.chromeEventHandler.removeEventListener('DOMWindowCreated', handler);
     let iframe = document.getElementById('testFrame');
     is(e.target, iframe.contentDocument, 'verify event target');
 
     // Remove the iframe to cause frameloader destroy.
     iframe.remove();
     setTimeout($ => {
--- a/dom/base/test/copypaste.js
+++ b/dom/base/test/copypaste.js
@@ -19,29 +19,25 @@ function modifySelection(s) {
       e.remove();
       g.removeAllRanges();
       g.addRange(l);
   }, 0)
 }
 
 function getLoadContext() {
   var Ci = SpecialPowers.Ci;
-  return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
-                                   .getInterface(Ci.nsIWebNavigation)
+  return SpecialPowers.wrap(window).docShell
                                    .QueryInterface(Ci.nsILoadContext);
 }
 
 async function testCopyPaste (isXHTML) {
   var suppressUnicodeCheckIfHidden = !!isXHTML;
   var suppressHTMLCheck = !!isXHTML;
 
-  var webnav = SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                     .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-
-  var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(window).docShell;
 
   var documentViewer = docShell.contentViewer
                                .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
 
   var clipboard = SpecialPowers.Services.clipboard;
 
   var textarea = SpecialPowers.wrap(document.getElementById('input'));
 
--- a/dom/base/test/test_bug1101364.html
+++ b/dom/base/test/test_bug1101364.html
@@ -25,39 +25,34 @@ https://bugzilla.mozilla.org/show_bug.cg
 <iframe id="test2" srcdoc="<div contenteditable id='test2'>AAA<span id='test2Inner'>BBB</span></div>"></iframe>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function test()
 {
   var iframe1 = document.getElementById('test1');
   iframe1.focus();
-  var Ci = SpecialPowers.Ci;
-  var webnav = SpecialPowers.wrap(iframe1.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor)
-                                                        .getInterface(Ci.nsIWebNavigation)
-  var docShell = webnav.QueryInterface(Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(iframe1.contentWindow).docShell;
 
   // test1
   docShell.doCommand("cmd_selectAll");
   var withoutContenteditable = snapshotWindow(iframe1.contentWindow);
 
   iframe1.contentDocument.getElementById('testDiv').setAttribute('contentEditable', true);
   docShell.doCommand("cmd_selectAll");
   var withContenteditable = snapshotWindow(iframe1.contentWindow);
   dump(withoutContenteditable.toDataURL());
   dump(withContenteditable.toDataURL());
 
   ok(compareSnapshots(withoutContenteditable, withContenteditable, true)[0], 'Select all should look identical');
 
   // test2
   var iframe2 = document.getElementById('test2');
   iframe2.focus();
-  var webnav = SpecialPowers.wrap(iframe2.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor)
-                                                        .getInterface(Ci.nsIWebNavigation)
-  var docShell = webnav.QueryInterface(Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(iframe2.contentWindow).docShell;
   var test2Inner = iframe2.contentDocument.getElementById('test2Inner');
   test2Inner.style.MozUserSelect = 'text';
   docShell.doCommand("cmd_selectAll");
   var withoutUserSelect = snapshotWindow(iframe2.contentWindow);
 
   test2Inner.style.MozUserSelect = 'none';
   docShell.doCommand("cmd_selectAll");
   var withUserSelect = snapshotWindow(iframe2.contentWindow);
--- a/dom/base/test/test_bug166235.html
+++ b/dom/base/test/test_bug166235.html
@@ -24,32 +24,28 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
   "use strict";
 
 /** Test for Bug 166235 **/
   var Cc = SpecialPowers.Cc;
   var Ci = SpecialPowers.Ci;
 
-  var webnav = SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                                         .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-
-  var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(window).docShell;
 
   var documentViewer = docShell.contentViewer
                                .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
 
   var clipboard = Cc["@mozilla.org/widget/clipboard;1"]
                     .getService(SpecialPowers.Ci.nsIClipboard);
 
   var textarea = SpecialPowers.wrap(document.getElementById('input'));
 
   function getLoadContext() {
-    return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
-                                     .getInterface(Ci.nsIWebNavigation)
+    return SpecialPowers.wrap(window).docShell
                                      .QueryInterface(Ci.nsILoadContext);
   }
 
   function copyChildrenToClipboard(id) {
     textarea.blur();
     clipboard.emptyClipboard(1);
     window.getSelection().selectAllChildren(document.getElementById(id));
     documentViewer.copySelection();
--- a/dom/base/test/test_copyimage.html
+++ b/dom/base/test/test_copyimage.html
@@ -21,18 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 function testCopyImage () {
   var Ci = SpecialPowers.Ci;
   var Cc = SpecialPowers.Cc;
   var clipboard = SpecialPowers.Services.clipboard;
 
   function getClipboardData(mime) {
     var transferable = Cc['@mozilla.org/widget/transferable;1']
                        .createInstance(Ci.nsITransferable);
-    var loadingContext = SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
-                                      .getInterface(Ci.nsIWebNavigation)
+    var loadingContext = SpecialPowers.wrap(window).docShell
                                       .QueryInterface(Ci.nsILoadContext);
     transferable.init(loadingContext);
     transferable.addDataFlavor(mime);
     clipboard.getData(transferable, 1);
     var data = SpecialPowers.createBlankObject();
     transferable.getTransferData(mime, data, {});
     return data;
   }
@@ -45,20 +44,17 @@ function testCopyImage () {
   }
 
   //--------- Prepare data and copy it.
 
   // Select the node.
   var node = document.getElementById('logo');
 
   // Set node and copy image.
-  var webnav = SpecialPowers.wrap(window)
-               .QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-  var docShell = webnav.QueryInterface(Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(window).docShell;
   var documentViewer = docShell.contentViewer
                                .QueryInterface(Ci.nsIContentViewerEdit);
   documentViewer.setCommandNode(node);
   documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);
 
   //--------- Let's check the content of the clipboard now.
 
   // Does the clipboard contain text/unicode data ?
--- a/dom/base/test/test_copypaste.xul
+++ b/dom/base/test/test_copypaste.xul
@@ -14,19 +14,17 @@ SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 function runTest() {
   let desc = document.querySelector("description");
   window.getSelection().selectAllChildren(desc);
 
   let expected = "\n    hello\n    world\n  ";
   SimpleTest.waitForClipboard(expected, function() {
-    let webnav = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIWebNavigation);
-    webnav.QueryInterface(Ci.nsIDocShell)
+    window.docShell
           .contentViewer
           .QueryInterface(Ci.nsIContentViewerEdit)
           .copySelection();
   }, function() {
     ok(true, "Paste is not HTML, so it should not be pretty printed");
     SimpleTest.finish();
   });
 }
--- a/dom/base/test/test_postMessage_originAttributes.html
+++ b/dom/base/test/test_postMessage_originAttributes.html
@@ -15,18 +15,17 @@ add_task(async function() {
   await SpecialPowers.pushPrefEnv(
     { "set": [["network.disable.ipc.security", true]] });
 });
 
 add_task(async function() {
   let iframe = document.querySelector("#target-iframe");
 
   let win = SpecialPowers.wrap(iframe).contentWindow;
-  let docShell = win.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                    .getInterface(SpecialPowers.Ci.nsIDocShell);
+  let docShell = win.docShell;
 
   // Add private browsing ID to docShell origin and load document.
   docShell.setOriginAttributes({privateBrowsingId: 1});
 
   await new Promise(resolve => {
     iframe.addEventListener("load", resolve, true);
 
     iframe.src = SimpleTest.getTestFileURL("file_receiveMessage.html");
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -737,19 +737,17 @@ BrowserElementChild.prototype = {
     debug("Closing window " + win);
     sendAsyncMsg('close');
 
     // Inform the window implementation that we handled this close ourselves.
     e.preventDefault();
   },
 
   _windowCreatedHandler: function(e) {
-    let targetDocShell = e.target.defaultView
-          .QueryInterface(Ci.nsIInterfaceRequestor)
-          .getInterface(Ci.nsIWebNavigation);
+    let targetDocShell = e.target.defaultView.docShell;
     if (targetDocShell != docShell) {
       return;
     }
 
     let uri = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI;
     debug("Window created: " + uri.spec);
     if (uri.spec != "about:blank") {
       this._addMozAfterPaintHandler(function () {
--- a/dom/browser-element/BrowserElementCopyPaste.js
+++ b/dom/browser-element/BrowserElementCopyPaste.js
@@ -103,19 +103,17 @@ var CopyPasteAssistent = {
     while (currentWindow.realFrameElement) {
       let currentRect = currentWindow.realFrameElement.getBoundingClientRect();
       detail.rect.top += currentRect.top;
       detail.rect.bottom += currentRect.top;
       detail.rect.left += currentRect.left;
       detail.rect.right += currentRect.left;
       currentWindow = currentWindow.realFrameElement.ownerGlobal;
 
-      let targetDocShell = currentWindow
-          .QueryInterface(Ci.nsIInterfaceRequestor)
-          .getInterface(Ci.nsIWebNavigation);
+      let targetDocShell = currentWindow.docShell;
       if(targetDocShell.isMozBrowser) {
         break;
       }
     }
 
     sendAsyncMsg('caretstatechanged', detail);
   },
 };
--- a/dom/events/test/test_bug1412775.xul
+++ b/dom/events/test/test_bug1412775.xul
@@ -25,18 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       var b = win.document.getElementById("browser");
       var d = b.contentWindow.document;
       var e = new d.defaultView.Event("foo");
       var didCallChromeSide = false;
       var didCallContentSide = false;
       b.addEventListener("foo", function(e) {
         didCallChromeSide = true;
         var path = e.composedPath();
-        var mm = d.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIWebNavigation)
+        var mm = d.defaultView.docShell
                               .QueryInterface(Ci.nsIInterfaceRequestor)
                               .getInterface(Ci.nsIContentFrameMessageManager);
         is(path.length, 5, "Should have 5 items in composedPath in chrome.");
         is(path[0], mm, "TabChildGlobal is the chrome handler.");
         is(path[1], b, "browser element should be in the path.");
         is(path[2], b.parentNode, "window element should be in the path.");
         is(path[3], win.document, "Document object should be in the path.");
         is(path[4], win, "Window object should be in the path.");
--- a/dom/events/test/test_paste_image.html
+++ b/dom/events/test/test_paste_image.html
@@ -66,21 +66,17 @@
       canvas.getContext('2d').drawImage(aImage, 0, 0);
       return canvas;
     }
   }
 
   function copyImage(aImageId) {
     // selection of the node
     var node = document.getElementById(aImageId);
-    var webnav = SpecialPowers.wrap(window)
-                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-
-    var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
+    var docShell = SpecialPowers.wrap(window).docShell;
 
     // let's copy the node
     var documentViewer = docShell.contentViewer
                          .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
     documentViewer.setCommandNode(node);
     documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);
   }
 
--- a/dom/html/test/browser_bug649778.js
+++ b/dom/html/test/browser_bug649778.js
@@ -34,18 +34,18 @@ function checkCache(url, inMemory, shoul
     };
   };
 
   storage.asyncOpenURI(Services.io.newURI(url), "",
                        Ci.nsICacheStorage.OPEN_READONLY,
                        new CheckCacheListener(inMemory, shouldExist));
 }
 function getPopupURL() {
-  var sh = popup.QueryInterface(Ci.nsIInterfaceRequestor)
-                .getInterface(Ci.nsIWebNavigation)
+  var sh = popup.docShell
+                .QueryInterface(Ci.nsIWebNavigation)
                 .sessionHistory;
 
   return sh.legacySHistory.getEntryAtIndex(sh.index, false).URI.spec;
 }
 
 var wyciwygURL;
 function testContinue() {
   wyciwygURL = getPopupURL();
--- a/dom/html/test/test_bug460568.html
+++ b/dom/html/test/test_bug460568.html
@@ -31,20 +31,17 @@ function runTest()
 
   function isReallyEditable()
   {
     editor.focus();
     var range = document.createRange();
     range.selectNodeContents(editor);
     var prevStr = range.toString();
 
-    var docShell = SpecialPowers.wrap(window)
-            .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-            .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-            .QueryInterface(SpecialPowers.Ci.nsIDocShell);
+    var docShell = SpecialPowers.wrap(window).docShell;
     var controller =
           docShell.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
                   .getInterface(SpecialPowers.Ci.nsISelectionDisplay)
                   .QueryInterface(SpecialPowers.Ci.nsISelectionController);
     var sel = controller.getSelection(controller.SELECTION_NORMAL);
     sel.collapse(anchorInEditor, 0);
     sendString("a");
     range.selectNodeContents(editor);
--- a/dom/html/test/test_bug512367.html
+++ b/dom/html/test/test_bug512367.html
@@ -19,22 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 var frame = document.getElementById("i");
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
-  var viewer =
-    SpecialPowers.wrap(frame.contentWindow)
-                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                 .QueryInterface(SpecialPowers.Ci.nsIDocShell)
-                 .contentViewer;
+  var viewer = SpecialPowers.wrap(frame.contentWindow).docShell.contentViewer;
 
   viewer.fullZoom = 1.5;
 
   setTimeout(function() {
     synthesizeMouse(frame, 30, 30, {});
 
     is(viewer.fullZoom, 1.5, "Zoom in the image frame should not have been reset");
 
--- a/dom/ipc/remote-test.js
+++ b/dom/ipc/remote-test.js
@@ -8,21 +8,17 @@ dump(content + "\n");
 var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
 cpm.addMessageListener("cpm-async",
   function(m) {
     cpm.sendSyncMessage("ppm-sync");
     dump(content.document.documentElement);
     cpm.sendAsyncMessage("ppm-async");
   });
 
-var dshell = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                    .getInterface(Ci.nsIWebNavigation)
-                    .QueryInterface(Ci.nsIDocShellTreeItem)
-                    .rootTreeItem
-                    .QueryInterface(Ci.nsIDocShell);
+var dshell = content.docShell.rootTreeItem.QueryInterface(Ci.nsIDocShell);
 
 
 addEventListener("click",
   function(e) {
     dump(e.target + "\n");
     if (ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" &&
         dshell == docShell) {
       var retval = docShell.QueryInterface(Ci.nsIInterfaceRequestor).
--- a/dom/ipc/tests/test_child_docshell.html
+++ b/dom/ipc/tests/test_child_docshell.html
@@ -61,19 +61,17 @@ SpecialPowers.pushPrefEnv({'set':[
       by creating a new window and listening for its DOMWindowCreated event
     */
     chromeEventHandler.addEventListener("DOMWindowCreated", function listener(evt) {
       if (evt.target == content.document) {
         return;
       }
       chromeEventHandler.removeEventListener("DOMWindowCreated", listener);
       let new_win = evt.target.defaultView;
-      let new_docShell = new_win.QueryInterface(Ci.nsIInterfaceRequestor)
-                                .getInterface(Ci.nsIWebNavigation)
-                                .QueryInterface(Ci.nsIDocShell);
+      let new_docShell = new_win.docShell;
       sendAsyncMessage("DOMWindowCreatedReceived", {
         stableChromeEventHandler: chromeEventHandler === docShell.chromeEventHandler,
         iframeHasNewDocShell: new_docShell !== docShell,
         iframeHasSameChromeEventHandler: new_docShell.chromeEventHandler === chromeEventHandler
       });
     });
 
     function go() {
--- a/dom/serviceworkers/test/test_devtools_bypass_serviceworker.html
+++ b/dom/serviceworkers/test/test_devtools_bypass_serviceworker.html
@@ -10,16 +10,18 @@
 </head>
 <body>
 <div id="content" style="display: none"></div>
 <script src="utils.js"></script>
 <script type="text/javascript">
 "use strict";
 
 async function testBypassSW () {
+  let Ci = SpecialPowers.Ci;
+
   // Bypass SW imitates the "Disable Cache" option in dev-tools.
   // Note: if we put the setter/getter into dev-tools, we should take care of
   // the implementation of enabling/disabling cache since it just overwrite the
   // defaultLoadFlags of docShell.
   function setBypassServiceWorker(aDocShell, aBypass) {
     if (aBypass) {
       aDocShell.defaultLoadFlags |= Ci.nsIChannel.LOAD_BYPASS_SERVICE_WORKER;
       return;
@@ -50,21 +52,17 @@ async function testBypassSW () {
       // Intercepted
       return true;
     }
 
     throw("Unexpected error");
     return;
   }
 
-  let Ci = SpecialPowers.Ci;
-  let docShell = SpecialPowers.wrap(window)
-                              .QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIWebNavigation)
-                              .QueryInterface(Ci.nsIDocShell);
+  let docShell = SpecialPowers.wrap(window).docShell;
 
   info("Test 1: Enable bypass service worker for the docShell");
 
   setBypassServiceWorker(docShell, true);
   ok(getBypassServiceWorker(docShell),
      "The loadFlags in docShell does bypass the serviceWorker by default");
 
   let intercepted = await fetchFakeDocAndCheckIfIntercepted(window);
--- a/dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html
+++ b/dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html
@@ -5,30 +5,16 @@
 <script type="text/javascript">
 
 applicationCache.onerror = function() {
   parent.frameOnUpdate("diff", false);
 }
 
 applicationCache.oncached = function() {
   parent.frameOnUpdate("diff", true, applicationCache.status);
-
-  /* This code tries to figure out what cache is really
-     associated to this document, but hangs on getter2.getInterface
-     from for now unknown reasons. Commenting this out.
-
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
-  var getter1 = window.QueryInterface(Ci.nsIInterfaceRequestor);
-  var webnav = getter1.getInterface(Ci.nsIWebNavigation);
-  var getter2 = webnav.QueryInterface(Ci.nsIInterfaceRequestor);
-  var cacheCont = getter2.getInterface(Ci.nsIApplicationCacheContainer);
-  var cache = cacheCont.applicationCache;
-  dump(cache.groupID);
-  */
 }
 
 </script>
 
 </head>
 <body onload="parent.frameOnLoad('diff', applicationCache.status);">
   This is an iframe with a different manifest reference
 </body>
--- a/dom/tests/mochitest/ajax/offline/offlineTests.js
+++ b/dom/tests/mochitest/ajax/offline/offlineTests.js
@@ -301,20 +301,18 @@ manifestURL: function(overload)
             .getService(Ci.nsIIOService)
 
   var baseURI = ios.newURI(window.location.href);
   return ios.newURI(manifestURLspec, null, baseURI);
 },
 
 loadContext: function()
 {
-  return SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                                   .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                                   .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                                   .getInterface(SpecialPowers.Ci.nsILoadContext);
+  return SpecialPowers.wrap(window).docShell
+                                   .QueryInterface(SpecialPowers.Ci.nsILoadContext);
 },
 
 loadContextInfo: function()
 {
   return LoadContextInfo.fromLoadContext(this.loadContext(), false);
 },
 
 getActiveCache: function(overload)
--- a/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html
@@ -106,17 +106,17 @@ function posecheck() {
      "correct gamepadPose linearVelocity");
   is(checkValueInFloat32Array(pose.linearAcceleration, poseLinAcc), true,
      "correct gamepadPose linearAcceleration");
   pressButton();
 }
 
 function setFrameVisible(f, visible) {
   var Ci = SpecialPowers.Ci;
-  var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell);
+  var docshell = SpecialPowers.wrap(f.contentWindow).docShell;
   docshell.isActive = visible;
 }
 
 function haptictest() {
   var gamepads = navigator.getGamepads();
   var hapticActuators = gamepads[0].hapticActuators[0];
   hapticActuators.pulse(1, 100).then(function(result) {
     is(result, true, "gamepad hapticActuators test success.");
--- a/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html
@@ -14,17 +14,17 @@ let is = window.parent.is;
 let SimpleTest = window.parent.SimpleTest;
 let SpecialPowers = window.parent.SpecialPowers;
 
  // Add a gamepad
 var index;
 
 function setFrameVisible(f, visible) {
   var Ci = SpecialPowers.Ci;
-  var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell);
+  var docshell = SpecialPowers.wrap(f.contentWindow).docShell;
   docshell.isActive = visible;
 }
 
 var frames_loaded = 0;
 function startTest() {
   frames_loaded++;
   if (frames_loaded == 2) {
     GamepadService.addGamepad("test gamepad", // id
--- a/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html
+++ b/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html
@@ -21,17 +21,17 @@ window.addEventListener("gamepadbuttondo
 
 function pressButton() {
   GamepadService.newButtonEvent(index, 0, true, true);
   GamepadService.newButtonEvent(index, 0, false, false);
 }
 
 function setFrameVisible(f, visible) {
   var Ci = SpecialPowers.Ci;
-  var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell);
+  var docshell = SpecialPowers.wrap(f.contentWindow).docShell;
   docshell.isActive = visible;
 }
 
 var frames_loaded = 0;
 function startTest() {
   frames_loaded++;
   if (frames_loaded == 2) {
     GamepadService.addGamepad("test gamepad", // id
--- a/dom/tests/mochitest/general/test_innerScreen.xul
+++ b/dom/tests/mochitest/general/test_innerScreen.xul
@@ -44,17 +44,17 @@ function doTests()
   isRounded(window.mozInnerScreenX*devPxPerCSSPx, windowBO.screenX,
             "window screen X");
   isRounded(window.mozInnerScreenY*devPxPerCSSPx, windowBO.screenY,
             "window screen Y");
 
   var f = document.getElementById("f");
   var fBounds = f.getBoundingClientRect();
 
-  var fshell = f.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell);
+  var fshell = f.contentWindow.docShell;
   var fmudv = fshell.contentViewer;
 
   isRounded(f.contentWindow.mozInnerScreenX,
             window.mozInnerScreenX + fBounds.left,
             "frame screen X");
   isRounded(f.contentWindow.mozInnerScreenY,
             window.mozInnerScreenY + fBounds.top,
             "frame screen Y");
--- a/dom/tests/mochitest/whatwg/test_bug500328.html
+++ b/dom/tests/mochitest/whatwg/test_bug500328.html
@@ -155,18 +155,18 @@ function popstateExpected(msg) {
 function getColor(elem) {
   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)
+  var sh = SpecialPowers.wrap(theWindow).docShell
+                        .QueryInterface(Ci.nsIWebNavigation)
                         .sessionHistory;
   if (!sh || sh == null)
     throw("Couldn't get shistory for window!");
 
   return sh;
 }
 
 function getSHTitle(sh, offset)
--- a/dom/websocket/tests/websocket_tests.js
+++ b/dom/websocket/tests/websocket_tests.js
@@ -986,18 +986,17 @@ function test41() {
         }
 
         wsc.onclose = function(e) {
           ok(true, "test 41c close");
 
           // clean up the STS state
           const Ci = SpecialPowers.Ci;
           var loadContext = SpecialPowers.wrap(window)
-                            .QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIWebNavigation)
+                            .docShell
                             .QueryInterface(Ci.nsILoadContext);
           var flags = 0;
           if (loadContext.usePrivateBrowsing)
             flags |= Ci.nsISocketProvider.NO_PERMANENT_STORAGE;
           SpecialPowers.cleanUpSTSData("http://example.com", flags);
           resolve();
          }
        }
--- a/editor/AsyncSpellCheckTestHelper.jsm
+++ b/editor/AsyncSpellCheckTestHelper.jsm
@@ -25,21 +25,17 @@ const SPELL_CHECK_STARTED_TOPIC = "inlin
  * @param callback         Called when spell check has completed or enough turns
  *                         of the event loop have passed to determine it has not
  *                         started.
  */
 function onSpellCheck(editableElement, callback) {
   let editor = editableElement.editor;
   if (!editor) {
     let win = editableElement.ownerGlobal;
-    editor = win.QueryInterface(Ci.nsIInterfaceRequestor).
-                 getInterface(Ci.nsIWebNavigation).
-                 QueryInterface(Ci.nsIInterfaceRequestor).
-                 getInterface(Ci.nsIEditingSession).
-                 getEditorForWindow(win);
+    editor = win.docShell.editingSession.getEditorForWindow(win);
   }
   if (!editor)
     throw new Error("Unable to find editor for element " + editableElement);
 
   try {
     // False is important here.  Pass false so that the inline spell checker
     // isn't created if it doesn't already exist.
     var isc = editor.getInlineSpellChecker(false);
--- a/editor/composer/test/test_bug1266815.html
+++ b/editor/composer/test/test_bug1266815.html
@@ -58,20 +58,17 @@ add_task(async function() {
     iframe.id = "testframe";
     iframe.src = "data:text/html,<div id=edit contenteditable=true>abc</div>";
     document.body.appendChild(iframe);
   });
 
   await promise;
 
   let iframe = document.getElementById("testframe");
-  let docShell = SpecialPowers.wrap(iframe.contentWindow)
-                 .QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
-                 .QueryInterface(Ci.nsIDocShell);
+  let docShell = SpecialPowers.wrap(iframe.contentWindow).docShell;
 
   ok(docShell.hasEditingSession, "Should have editing session");
 
   document.getElementById("testframe").src =
     "data:application/octet-stream,TESTCONTENT";
 
   await helperAppDlgPromise;
 
--- a/editor/composer/test/test_bug519928.html
+++ b/editor/composer/test/test_bug519928.html
@@ -17,21 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var iframe = document.getElementById("load-frame");
 
 function enableJS() { allowJS(true, iframe); }
 function disableJS() { allowJS(false, iframe); }
 function allowJS(allow, frame) {
-  SpecialPowers.wrap(frame.contentWindow)
-               .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-               .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-               .QueryInterface(SpecialPowers.Ci.nsIDocShell)
-               .allowJavascript = allow;
+  SpecialPowers.wrap(frame.contentWindow).docShell.allowJavascript = allow;
 }
 
 function expectJSAllowed(allowed, testCondition, callback) {
   window.ICanRunMyJS = false;
   var self_ = window;
   testCondition();
 
   var doc = iframe.contentDocument;
--- a/editor/libeditor/tests/test_CF_HTML_clipboard.html
+++ b/editor/libeditor/tests/test_CF_HTML_clipboard.html
@@ -22,18 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 572642 **/
 
 function copyCF_HTML(cfhtml, success, failure) {
   const Cc = SpecialPowers.Cc;
   const Ci = SpecialPowers.Ci;
   const CF_HTML = "application/x-moz-nativehtml";
 
   function getLoadContext() {
-    return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
+    return SpecialPowers.wrap(window)
+                 .docShell
                  .QueryInterface(Ci.nsILoadContext);
   }
 
   var cb = Cc["@mozilla.org/widget/clipboard;1"].
            getService(Ci.nsIClipboard);
 
   var counter = 0;
   function copyCF_HTML_worker(success, failure) {
--- a/editor/libeditor/tests/test_bug1100966.html
+++ b/editor/libeditor/tests/test_bug1100966.html
@@ -49,21 +49,17 @@ SimpleTest.waitForFocus(function() {
         });
       },0);
     },0);
   });
 });
 
 function getEditor() {
   var Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-    .QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIWebNavigation)
-    .QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window);
 }
 
 function getSpellChecker() {
   return getEditor().getInlineSpellChecker(false).spellChecker;
 }
 
 function getSpellCheckSelection() {
--- a/editor/libeditor/tests/test_bug1140105.html
+++ b/editor/libeditor/tests/test_bug1140105.html
@@ -48,21 +48,17 @@ SimpleTest.waitForFocus(function() {
   is(allHas.value, false, "Test for Courier: allHas: false expected");
 
   SimpleTest.finish();
 
 });
 
 function getEditor() {
   var Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-                             .QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIWebNavigation)
-                             .QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   var editor = editingSession.getEditorForWindow(window);
   editor.QueryInterface(Ci.nsIHTMLEditor);
   return editor;
 }
 
 </script>
 </body>
 
--- a/editor/libeditor/tests/test_bug1154791.html
+++ b/editor/libeditor/tests/test_bug1154791.html
@@ -49,21 +49,17 @@ SimpleTest.waitForFocus(function() {
         });
       },0);
     },0);
   });
 });
 
 function getEditor() {
   var Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-                             .QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIWebNavigation)
-                             .QueryInterface(Ci.nsIInterfaceRequestor)
-                             .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window);
 }
 
 function getSpellChecker() {
   return getEditor().getInlineSpellChecker(false).spellChecker;
 }
 
 function getSpellCheckSelection() {
--- a/editor/libeditor/tests/test_bug1186799.html
+++ b/editor/libeditor/tests/test_bug1186799.html
@@ -49,20 +49,18 @@ SimpleTest.waitForFocus(function() {
   ok(!isThereIMESelection(), "There should be no IME selection");
 
   SimpleTest.finish();
 });
 
 function isThereIMESelection()
 {
   var selCon = SpecialPowers.wrap(window).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIWebNavigation).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIEditingSession).
+        docShell.
+        editingSession.
         getEditorForWindow(window).
         selectionController;
   const kIMESelections = [
     SpecialPowers.Ci.nsISelectionController.SELECTION_IME_RAWINPUT,
     SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDRAWTEXT,
     SpecialPowers.Ci.nsISelectionController.SELECTION_IME_CONVERTEDTEXT,
     SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDCONVERTEDTEXT
   ];
--- a/editor/libeditor/tests/test_bug1230473.html
+++ b/editor/libeditor/tests/test_bug1230473.html
@@ -30,19 +30,17 @@ SimpleTest.waitForFocus(()=>{
     function value() {
       return isNSEditableElement() ? aEditor.value : aEditor.textContent;
     }
     function isComposing() {
       return isNSEditableElement() ?  SpecialPowers.wrap(aEditor)
                                                    .editor
                                                    .composing :
                                       SpecialPowers.wrap(window)
-                                                   .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                                                   .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                                                   .QueryInterface(SpecialPowers.Ci.nsIDocShell)
+                                                   .docShell
                                                    .editor
                                                    .composing;
     }
     function clear() {
       if (isNSEditableElement()) {
         aEditor.value = "";
       } else {
         aEditor.textContent = "";
--- a/editor/libeditor/tests/test_bug1268736.html
+++ b/editor/libeditor/tests/test_bug1268736.html
@@ -32,21 +32,17 @@ https://bugzilla.mozilla.org/show_bug.cg
  * Test for Bug 1268736
  *
  * Tests for editing a table cell's contents when the table cell is or isn't a child of a contenteditable node.
  *
  */
 
 function getEditor() {
   const Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIWebNavigation)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
 }
 
 var table = document.getElementById("table");
 var tableHTML = table.innerHTML;
 var editor = getEditor();
 
 var cell = document.getElementById("cell_readonly");
--- a/editor/libeditor/tests/test_bug1330796.html
+++ b/editor/libeditor/tests/test_bug1330796.html
@@ -81,21 +81,17 @@ SimpleTest.waitForFocus(function() {
   }
 
   SimpleTest.finish();
 
 });
 
 function makeMailEditor() {
   var Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-    .QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIWebNavigation)
-    .QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   var editor = editingSession.getEditorForWindow(window);
   editor.flags |= Ci.nsIPlaintextEditor.eEditorMailMask;
 }
 </script>
 
 </pre>
 </body>
 </html>
--- a/editor/libeditor/tests/test_bug1397412.xul
+++ b/editor/libeditor/tests/test_bug1397412.xul
@@ -28,19 +28,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
   <script class="testbody" type="application/javascript">
   <![CDATA[
 function runTest() {
   var initialHTML1 = "xx<br><br>";
   var expectedHTML1 = "xx<br>t<br>";
   var initialHTML2 = "xx<br><br>yy<br>";
   var expectedHTML2 = "xx<br>t<br>yy<br>";
-  window.QueryInterface(Ci.nsIInterfaceRequestor)
-     .getInterface(Ci.nsIWebNavigation)
-     .QueryInterface(Ci.nsIDocShellTreeItem)
+  window.docShell
      .rootTreeItem
      .QueryInterface(Ci.nsIDocShell)
      .appType = Ci.nsIDocShell.APP_TYPE_EDITOR;
   var e = document.getElementById("editor");
   var doc = e.contentDocument;
   doc.designMode = "on";
   doc.defaultView.focus();
   var selection = doc.defaultView.getSelection();
--- a/editor/libeditor/tests/test_bug366682.html
+++ b/editor/libeditor/tests/test_bug366682.html
@@ -31,21 +31,17 @@ function getEdit() {
 
 function editDoc() {
   return getEdit().contentDocument;
 }
 
 function getEditor() {
   var Ci = SpecialPowers.Ci;
   var win = editDoc().defaultView;
-  var editingSession = SpecialPowers.wrap(win)
-    .QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIWebNavigation)
-    .QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
   return editingSession.getEditorForWindow(win);
 }
 
 function runTest() {
   editDoc().body.innerHTML = "<div>errror and an other errror</div>";
   gMisspeltWords = ["errror", "errror"];
   editDoc().designMode = "on";
 
--- a/editor/libeditor/tests/test_bug432225.html
+++ b/editor/libeditor/tests/test_bug432225.html
@@ -34,21 +34,17 @@ function getEdit() {
 
 function editDoc() {
   return getEdit().contentDocument;
 }
 
 function getEditor() {
   var Ci = SpecialPowers.Ci;
   var win = editDoc().defaultView;
-  var editingSession = SpecialPowers.wrap(win)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIWebNavigation)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
   return editingSession.getEditorForWindow(win);
 }
 
 function runTest() {
   editDoc().designMode = "on";
   setTimeout(function() { addWords(100); }, 0);
 }  
  
--- a/editor/libeditor/tests/test_bug484181.html
+++ b/editor/libeditor/tests/test_bug484181.html
@@ -24,20 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 var gMisspeltWords;
 
 function getEditor() {
   var Ci = SpecialPowers.Ci;
   var win = window;
-  var editingSession = SpecialPowers.wrap(win).QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIWebNavigation)
-                          .QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
   return editingSession.getEditorForWindow(win);
 }
 
 function append(str) {
   var edit = document.getElementById("edit");
   var editor = getEditor();
   var sel = editor.selection;
   sel.selectAllChildren(edit);
--- a/editor/libeditor/tests/test_bug489202.xul
+++ b/editor/libeditor/tests/test_bug489202.xul
@@ -26,35 +26,31 @@ https://bugzilla.mozilla.org/show_bug.cg
   <pre id="test">
   </pre>
   </body>
   <script class="testbody" type="application/javascript">
   <![CDATA[
   var utils = SpecialPowers.getDOMWindowUtils(window);
 
 function getLoadContext() {
-  return window.QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 function runTest() {
   var trans = Cc["@mozilla.org/widget/transferable;1"]
       .createInstance(Ci.nsITransferable);
   trans.init(getLoadContext());
   trans.addDataFlavor("text/html");
   var test_data = '<meta/><a href="http://mozilla.org/">mozilla.org</a>';
   var cstr = Cc["@mozilla.org/supports-string;1"]
       .createInstance(Ci.nsISupportsString);
   cstr.data = test_data;
   trans.setTransferData("text/html", cstr, test_data.length*2);
 
-  window.QueryInterface(Ci.nsIInterfaceRequestor)
-     .getInterface(Ci.nsIWebNavigation)
-     .QueryInterface(Ci.nsIDocShellTreeItem)
+  window.docShell
      .rootTreeItem
      .QueryInterface(Ci.nsIDocShell)
      .appType = Ci.nsIDocShell.APP_TYPE_EDITOR; 
   var e = document.getElementById('i1');
   var doc = e.contentDocument;
   doc.designMode = "on";
   doc.body.innerHTML = "";
   doc.defaultView.focus();
--- a/editor/libeditor/tests/test_bug520189.html
+++ b/editor/libeditor/tests/test_bug520189.html
@@ -545,20 +545,17 @@ function doNextTest() {
 
   runTest(tests[testCounter]);
 
   doNextTest();
 }
 
 function getLoadContext() {
   const Ci = SpecialPowers.Ci;
-  return SpecialPowers.wrap(window)
-               .QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 function runTest(test) {
   var elem = document.getElementById(test.id);
   if ("isIFrame" in test) {
     elem.contentDocument.designMode = "on";
     elem.contentWindow.focus();
   } else
@@ -576,20 +573,17 @@ function runTest(test) {
   if ("indirectPaste" in test) {
     var editor, win;
     if ("isIFrame" in test) {
       win = elem.contentDocument.defaultView;
     } else {
       getSelection().collapse(elem, 0);
       win = window;
     }
-    editor = SpecialPowers.wrap(win).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                          .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                          .QueryInterface(SpecialPowers.Ci.nsIDocShell)
-                          .editor;
+    editor = SpecialPowers.wrap(win).docShell.editor;
     editor.pasteTransferable(trans);
   } else {
     var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
                                  .getService(SpecialPowers.Ci.nsIClipboard);
 
     clipboard.setData(trans, null, SpecialPowers.Ci.nsIClipboard.kGlobalClipboard);
 
     synthesizeKey("V", {accelKey: true});
--- a/editor/libeditor/tests/test_bug525389.html
+++ b/editor/libeditor/tests/test_bug525389.html
@@ -8,20 +8,17 @@
 
 <script class="testbody" type="application/javascript">
 
   var utils = SpecialPowers.getDOMWindowUtils(window);
   var Cc = SpecialPowers.Cc;
   var Ci = SpecialPowers.Ci;
 
 function getLoadContext() {
-  return SpecialPowers.wrap(window)
-               .QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 async function runTest() {
   var pasteCount = 0;
   var pasteFunc = function (event) { pasteCount++; };
 
   function verifyContent(s) {
     var e = document.getElementById('i1');
--- a/editor/libeditor/tests/test_bug596333.html
+++ b/editor/libeditor/tests/test_bug596333.html
@@ -35,20 +35,17 @@ function append(str) {
   var edit = document.getElementById("edit");
   edit.focus();
   edit.selectionStart = edit.selectionEnd = edit.value.length;
   var editor = getEditor();
   sendString(str);
 }
 
 function getLoadContext() {
-  return SpecialPowers.wrap(window)
-         .QueryInterface(Ci.nsIInterfaceRequestor)
-         .getInterface(Ci.nsIWebNavigation)
-         .QueryInterface(Ci.nsILoadContext);
+  return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 function paste(str) {
   var edit = document.getElementById("edit");
   var Cc = SpecialPowers.Cc, Ci = SpecialPowers.Ci;
   var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
   trans.init(getLoadContext());
   var s = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
--- a/editor/libeditor/tests/test_bug790475.html
+++ b/editor/libeditor/tests/test_bug790475.html
@@ -24,21 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 var gMisspeltWords;
 
 function getEditor() {
   const Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIWebNavigation)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window);
 }
 
 function getSpellCheckSelection() {
   var editor = getEditor();
   var selcon = editor.selectionController;
   return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
 }
--- a/editor/libeditor/tests/test_bug857487.html
+++ b/editor/libeditor/tests/test_bug857487.html
@@ -37,21 +37,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 /**
  * Test for Bug 857487
  *
  * Tests that removing a table row through nsIHTMLEditor works
  */
 
 function getEditor() {
   const Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIWebNavigation)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
 }
 
 var cell = document.getElementById("cell");
 cell.focus();
 
 // place caret at end of center cell
 var sel = getSelection();
--- a/editor/libeditor/tests/test_bug974309.html
+++ b/editor/libeditor/tests/test_bug974309.html
@@ -39,21 +39,17 @@ https://bugzilla.mozilla.org/show_bug.cg
  * Test for Bug 974309
  *
  * Tests that editing a table row fails when the table or row is _not_ a child of a contenteditable node.
  * See bug 857487 for tests that cover when the table or row _is_ a child of a contenteditable node.
  */
 
 function getEditor() {
   const Ci = SpecialPowers.Ci;
-  var editingSession = SpecialPowers.wrap(window)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIWebNavigation)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIEditingSession);
+  var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor);
 }
 
 var cell = document.getElementById("cell");
 cell.focus();
 
 // place caret at end of center cell
 var sel = getSelection();
--- a/editor/libeditor/tests/test_contenteditable_focus.html
+++ b/editor/libeditor/tests/test_contenteditable_focus.html
@@ -51,19 +51,17 @@ function runTests()
 
 function runTestsInternal()
 {
   var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
              getService(SpecialPowers.Ci.nsIFocusManager);
   // XXX using selCon for checking the visibility of the caret, however,
   // selCon is shared in document, cannot get the element of owner of the
   // caret from javascript?
-  var selCon = SpecialPowers.wrap(window).
-        QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-        getInterface(SpecialPowers.Ci.nsIWebNavigation).
+  var selCon = SpecialPowers.wrap(window).docShell.
         QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
         getInterface(SpecialPowers.Ci.nsISelectionDisplay).
         QueryInterface(SpecialPowers.Ci.nsISelectionController);
   var selection = window.getSelection();
 
   var inputText = document.getElementById("inputText");
   var inputTextReadonly = document.getElementById("inputTextReadonly");
   var inputButton = document.getElementById("inputButton");
--- a/editor/libeditor/tests/test_css_chrome_load_access.html
+++ b/editor/libeditor/tests/test_css_chrome_load_access.html
@@ -20,21 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 const Ci = SpecialPowers.Ci;
 var styleSheets = null;
 
 function runTest() {
 
   var editframe = window.frames[0];
   var editdoc = editframe.document;
   editdoc.designMode = 'on';
-  var editor = SpecialPowers.wrap(editframe)
-                            .QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIWebNavigation)
-                            .QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIEditingSession)
+  var editor = SpecialPowers.wrap(editframe).docShell.editingSession
                             .getEditorForWindow(editframe);
 
   styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
 
   // test 1: try to access chrome:// url that is accessible to content
   try
   {
     styleSheets.addOverrideStyleSheet("chrome://browser/content/pageinfo/pageInfo.css");
--- a/editor/libeditor/tests/test_documentCharacterSet.html
+++ b/editor/libeditor/tests/test_documentCharacterSet.html
@@ -13,21 +13,17 @@
 <iframe></iframe>
 
 <pre id="test">
 
 <script class="testbody" type="application/javascript">
 function getEditor() {
   const Ci = SpecialPowers.Ci;
   let editframe = window.frames[0];
-  return SpecialPowers.wrap(editframe)
-                      .QueryInterface(Ci.nsIInterfaceRequestor)
-                      .getInterface(Ci.nsIWebNavigation)
-                      .QueryInterface(Ci.nsIInterfaceRequestor)
-                      .getInterface(Ci.nsIEditingSession)
+  return SpecialPowers.wrap(editframe).docShell.editingSession
                       .getEditorForWindow(editframe);
 }
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   let editdoc = window.frames[0].document;
   editdoc.designMode = 'on';
   let editor = getEditor();
--- a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html
+++ b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html
@@ -604,20 +604,17 @@ function runTests()
     is(aElement.innerHTML,
        aIsReadonly ? "" : aIsPlaintext ? "Mozilla " : "Mozilla <br>",
        aDescription + "typed \"Mozilla \"");
   }
 
   doTest(htmlEditor, "contenteditable=\"true\"", false, true, false);
 
   const nsIPlaintextEditor = SpecialPowers.Ci.nsIPlaintextEditor;
-  var editor = SpecialPowers.wrap(window).
-      QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-      getInterface(SpecialPowers.Ci.nsIWebNavigation).
-      QueryInterface(SpecialPowers.Ci.nsIDocShell).editor;
+  var editor = SpecialPowers.wrap(window).docShell.editor;
   var flags = editor.flags;
   // readonly
   editor.flags = flags | nsIPlaintextEditor.eEditorReadonlyMask;
   doTest(htmlEditor, "readonly HTML editor", true, true, false);
 
   // non-tabbable
   editor.flags = flags & ~(nsIPlaintextEditor.eEditorAllowInteraction);
   doTest(htmlEditor, "non-tabbable HTML editor", false, false, false);
--- a/editor/libeditor/tests/test_root_element_replacement.html
+++ b/editor/libeditor/tests/test_root_element_replacement.html
@@ -79,18 +79,17 @@ const kTests = [
 var gIFrame;
 var gSetFocusToIFrame = false;
 
 function onLoadIFrame()
 {
   var frameDoc = gIFrame.contentWindow.document;
 
   var selCon = SpecialPowers.wrap(gIFrame).contentWindow.
-    QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-    getInterface(SpecialPowers.Ci.nsIWebNavigation).
+    docShell.
     QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
     getInterface(SpecialPowers.Ci.nsISelectionDisplay).
     QueryInterface(SpecialPowers.Ci.nsISelectionController);
   var utils = SpecialPowers.getDOMWindowUtils(window);
 
   // move focus to the HTML editor
   const kTest = kTests[gTestIndex];
   ok(true, "Running " + kTest.description);
--- a/editor/spellchecker/tests/test_bug1205983.html
+++ b/editor/spellchecker/tests/test_bug1205983.html
@@ -61,21 +61,17 @@ SimpleTest.waitForFocus(function() {
   document.getElementById('de-DE').focus();
 });
 
 function deFocus() {
   elem_de = document.getElementById('de-DE');
 
   onSpellCheck(elem_de, function () {
     var Ci = SpecialPowers.Ci;
-    var editingSession = SpecialPowers.wrap(window)
-                               .QueryInterface(Ci.nsIInterfaceRequestor)
-                               .getInterface(Ci.nsIWebNavigation)
-                               .QueryInterface(Ci.nsIInterfaceRequestor)
-                               .getInterface(Ci.nsIEditingSession);
+    var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     editor_de = editingSession.getEditorForWindow(window);
     selcon_de = editor_de.selectionController;
     var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
 
     // Check that we spelled in German, so there is only one misspelled word.
     is(sel.toString(), "German", "one misspelled word expected: German");
 
     // Now focus the textarea, which requires English spelling.
--- a/editor/spellchecker/tests/test_bug1219928.html
+++ b/editor/spellchecker/tests/test_bug1219928.html
@@ -32,21 +32,17 @@ SimpleTest.waitForFocus(function() {
   SpecialPowers.Cu.import(
     "resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
 
   var elem = document.getElementById('en-US');
   elem.focus();
 
   onSpellCheck(elem, function () {
     var Ci = SpecialPowers.Ci;
-    var editingSession = SpecialPowers.wrap(window)
-                                      .QueryInterface(Ci.nsIInterfaceRequestor)
-                                      .getInterface(Ci.nsIWebNavigation)
-                                      .QueryInterface(Ci.nsIInterfaceRequestor)
-                                      .getInterface(Ci.nsIEditingSession);
+    var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     var editor = editingSession.getEditorForWindow(window);
     var selcon = editor.selectionController;
     var sel = selcon.getSelection(selcon.SELECTION_SPELLCHECK);
 
     is(sel.toString(), "missspelled", "one misspelled word expected: missspelled");
 
     spellchecker = SpecialPowers.Cc['@mozilla.org/editor/editorspellchecker;1']
                                 .createInstance(Ci.nsIEditorSpellCheck);
--- a/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
+++ b/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
@@ -3,19 +3,17 @@ let { Services } = ChromeUtils.import("r
 add_task(async function test_windowlessBrowserTroubleshootCrash() {
   let webNav = Services.appShell.createWindowlessBrowser(false);
 
   let onLoaded = new Promise((resolve, reject) => {
     let docShell = webNav.QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIDocShell);
     let listener = {
       observe(contentWindow, topic, data) {
-        let observedDocShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                            .getInterface(Ci.nsIWebNavigation)
-                                            .QueryInterface(Ci.nsIDocShellTreeItem)
+        let observedDocShell = contentWindow.docShell
                                             .sameTypeRootTreeItem
                                             .QueryInterface(Ci.nsIDocShell);
           if (docShell === observedDocShell) {
             Services.obs.removeObserver(listener, "content-document-global-created");
             resolve();
           }
         }
     }
--- a/layout/base/tests/chrome/bug1041200_window.html
+++ b/layout/base/tests/chrome/bug1041200_window.html
@@ -9,22 +9,17 @@
 <body>
 <iframe style="width:700px; height:500px; margin-top:200px;" id="ourFrame"></iframe>
 <script>
 var SpecialPowers = window.opener.wrappedJSObject.SpecialPowers;
 var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 var ok = window.opener.wrappedJSObject.ok;
 var info = window.opener.wrappedJSObject.info;
 
-var viewer =
-  SpecialPowers.wrap(ourFrame).contentWindow
-               .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-               .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-               .QueryInterface(SpecialPowers.Ci.nsIDocShell)
-               .contentViewer;
+var viewer = SpecialPowers.wrap(ourFrame).contentWindow.docShell.contentViewer;
 viewer.fullZoom = 2;
 
 SimpleTest.waitForExplicitFinish();
 
 window.onload = function() {
   window.waitForAllPaintsFlushed(function () {
     // Supply random key to ensure load actually happens
     ourFrame.src = "bug1041200_frame.html?" + Math.random();
--- a/layout/base/tests/chrome/file_bug1018265.xul
+++ b/layout/base/tests/chrome/file_bug1018265.xul
@@ -31,18 +31,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   function didGoBack(e) {
     testcontent.removeEventListener("pageshow", didGoBack, true);
     shouldHaveTwoNonHiddenContentViewers();
     opener.done();
     window.close();
   }
 
   function getContentViewer(win) {
-    return win.QueryInterface(Ci.nsIInterfaceRequestor)
-              .getInterface(Ci.nsIDocShell).contentViewer;
+    return win.docShell.contentViewer;
   }
 
   function shouldHaveTwoNonHiddenContentViewers() {
     opener.is(getContentViewer(testcontent.contentWindow).isHidden, false, "Top level ContentViewer should not be hidden.");
     opener.is(getContentViewer(testcontent.contentWindow.frames[0]).isHidden, false, " Iframe's ContentViewer should not be hidden.");
   }
   ]]>
   </script>
--- a/layout/base/tests/chrome/test_bug396367-1.html
+++ b/layout/base/tests/chrome/test_bug396367-1.html
@@ -13,18 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     function finish() {
       ok(true, "didn't crash");
       var docviewer = getdocviewer();
       docviewer.textZoom = 1;
       SimpleTest.finish();
     }
 
     function getdocviewer() {
-      var navigator1 = top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
-      var docShell = navigator1.QueryInterface(Ci.nsIDocShell);
+      var docShell = top.docShell;
       var docviewer = docShell.contentViewer;
       return docviewer;
     }
   </script>
 </head>
 <body>
 
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396367">Mozilla Bug 396367</a>
--- a/layout/base/tests/chrome/test_bug396367-2.html
+++ b/layout/base/tests/chrome/test_bug396367-2.html
@@ -14,18 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     function finish() {
       ok(true, "didn't crash");
       var docviewer = getdocviewer();
       docviewer.textZoom = 1;
       SimpleTest.finish();
     }
 
     function getdocviewer() {
-      var navigator1 = top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
-      var docShell = navigator1.QueryInterface(Ci.nsIDocShell);
+      var docShell = top.docShell;
       var docviewer = docShell.contentViewer;
       return docviewer;
     }
   </script>
 </head>
 <body>
 
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396367">Mozilla Bug 396367</a>
--- a/layout/base/tests/chrome/test_bug420499.xul
+++ b/layout/base/tests/chrome/test_bug420499.xul
@@ -62,20 +62,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     function getSelectionController() {
       return window.docShell
         .QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsISelectionDisplay)
         .QueryInterface(Ci.nsISelectionController);
     }
 
     function isCaretVisible() {
-      window.QueryInterface(Ci.nsIInterfaceRequestor);
-      var docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIWebNavigation)
-                            .QueryInterface(Ci.nsIDocShell);
+      var docShell = window.docShell;
       var selCon = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsISelectionDisplay)
         .QueryInterface(Ci.nsISelectionController);
       return selCon.caretVisible;
     }
     
     function focusInput() {
       ok(!isCaretVisible(), "Caret shouldn't be visible");
--- a/layout/base/tests/chrome/test_bug514660.xul
+++ b/layout/base/tests/chrome/test_bug514660.xul
@@ -17,21 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
   <!-- test code goes here -->
 <script type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function doTest()
 {
-  var viewer = window
-                 .QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
-                 .QueryInterface(Ci.nsIDocShell)
-                 .contentViewer;
+  var viewer = window.docShell.contentViewer;
   viewer.authorStyleDisabled = true;
 
   document.documentElement.getBoundingClientRect();
   ok(true, "Didn't crash");
 
   viewer.authorStyleDisabled = false;
 
   SimpleTest.finish();
--- a/layout/base/tests/chrome/test_bug708062.html
+++ b/layout/base/tests/chrome/test_bug708062.html
@@ -23,18 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 function isBoundingClientRect(e, r, msg) {
   var BCR = e.getBoundingClientRect();
   is([BCR.left, BCR.top, BCR.right, BCR.bottom].join(','), r, msg);
 }
 
 function doTest() {
   var f = document.getElementById('f');
 
-  var navigator1 = f.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
-  var docShell = navigator1.QueryInterface(Ci.nsIDocShell);
+  var docShell = f.contentWindow.docShell;
   var docviewer = docShell.contentViewer;
 
   var d = f.contentDocument.getElementById('d');
 
   isBoundingClientRect(d, "-70,0,100,1", "initial rect");
   docviewer.fullZoom = 2;
   isBoundingClientRect(d, "-120,0,50,1", "after zooming in");
   docviewer.fullZoom = 1;
--- a/layout/base/tests/test_bug449781.html
+++ b/layout/base/tests/test_bug449781.html
@@ -32,21 +32,17 @@ addLoadEvent(function() {
   s2 = snapshotWindow(window);
 
   var equal, str1, str2;
   [equal, str1, str2] = compareSnapshots(s1, s2, true);
   ok(equal, "Show/hide should have no effect",
      "got " + str1 + " but expected " + str2);
 
   var viewer =
-    SpecialPowers.wrap($("ourFrame")).contentWindow
-                 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-                 .QueryInterface(SpecialPowers.Ci.nsIDocShell)
-                 .contentViewer;
+    SpecialPowers.wrap($("ourFrame")).contentWindow.docShell.contentViewer;
   viewer.fullZoom = 2;
   
   s3 = snapshotWindow(window);
 
   [equal, str1, str2] = compareSnapshots(s1, s3, true);
   ok(equal, "Zoom should have no effect",
      "got " + str1 + " but expected " + str2);
 
--- a/layout/generic/test/frame_selection_underline-ref.xhtml
+++ b/layout/generic/test/frame_selection_underline-ref.xhtml
@@ -8,20 +8,17 @@
 
 function init(aTest)
 {
   var target = document.getElementById("target");
   var decoration = document.getElementById("decoration");
   var leftSpacer = document.getElementById("leftspacer");
   var rightSpacer = document.getElementById("rightspacer");
 
-  var docShell =
-    window.QueryInterface(Ci.nsIInterfaceRequestor)
-          .getInterface(Ci.nsIWebNavigation)
-          .QueryInterface(Ci.nsIDocShell);
+  var docShell = window.docShell;
   var controller =
     docShell.QueryInterface(Ci.nsIInterfaceRequestor)
             .getInterface(Ci.nsISelectionDisplay)
             .QueryInterface(Ci.nsISelectionController);
 
   const nsISelectionController = Ci.nsISelectionController;
   if (aTest.selection.isIME) {
     leftSpacer.style.display = rightSpacer.style.display = "inline-block";
--- a/layout/generic/test/frame_selection_underline.xhtml
+++ b/layout/generic/test/frame_selection_underline.xhtml
@@ -3,20 +3,17 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" class="willBeRemoved">
 <head>
 <link rel="stylesheet" type="text/css" href="frame_selection_underline.css"/>
 <script type="text/javascript">
 <![CDATA[
 
 function init(aTest)
 {
-  var docShell =
-    window.QueryInterface(Ci.nsIInterfaceRequestor)
-          .getInterface(Ci.nsIWebNavigation)
-          .QueryInterface(Ci.nsIDocShell);
+  var docShell = window.docShell;
   var controller =
     docShell.QueryInterface(Ci.nsIInterfaceRequestor)
             .getInterface(Ci.nsISelectionDisplay)
             .QueryInterface(Ci.nsISelectionController);
 
   var selections = [
     controller.SELECTION_SPELLCHECK,
     controller.SELECTION_IME_RAWINPUT,
@@ -43,9 +40,9 @@ function init(aTest)
 }
 
 ]]>
 </script>
 </head>
 <body class="test">
   <div id="target"><span id="decoration">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div>
 </body>
-</html>
\ No newline at end of file
+</html>
--- a/layout/generic/test/test_bug263683.html
+++ b/layout/generic/test/test_bug263683.html
@@ -47,18 +47,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       function startTest() {
         var textToSelect = document.getElementById("selecttext");
 
         // Take a snapshot now. This will be used to check that removing the
         // ranges removes the highlighting correctly
         var noHighlight = snapshotWindow(window);
 
         var controller = SpecialPowers.wrap(window).
-           QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-           getInterface(SpecialPowers.Ci.nsIWebNavigation).
+           docShell.
            QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
            getInterface(SpecialPowers.Ci.nsISelectionDisplay).
            QueryInterface(SpecialPowers.Ci.nsISelectionController);
 
         // Get selection
         var findSelection = controller.getSelection(controller.SELECTION_FIND);
 
         // Lastly add range
--- a/layout/generic/test/test_selection_touchevents.html
+++ b/layout/generic/test/test_selection_touchevents.html
@@ -25,19 +25,17 @@ function test()
   selection.removeAllRanges();
   var rect = div1.getBoundingClientRect();
 
   // Position the caret using a fake mouse click
   var Ci = SpecialPowers.Ci;
   var cwu = SpecialPowers.getDOMWindowUtils(window);
   cwu.sendMouseEventToWindow("mousedown", rect.left + rect.width/2, rect.top + rect.height/2, 0, 0, 0, true);
   cwu.sendMouseEventToWindow("mouseup",   rect.left + rect.width/2, rect.top + rect.height/2, 0, 0, 0, true);
-  var selectionController = SpecialPowers.wrap(window).
-                              QueryInterface(Ci.nsIInterfaceRequestor).
-                              getInterface(Ci.nsIWebNavigation).
+  var selectionController = SpecialPowers.wrap(window).docShell.
                               QueryInterface(Ci.nsIInterfaceRequestor).
                               getInterface(Ci.nsISelectionDisplay).
                               QueryInterface(Ci.nsISelectionController);
 
   selectionController.wordMove(false, false);
   selectionController.wordMove(true, true);
   isnot(selection.rangeCount, 0, "Something should be selected");
   var string = selection.toString();
@@ -49,9 +47,9 @@ function test()
 
   SimpleTest.finish();
 }
 window.onload = function() { setTimeout(test, 0); };
 SimpleTest.waitForExplicitFinish();
 </script>
 </pre>
 </body>
-</html>
\ No newline at end of file
+</html>
--- a/layout/mathml/crashtests/400157.xhtml
+++ b/layout/mathml/crashtests/400157.xhtml
@@ -1,17 +1,16 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:mathml="http://www.w3.org/1998/Math/MathML" class="reftest-wait">
 <mathml:mfenced/>
 
 
 <script><![CDATA[
 var docviewer;
 function do_onload() {
-  var navigator1 = SpecialPowers.wrap(parent).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).getInterface(SpecialPowers.Ci.nsIWebNavigation);
-  var docShell = navigator1.QueryInterface(SpecialPowers.Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(parent).docShell;
   docviewer = docShell.contentViewer;
 
   setTimeout(function() {
     clearTimeout(timer);
     docviewer.textZoom = 1;
     document.documentElement.removeAttribute("class");
   }, 500);
   setTimeout(doe,50, 0.2);
--- a/layout/style/test/chrome/test_display_mode.html
+++ b/layout/style/test/chrome/test_display_mode.html
@@ -47,19 +47,17 @@ add_task(async function() {
     ok(queryApplies(q), q + " should apply");
   }
 
   function shouldNotApply(q) {
     ok(!queryApplies(q), q + " should not apply");
   }
 
   function setDisplayMode(mode) {
-    win.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIDocShell)
-                 .displayMode = mode;
+    win.docShell.displayMode = mode;
   }
 
   shouldApply("all and (display-mode: browser)");
   shouldNotApply("all and (display-mode: fullscreen)");
   shouldNotApply("all and (display-mode: standalone)");
   shouldNotApply("all and (display-mode: minimal-ui)");
 
   // Test entering the OS's fullscreen mode.
--- a/layout/style/test/test_restyles_in_smil_animation.html
+++ b/layout/style/test/test_restyles_in_smil_animation.html
@@ -28,20 +28,17 @@ function waitForAnimationFrames(frameCou
       }
     }
     window.requestAnimationFrame(handleFrame);
   });
 }
 
 function observeStyling(frameCount) {
   var Ci = SpecialPowers.Ci;
-  var docShell =
-    SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIWebNavigation)
-                              .QueryInterface(Ci.nsIDocShell);
+  var docShell = SpecialPowers.wrap(window).docShell;
 
   docShell.recordProfileTimelineMarkers = true;
   docShell.popProfileTimelineMarkers();
 
   return new Promise(function(resolve) {
     return waitForAnimationFrames(frameCount).then(function() {
       var markers = docShell.popProfileTimelineMarkers();
       docShell.recordProfileTimelineMarkers = false;
--- a/layout/xul/test/test_popupZoom.xul
+++ b/layout/xul/test/test_popupZoom.xul
@@ -14,20 +14,17 @@
   <script type="application/javascript"><![CDATA[
     SimpleTest.waitForExplicitFinish();
 
     var docviewer;
     var savedzoom;
 
     function openPopup()
     {
-      docviewer = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIWebNavigation)
-                        .QueryInterface(Ci.nsIDocShell)
-                        .contentViewer;
+      docviewer = window.docShell.contentViewer;
       savedzoom = docviewer.fullZoom;
       docviewer.fullZoom = 2;
 
       document.getElementById("panel").
         openPopup(document.getElementById("anchor"), "after_start", 0, 0, false, false, null);
     }
 
     function popupShown(event)
--- a/security/manager/ssl/tests/mochitest/mixedcontent/backward.html
+++ b/security/manager/ssl/tests/mochitest/mixedcontent/backward.html
@@ -2,17 +2,17 @@
 <html>
 <head>
   <script type="text/javascript">
   "use strict";
   window.onload = function()
   {
     window.setTimeout(function()
     {
-      SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-        .getInterface(SpecialPowers.Ci.nsIWebNavigation)
+      SpecialPowers.wrap(window).docShell
+        .QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
         .goBack();
     }, 100);
   };
 
   </script>
 </head>
 </html>
--- a/security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
+++ b/security/manager/ssl/tests/mochitest/mixedcontent/mixedContentTest.js
@@ -134,21 +134,17 @@ function is(a, b, message) {
   }
 }
 
 function isSecurityState(expectedState, message, test) {
   if (!test) {
     test = ok;
   }
 
-  let ui = SpecialPowers.wrap(window)
-    .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-    .getInterface(SpecialPowers.Ci.nsIWebNavigation)
-    .QueryInterface(SpecialPowers.Ci.nsIDocShell)
-    .securityUI;
+  let ui = SpecialPowers.wrap(window).docShell.securityUI;
 
   let isInsecure = !ui ||
     (ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_INSECURE);
   let isBroken = ui &&
     (ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IS_BROKEN);
   let isEV = ui &&
     (ui.state & SpecialPowers.Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
 
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -674,19 +674,17 @@ async function executeInSandbox(script, 
 function emitTouchEvent(type, touch) {
   logger.info(`Emitting Touch event of type ${type} ` +
       `to element with id: ${touch.target.id} ` +
       `and tag name: ${touch.target.tagName} ` +
       `at coordinates (${touch.clientX}), ` +
       `${touch.clientY}) relative to the viewport`);
 
   const win = curContainer.frame;
-  let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
-      .getInterface(Ci.nsIWebNavigation)
-      .QueryInterface(Ci.nsIDocShell);
+  let docShell = win.docShell;
   if (docShell.asyncPanZoomEnabled && legacyactions.scrolling) {
     let ev = {
       index: 0,
       type,
       id: touch.identifier,
       clientX: touch.clientX,
       clientY: touch.clientY,
       screenX: touch.screenX,
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -90,18 +90,18 @@ function testInit() {
     let messageHandler = function(m) {
       // eslint-disable-next-line no-undef
       messageManager.removeMessageListener("chromeEvent", messageHandler);
       var url = m.json.data;
 
       // Window is the [ChromeWindow] for messageManager, so we need content.window
       // Currently chrome tests are run in a content window instead of a ChromeWindow
       // eslint-disable-next-line no-undef
-      var webNav = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation);
+      var webNav = content.window.docShell
+                          .QueryInterface(Ci.nsIWebNavigation);
       webNav.loadURI(url, null, null, null, null);
     };
 
     var listener = 'data:,function doLoad(e) { var data=e.detail&&e.detail.data;removeEventListener("contentEvent", function (e) { doLoad(e); }, false, true);sendAsyncMessage("chromeEvent", {"data":data}); };addEventListener("contentEvent", function (e) { doLoad(e); }, false, true);';
     // eslint-disable-next-line no-undef
     messageManager.addMessageListener("chromeEvent", messageHandler);
     // eslint-disable-next-line no-undef
     messageManager.loadFrameScript(listener, true);
--- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html
+++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html
@@ -97,20 +97,18 @@ function starttest(){
   var testURI = SpecialPowers.Cc['@mozilla.org/network/standard-url-mutator;1']
                              .createInstance(SpecialPowers.Ci.nsIURIMutator)
                              .setSpec("http://www.foobar.org/")
                              .finalize();
   is(testURI.spec, "http://www.foobar.org/", "Getters/Setters should work correctly");
   is(SpecialPowers.wrap(document).getElementsByTagName('details').length, 0, "Should work with proxy-based DOM bindings.");
 
   // Play with the window object.
-  var webnav = SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
-                                         .getInterface(SpecialPowers.Ci.nsIWebNavigation);
-  webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
-  ok(webnav.allowJavascript, "Able to pull properties off of docshell!");
+  var docShell = SpecialPowers.wrap(window).docShell;
+  ok(docShell.allowJavascript, "Able to pull properties off of docshell!");
 
   // Make sure Xray-wrapped functions work.
   try {
     SpecialPowers.wrap(SpecialPowers.Components).ID('{00000000-0000-0000-0000-000000000000}');
     ok(true, "Didn't throw");
   }
   catch (e) {
     ok(false, "Threw while trying to call Xray-wrapped function.");
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -1400,19 +1400,17 @@ SpecialPowersAPI.prototype = {
       prefType,
       iid, // Only used with complex prefs
       prefValue,
     };
     return this._sendSyncMessage("SPPrefService", msg)[0];
   },
 
   _getDocShell(window) {
-    return window.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
-                 .QueryInterface(Ci.nsIDocShell);
+    return window.docShell;
   },
   _getMUDV(window) {
     return this._getDocShell(window).contentViewer;
   },
   // XXX: these APIs really ought to be removed, they're not e10s-safe.
   // (also they're pretty Firefox-specific)
   _getTopChromeWindow(window) {
     return window.docShell.rootTreeItem.domWindow
@@ -1744,20 +1742,19 @@ SpecialPowersAPI.prototype = {
   focus(aWindow) {
     // This is called inside TestRunner._makeIframe without aWindow, because of assertions in oop mochitests
     // With aWindow, it is called in SimpleTest.waitForFocus to allow popup window opener focus switching
     if (aWindow)
       aWindow.focus();
     var mm = global;
     if (aWindow) {
       try {
-        mm = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIDocShell)
-                                    .QueryInterface(Ci.nsIInterfaceRequestor)
-                                    .getInterface(Ci.nsIContentFrameMessageManager);
+        mm = aWindow.docShell
+                    .QueryInterface(Ci.nsIInterfaceRequestor)
+                    .getInterface(Ci.nsIContentFrameMessageManager);
       } catch (ex) {
         /* Ignore exceptions for e.g. XUL chrome windows from mochitest-chrome
          * which won't have a message manager */
       }
     }
     mm.sendAsyncMessage("SpecialPowers.Focus", {});
   },
 
--- a/testing/talos/talos/tests/cpstartup/content/cpstartup.html
+++ b/testing/talos/talos/tests/cpstartup/content/cpstartup.html
@@ -1,16 +1,15 @@
 <html>
   <head>
     <script>
 
       function init() {
         if (document.location.hash.indexOf("#auto") == 0) {
-          let mm = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation)
+          let mm = window.docShell
                          .QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIContentFrameMessageManager);
 
           mm.addMessageListener("CPStartup:FinalResults", function onResults(msg) {
             mm.removeMessageListener("CPStartup:FinalResults", onResults);
             let results = msg.data;
 
             tpRecordTime(results, 0, "content-process-startup");
--- a/testing/talos/talos/tests/tabpaint/content/tabpaint.html
+++ b/testing/talos/talos/tests/tabpaint/content/tabpaint.html
@@ -1,16 +1,15 @@
 <html>
   <head>
     <script>
 
       function init() {
         if (document.location.hash.indexOf("#auto") == 0) {
-          let mm = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIWebNavigation)
+          let mm = window.docShell
                          .QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIContentFrameMessageManager);
 
           mm.addMessageListener("TabPaint:FinalResults", function onResults(msg) {
             mm.removeMessageListener("TabPaint:FinalResults", onResults);
 
             let { fromParent, fromContent } = msg.data;
 
--- a/testing/talos/talos/tests/tabpaint/content/target.html
+++ b/testing/talos/talos/tests/tabpaint/content/target.html
@@ -47,17 +47,16 @@
     // paint occurring within the tab.
     let fetchStart = window.performance.timing.fetchStart;
     let presented = fetchStart + e.paintTimeStamp;
     removeEventListener("MozAfterPaint", onPaint);
 
     let opened = parseInt(location.search.substring(1), 10);
     let delta = presented - opened;
 
-    let mm = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                   .getInterface(Ci.nsIWebNavigation)
+    let mm = window.docShell
                    .QueryInterface(Ci.nsIInterfaceRequestor)
                    .getInterface(Ci.nsIContentFrameMessageManager);
 
     mm.sendAsyncMessage("TabPaint:Painted", { delta });
   });
 </script>
 </html>
--- a/uriloader/exthandler/tests/mochitest/handlerApps.js
+++ b/uriloader/exthandler/tests/mochitest/handlerApps.js
@@ -19,20 +19,17 @@ function test() {
   
   // set up the uri to test with
   var ioService = Cc["@mozilla.org/network/io-service;1"].
     getService(SpecialPowers.Ci.nsIIOService);
   var uri = ioService.newURI(testURI);
 
   // create a window, and launch the handler in it
   var newWindow = window.open("", "handlerWindow", "height=300,width=300");
-  var windowContext = 
-    SpecialPowers.wrap(newWindow).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
-    getInterface(SpecialPowers.Ci.nsIWebNavigation).
-    QueryInterface(SpecialPowers.Ci.nsIDocShell);
+  var windowContext = SpecialPowers.wrap(newWindow).docShell;
  
   webHandler.launchWithURI(uri, windowContext);
 
   // if we get this far without an exception, we've at least partly passed
   // (remaining check in handlerApp.xhtml)
   ok(true, "webHandler launchWithURI (existing window/tab) started");
 
   // make the web browser launch in its own window/tab
--- a/widget/nsITransferable.idl
+++ b/widget/nsITransferable.idl
@@ -105,18 +105,17 @@ interface nsITransferable : nsISupports
    * The load context is used to track whether the transferable is storing privacy-
    * sensitive information.  For example, we try to delete data that you copy
    * to the clipboard when you close a Private Browsing window.
    *
    * To get the appropriate load context in Javascript callers, one needs to get
    * to the document that the transferable corresponds to, and then get the load
    * context from the document like this:
    *
-   * var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
-   *                                  .getInterface(Ci.nsIWebNavigation)
+   * var loadContext = doc.defaultView.docShell
    *                                  .QueryInterface(Ci.nsILoadContext);
    *
    * In C++ callers, if you have the corresponding document, you can just call
    * nsIDocument::GetLoadContext to get to the load context object.
    *
    * @param aContext the load context associated with the transferable object.
    *        This can be set to null if a load context is not available.
    */
--- a/widget/tests/test_bug444800.xul
+++ b/widget/tests/test_bug444800.xul
@@ -35,19 +35,17 @@ function copyImageToClipboard()
                    .getControllerForCommand(kCmd);
   ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
   controller.doCommand(kCmd);
 
   document.popupNode = tmpNode;
 }
 
 function getLoadContext() {
-  return window.QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 function runImageClipboardTests(aCBSvc, aImageType)
 {
   // Verify that hasDataMatchingFlavors() is working correctly.
   var typeArray = [ aImageType ];
   var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray, typeArray.length,
                                                knsIClipboard.kGlobalClipboard);
--- a/widget/tests/test_bug466599.xul
+++ b/widget/tests/test_bug466599.xul
@@ -19,19 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <!-- test code goes here -->
   <script class="testbody" type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 466599 **/
 
 function getLoadContext() {
-  return window.QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 function copyToClipboard(txt)
 {
   var clipid = Ci.nsIClipboard;
   var clip =
     Cc['@mozilla.org/widget/clipboard;1'].createInstance(clipid);
   if (!clip)
--- a/widget/tests/test_bug565392.html
+++ b/widget/tests/test_bug565392.html
@@ -21,19 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   var ds = Cc["@mozilla.org/file/directory_service;1"]
              .getService(Ci.nsIProperties);
   var dir1 = ds.get("ProfD", Ci.nsIFile);
   var clipboard = Cc["@mozilla.org/widget/clipboard;1"]
                     .getService(Ci.nsIClipboard);
   
   function getLoadContext() {
-    return window.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
-                 .QueryInterface(Ci.nsILoadContext);
+    return window.docShell.QueryInterface(Ci.nsILoadContext);
   }
 
   function getTransferableFile(file) {
     var transferable = Cc['@mozilla.org/widget/transferable;1']
                          .createInstance(Ci.nsITransferable);
     transferable.init(getLoadContext());
     transferable.setTransferData("application/x-moz-file", file, 0);
     return transferable;
--- a/widget/tests/test_bug673301.xul
+++ b/widget/tests/test_bug673301.xul
@@ -9,19 +9,17 @@
 
 <body  xmlns="http://www.w3.org/1999/xhtml">
 <p id="display"></p>
 <div id="content" style="display: none"/>
 </body>
 
 <script type="application/javascript">
 function getLoadContext() {
-  return window.QueryInterface(Ci.nsIInterfaceRequestor)
-               .getInterface(Ci.nsIWebNavigation)
-               .QueryInterface(Ci.nsILoadContext);
+  return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
                           .getService(Components.interfaces.nsIClipboard);
 
 var transferable = Components.classes['@mozilla.org/widget/transferable;1']
                              .createInstance(Components.interfaces.nsITransferable);
 transferable.init(getLoadContext());
--- a/widget/tests/test_bug760802.xul
+++ b/widget/tests/test_bug760802.xul
@@ -18,29 +18,23 @@ https://bugzilla.mozilla.org/show_bug.cg
           src="data:text/html,&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;"/><br/>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function getBaseWindowInterface(win) {
-  return win.QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIWebNavigation)
-    .QueryInterface(Ci.nsIDocShellTreeItem)
+  return win.docShell
     .treeOwner
-    .QueryInterface(Ci.nsIInterfaceRequestor)
     .nsIBaseWindow;
 }
 
 function getBaseWindowInterfaceFromDocShell(win) {
-  return win.QueryInterface(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.nsIWebNavigation)
-    .QueryInterface(Ci.nsIDocShell)
-    .QueryInterface(Ci.nsIBaseWindow);
+  return win.docShell.QueryInterface(Ci.nsIBaseWindow);
 }
 
 function shouldThrowException(fun, exception) {
   try {
     fun.call();
     return false;
   } catch (e) {
     $("display").innerHTML += "<br/>OK thrown: "+e.message;
--- a/widget/tests/test_clipboard.xul
+++ b/widget/tests/test_clipboard.xul
@@ -21,19 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script class="testbody" type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 948065 **/
 
   const kIsMac = navigator.platform.indexOf("Mac") == 0;
 
   function getLoadContext() {
-    return window.QueryInterface(Ci.nsIInterfaceRequestor)
-                 .getInterface(Ci.nsIWebNavigation)
-                 .QueryInterface(Ci.nsILoadContext);
+    return window.docShell.QueryInterface(Ci.nsILoadContext);
   }
 
   // Get clipboard data to paste.
   function paste(clipboard) {
     let trans = Cc['@mozilla.org/widget/transferable;1']
                 .createInstance(Ci.nsITransferable);
     trans.init(getLoadContext());
     trans.addDataFlavor("text/unicode");
--- a/widget/tests/test_imestate.html
+++ b/widget/tests/test_imestate.html
@@ -1026,20 +1026,17 @@ function runComplexContenteditableTests(
   container.focus();
 
   is(gFM.focusedElement, container,
      description + "The editor doesn't get focus");
   is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
      description + "IME isn't enabled on HTML editor");
   const kReadonly =
     Ci.nsIPlaintextEditor.eEditorReadonlyMask;
-  var editor =
-    window.QueryInterface(Ci.nsIInterfaceRequestor).
-      getInterface(Ci.nsIWebNavigation).
-      QueryInterface(Ci.nsIDocShell).editor;
+  var editor = window.docShell.editor;
   var flags = editor.flags;
   editor.flags = flags | kReadonly;
   is(gFM.focusedElement, container,
      description + "The editor loses focus by flag change");
   is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
      description + "IME is still enabled on readonly HTML editor");
   editor.flags = flags;
   is(gFM.focusedElement, container,
@@ -1058,20 +1055,17 @@ function runComplexContenteditableTests(
      description + "The button doesn't get focus");
   is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
      description + "IME is enabled on the button");
   container.setAttribute("contenteditable", "true");
   is(gFM.focusedElement, button,
      description + "The button loses focus, the container is editable now");
   todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
           description + "IME is still disabled on the button, the container is editable now");
-  editor =
-    window.QueryInterface(Ci.nsIInterfaceRequestor).
-      getInterface(Ci.nsIWebNavigation).
-      QueryInterface(Ci.nsIDocShell).editor;
+  editor = window.docShell.editor;
   flags = editor.flags;
   editor.flags = flags | kReadonly;
   is(gFM.focusedElement, button,
      description + "The button loses focus by changing editor flags");
   is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
      description + "IME is still enabled on the button, the container is readonly now");
   editor.flags = flags;
   is(gFM.focusedElement, button,
@@ -1100,20 +1094,17 @@ function runComplexContenteditableTests(
          " on the " + aEditorDescription);
     container.setAttribute("contenteditable", "true");
     is(gFM.focusedElement, aEditor,
        description + "The " + aEditorDescription +
          " loses focus, the container is editable now");
     is(gUtils.IMEStatus, expectedState,
        description + "IME becomes " + unexpectedStateDescription +
          " on the " + aEditorDescription + ", the container is editable now");
-    editor =
-      window.QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIWebNavigation).
-        QueryInterface(Ci.nsIDocShell).editor;
+    editor = window.docShell.editor;
     flags = editor.flags;
     editor.flags = flags | kReadonly;
     is(gFM.focusedElement, aEditor,
        description + "The " + aEditorDescription +
          " loses focus by changing editor flags");
     is(gUtils.IMEStatus, expectedState,
        description + "IME becomes " + unexpectedStateDescription + " on the " +
          aEditorDescription + ", the container is readonly now");
@@ -1168,20 +1159,17 @@ function runComplexContenteditableTests(
     aEditor.setAttribute("contenteditable", "true");
     is(gFM.focusedElement, aFocusNode,
        description + "The " + aFocusNodeDescription +
          " loses focus, a HTML editor is editable now");
     is(gUtils.IMEStatus, expectedState,
        description + "IME becomes " + unexpectedStateDescription +
          " on the " + aFocusNodeDescription +
          ", the HTML editor is editable now");
-    editor =
-      window.QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIWebNavigation).
-        QueryInterface(Ci.nsIDocShell).editor;
+    editor = window.docShell.editor;
     flags = editor.flags;
     editor.flags = flags | kReadonly;
     is(gFM.focusedElement, aFocusNode,
        description + aFocusNodeDescription +
          " loses focus by changing HTML editor flags");
     is(gUtils.IMEStatus, expectedState,
        description + "IME becomes " + unexpectedStateDescription + " on " +
          aFocusNodeDescription + ", the HTML editor is readonly now");
@@ -1239,20 +1227,17 @@ function runEditorFlagChangeTests()
   is(gFM.focusedElement, container,
      description + "The editor doesn't get focus");
   is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
      description + "IME isn't enabled on HTML editor");
   const kIMEStateChangeFlags =
     Ci.nsIPlaintextEditor.eEditorPasswordMask |
     Ci.nsIPlaintextEditor.eEditorReadonlyMask |
     Ci.nsIPlaintextEditor.eEditorDisabledMask;
-  var editor =
-    window.QueryInterface(Ci.nsIInterfaceRequestor).
-      getInterface(Ci.nsIWebNavigation).
-      QueryInterface(Ci.nsIDocShell).editor;
+  var editor = window.docShell.editor;
   var flags = editor.flags;
 
   // input characters
   synthesizeCompositionChange(
     { "composition":
       { "string": "\u3078\u3093\u3057\u3093",
         "clauses":
         [
--- a/widget/tests/test_keycodes.xul
+++ b/widget/tests/test_keycodes.xul
@@ -82,19 +82,17 @@ function isModifierKeyEvent(aEvent)
 }
 
 /**
  * Firefox infobar UI can have access keys which conflict with this test. Really
  * stupid workaround until we can move this test into its own chrome window.
  */
 function clearInfobars()
 {
-  var browser = window.top.QueryInterface(Ci.nsIInterfaceRequestor)
-                  .getInterface(Ci.nsIWebNavigation)
-                  .QueryInterface(Ci.nsIDocShell).chromeEventHandler;
+  var browser = window.top.docShell.chromeEventHandler;
   var chromeWin = browser.ownerGlobal;
   var nb = chromeWin.gBrowser.getNotificationBox(browser);
   for (let n of nb.allNotifications) {
     nb.removeNotification(n, true);
   }
 }
 
 function eventToString(aEvent)
--- a/widget/tests/window_composition_text_querycontent.xul
+++ b/widget/tests/window_composition_text_querycontent.xul
@@ -130,20 +130,17 @@ function hitEventLoop(aFunc, aTimes)
 
 function getEditor(aNode)
 {
   return aNode.editor;
 }
 
 function getHTMLEditorIMESupport(aWindow)
 {
-  return aWindow.QueryInterface(nsIInterfaceRequestor).
-                 getInterface(nsIWebNavigation).
-                 QueryInterface(nsIDocShell).
-                 editor;
+  return aWindow.docShell.editor;
 }
 
 const kIsWin = (navigator.platform.indexOf("Win") == 0);
 const kIsMac = (navigator.platform.indexOf("Mac") == 0);
 
 const kLFLen = kIsWin ? 2 : 1;
 const kLF = kIsWin ? "\r\n" : "\n";
 
--- a/widget/tests/window_imestate_iframes.html
+++ b/widget/tests/window_imestate_iframes.html
@@ -178,21 +178,17 @@ function runTests()
   }
 
   function testOnEditorFlagChange(aDescription, aIsInDesignMode)
   {
     const kReadonly =
       Ci.nsIPlaintextEditor.eEditorReadonlyMask;
     var description = "testOnEditorFlagChange: " + aDescription;
     resetFocusToParentHTML(description);
-    var htmlEditor =
-      iframe.contentWindow.
-        QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIWebNavigation).
-        QueryInterface(Ci.nsIDocShell).editor;
+    var htmlEditor = iframe.contentWindow.docShell.editor;
     var e = aIsInDesignMode ? root : editor;
     e.focus();
     is(fm.focusedElement, e,
        description + ": focus() of editor didn't move focus as expected");
     is(utils.IMEStatus, utils.IME_STATUS_ENABLED,
        description + ": IME isn't enabled when the editor gets focus");
     var flags = htmlEditor.flags;
     htmlEditor.flags |= kReadonly;