Backed out 6 changesets (bug 1553804) for browser-chrome failure at browser/base/content/test/general/browser_fullscreen-window-open.js. On a CLOSED TREE
authorDaniel Varga <dvarga@mozilla.com>
Fri, 20 Sep 2019 10:09:54 +0300
changeset 494187 af0fe61c3db069df2d363b611e6d466851c6a46f
parent 494186 e56ef27b142a02fe06c83dd12b800d997abba3c3
child 494188 52cb15e3f79439a2e7207eb1f4a785a58c675d08
child 494194 088c878f9f7cb9c8033f35bf591f246754048f87
push id36596
push userapavel@mozilla.com
push dateFri, 20 Sep 2019 09:45:58 +0000
treeherdermozilla-central@52cb15e3f794 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1553804
milestone71.0a1
backs out86b3d469b4ff9f22e5757f83450b956a4c769785
301e0d883a5f39053ab02ba11133f1b23156e240
acff4a6636719d9302d1a893e1f3ca392c8f99e5
1574aecf31775e67f4810595207f3e807b4a0e4e
3acf056e792ec386ff9c534237c4f8025dcb747c
1ed250faeb2e8a83167f2d8358a6dc4a396ead78
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 6 changesets (bug 1553804) for browser-chrome failure at browser/base/content/test/general/browser_fullscreen-window-open.js. On a CLOSED TREE Backed out changeset 86b3d469b4ff (bug 1553804) Backed out changeset 301e0d883a5f (bug 1553804) Backed out changeset acff4a663671 (bug 1553804) Backed out changeset 1574aecf3177 (bug 1553804) Backed out changeset 3acf056e792e (bug 1553804) Backed out changeset 1ed250faeb2e (bug 1553804)
accessible/tests/mochitest/browser.js
accessible/tests/mochitest/events/docload/test_docload_root.html
accessible/tests/mochitest/events/docload/test_docload_shutdown.html
accessible/tests/mochitest/focus/test_focusedChild.html
browser/base/content/test/general/browser_bug484315.js
browser/components/extensions/test/browser/browser_ext_sidebarAction.js
browser/components/preferences/in-content/subdialogs.js
browser/modules/SiteDataManager.jsm
devtools/client/responsive/test/browser/browser_window_close.js
devtools/client/shared/test/browser_dbg_multiple-windows.js
docshell/base/BrowsingContext.cpp
docshell/base/BrowsingContext.h
docshell/test/browser/browser_bug388121-2.js
docshell/test/chrome/bug112564_window.xul
docshell/test/chrome/bug113934_window.xul
docshell/test/chrome/bug215405_window.xul
docshell/test/chrome/bug364461_window.xul
docshell/test/chrome/bug396519_window.xul
docshell/test/chrome/bug449778_window.xul
docshell/test/chrome/bug449780_window.xul
docshell/test/chrome/bug89419_window.xul
docshell/test/chrome/bug92598_window.xul
docshell/test/chrome/docshell_helpers.js
docshell/test/chrome/mozFrameType_window.xul
docshell/test/chrome/test_bug112564.xul
docshell/test/chrome/test_bug113934.xul
docshell/test/chrome/test_bug215405.xul
docshell/test/chrome/test_bug293235.xul
docshell/test/chrome/test_bug294258.xul
docshell/test/chrome/test_bug298622.xul
docshell/test/chrome/test_bug301397.xul
docshell/test/chrome/test_bug303267.xul
docshell/test/chrome/test_bug311007.xul
docshell/test/chrome/test_bug321671.xul
docshell/test/chrome/test_bug360511.xul
docshell/test/chrome/test_bug364461.xul
docshell/test/chrome/test_bug396519.xul
docshell/test/chrome/test_bug396649.xul
docshell/test/chrome/test_bug449778.xul
docshell/test/chrome/test_bug449780.xul
docshell/test/chrome/test_bug456980.xul
docshell/test/chrome/test_bug582176.xul
docshell/test/chrome/test_bug608669.xul
docshell/test/chrome/test_bug662200.xul
docshell/test/chrome/test_bug690056.xul
docshell/test/chrome/test_bug89419.xul
docshell/test/chrome/test_bug92598.xul
docshell/test/chrome/test_mozFrameType.xul
docshell/test/chrome/test_principalInherit.xul
dom/base/test/chrome/cpows_parent.xul
dom/base/test/chrome/file_bug1139964.xul
dom/base/test/chrome/file_bug1209621.xul
dom/base/test/chrome/file_bug549682.xul
dom/base/test/chrome/file_bug616841.xul
dom/base/test/chrome/file_bug816340.xul
dom/base/test/chrome/file_bug990812-1.xul
dom/base/test/chrome/file_bug990812-2.xul
dom/base/test/chrome/file_bug990812-3.xul
dom/base/test/chrome/file_bug990812-4.xul
dom/base/test/chrome/file_bug990812-5.xul
dom/base/test/chrome/test_bug1139964.xul
dom/base/test/chrome/test_bug1209621.xul
dom/base/test/chrome/test_bug549682.xul
dom/base/test/chrome/test_bug616841.xul
dom/base/test/chrome/test_bug814638.xul
dom/base/test/chrome/test_bug816340.xul
dom/base/test/chrome/test_bug990812.xul
dom/base/test/chrome/test_chromeOuterWindowID.xul
dom/base/test/chrome/test_cpows.xul
dom/base/test/chrome/test_document-element-inserted.xul
dom/base/test/chrome/test_nsITextInputProcessor.xul
dom/base/test/chrome/test_swapFrameLoaders.xul
dom/base/test/chrome/test_title.xul
dom/base/test/chrome/title_window.xul
dom/base/test/chrome/window_nsITextInputProcessor.xul
dom/base/test/chrome/window_swapFrameLoaders.xul
dom/base/test/test_bug1016960.html
dom/canvas/test/chrome/test_drawWindow_widget_layers.html
dom/events/test/test_bug1412775.xul
dom/events/test/test_bug617528.xul
dom/ipc/tests/process_error.xul
dom/ipc/tests/test_process_error.xul
dom/messagechannel/tests/mm_messageChannelParent.js
dom/messagechannel/tests/test_messageChannelWithMessageManager.xul
dom/messagechannel/tests/test_messageChannelWithMessageManagerNotRemote.xul
dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul
dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
dom/tests/browser/browser_test_toolbars_visibility.js
dom/tests/mochitest/chrome/DOMWindowCreated_chrome.xul
dom/tests/mochitest/chrome/MozDomFullscreen_chrome.xul
dom/tests/mochitest/chrome/file_DOM_element_instanceof.xul
dom/tests/mochitest/chrome/file_bug1224790-1_modal.xul
dom/tests/mochitest/chrome/file_bug1224790-2_modal.xul
dom/tests/mochitest/chrome/file_bug799299.xul
dom/tests/mochitest/chrome/file_bug800817.xul
dom/tests/mochitest/chrome/file_bug830858.xul
dom/tests/mochitest/chrome/file_clipboard_events_chrome.html
dom/tests/mochitest/chrome/fullscreen.xul
dom/tests/mochitest/chrome/sizemode_attribute.xul
dom/tests/mochitest/chrome/test_DOMWindowCreated.xul
dom/tests/mochitest/chrome/test_DOM_element_instanceof.xul
dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul
dom/tests/mochitest/chrome/test_activation.xul
dom/tests/mochitest/chrome/test_bug1224790-1.xul
dom/tests/mochitest/chrome/test_bug1224790-2.xul
dom/tests/mochitest/chrome/test_bug799299.xul
dom/tests/mochitest/chrome/test_bug800817.xul
dom/tests/mochitest/chrome/test_bug830858.xul
dom/tests/mochitest/chrome/test_clipboard_events_chrome.html
dom/tests/mochitest/chrome/test_docshell_swap.xul
dom/tests/mochitest/chrome/test_focus.xul
dom/tests/mochitest/chrome/test_focus_docnav.xul
dom/tests/mochitest/chrome/test_fullscreen.xul
dom/tests/mochitest/chrome/test_sizemode_attribute.xul
dom/tests/mochitest/chrome/window_activation.xul
dom/tests/mochitest/chrome/window_focus.xul
dom/tests/mochitest/chrome/window_focus_docnav.xul
dom/xul/test/test_bug583948.xul
dom/xul/test/test_bug757137.xul
js/xpconnect/tests/chrome/bug503926.xul
js/xpconnect/tests/chrome/file_bug618176.xul
js/xpconnect/tests/chrome/test_bug1124898.html
js/xpconnect/tests/chrome/test_bug503926.xul
js/xpconnect/tests/chrome/test_bug618176.xul
layout/base/tests/chrome/bug1041200_window.html
layout/base/tests/chrome/chrome_content_integration_window.xul
layout/base/tests/chrome/chrome_over_plugin_window.xul
layout/base/tests/chrome/default_background_window.xul
layout/base/tests/chrome/dialog_with_positioning_window.xul
layout/base/tests/chrome/file_bug1018265.xul
layout/base/tests/chrome/printpreview_bug396024_helper.xul
layout/base/tests/chrome/printpreview_bug482976_helper.xul
layout/base/tests/chrome/printpreview_helper.xul
layout/base/tests/chrome/test_bug1018265.xul
layout/base/tests/chrome/test_bug1041200.xul
layout/base/tests/chrome/test_bug458898.html
layout/base/tests/chrome/test_chrome_content_integration.xul
layout/base/tests/chrome/test_chrome_over_plugin.xul
layout/base/tests/chrome/test_css_visibility_propagation.xul
layout/base/tests/chrome/test_default_background.xul
layout/base/tests/chrome/test_dialog_with_positioning.html
layout/base/tests/chrome/test_printpreview.xul
layout/base/tests/chrome/test_printpreview_bug396024.xul
layout/base/tests/chrome/test_printpreview_bug482976.xul
layout/generic/test/file_bug514732_window.xul
layout/generic/test/test_bug514732-2.xul
layout/xul/test/test_resizer.xul
layout/xul/test/test_windowminmaxsize.xul
layout/xul/test/window_resizer.xul
layout/xul/test/window_resizer_element.xul
testing/mochitest/tests/SimpleTest/SimpleTest.js
toolkit/components/aboutmemory/tests/test_aboutmemory5.xul
toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xul
toolkit/components/aboutmemory/tests/test_memoryReporters2.xul
toolkit/components/antitracking/test/browser/antitracking_head.js
toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul
toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul
toolkit/components/prompts/src/Prompter.jsm
toolkit/components/windowwatcher/nsWindowWatcher.cpp
toolkit/components/windowwatcher/test/file_test_dialog.html
toolkit/components/windowwatcher/test/test_dialog_arguments.html
toolkit/components/windowwatcher/test/test_modal_windows.html
toolkit/components/xulstore/tests/chrome/test_persistence.xul
toolkit/components/xulstore/tests/chrome/window_persistence.xul
toolkit/content/tests/chrome/bug263683_window.xul
toolkit/content/tests/chrome/bug304188_window.xul
toolkit/content/tests/chrome/bug331215_window.xul
toolkit/content/tests/chrome/bug360437_window.xul
toolkit/content/tests/chrome/bug366992_window.xul
toolkit/content/tests/chrome/bug409624_window.xul
toolkit/content/tests/chrome/bug429723_window.xul
toolkit/content/tests/chrome/bug451540_window.xul
toolkit/content/tests/chrome/bug624329_window.xul
toolkit/content/tests/chrome/findbar_entireword_window.xul
toolkit/content/tests/chrome/findbar_events_window.xul
toolkit/content/tests/chrome/findbar_window.xul
toolkit/content/tests/chrome/frame_popup_anchor.xul
toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xul
toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xul
toolkit/content/tests/chrome/test_browser_drop.xul
toolkit/content/tests/chrome/test_bug263683.xul
toolkit/content/tests/chrome/test_bug304188.xul
toolkit/content/tests/chrome/test_bug331215.xul
toolkit/content/tests/chrome/test_bug360437.xul
toolkit/content/tests/chrome/test_bug366992.xul
toolkit/content/tests/chrome/test_bug409624.xul
toolkit/content/tests/chrome/test_bug429723.xul
toolkit/content/tests/chrome/test_bug451540.xul
toolkit/content/tests/chrome/test_bug624329.xul
toolkit/content/tests/chrome/test_chromemargin.xul
toolkit/content/tests/chrome/test_cursorsnap.xul
toolkit/content/tests/chrome/test_dialogfocus.xul
toolkit/content/tests/chrome/test_edit_contextmenu.html
toolkit/content/tests/chrome/test_findbar.xul
toolkit/content/tests/chrome/test_findbar_entireword.xul
toolkit/content/tests/chrome/test_findbar_events.xul
toolkit/content/tests/chrome/test_keys.xul
toolkit/content/tests/chrome/test_largemenu.html
toolkit/content/tests/chrome/test_maximized_persist.xul
toolkit/content/tests/chrome/test_menuitem_commands.xul
toolkit/content/tests/chrome/test_navigate_persist.html
toolkit/content/tests/chrome/test_panel.xul
toolkit/content/tests/chrome/test_panel_anchoradjust.xul
toolkit/content/tests/chrome/test_panel_focus.xul
toolkit/content/tests/chrome/test_popup_anchor.xul
toolkit/content/tests/chrome/test_popup_anchoratrect.xul
toolkit/content/tests/chrome/test_popup_preventdefault_chrome.xul
toolkit/content/tests/chrome/test_preferences.xul
toolkit/content/tests/chrome/test_preferences_beforeaccept.xul
toolkit/content/tests/chrome/test_preferences_onsyncfrompreference.xul
toolkit/content/tests/chrome/test_screenPersistence.xul
toolkit/content/tests/chrome/test_showcaret.xul
toolkit/content/tests/chrome/test_subframe_origin.xul
toolkit/content/tests/chrome/test_titlebar.xul
toolkit/content/tests/chrome/test_tooltip.xul
toolkit/content/tests/chrome/test_window_intrinsic_size.xul
toolkit/content/tests/chrome/window_browser_drop.xul
toolkit/content/tests/chrome/window_chromemargin.xul
toolkit/content/tests/chrome/window_cursorsnap_dialog.xul
toolkit/content/tests/chrome/window_keys.xul
toolkit/content/tests/chrome/window_largemenu.xul
toolkit/content/tests/chrome/window_maximized_persist.xul
toolkit/content/tests/chrome/window_panel.xul
toolkit/content/tests/chrome/window_panel_anchoradjust.xul
toolkit/content/tests/chrome/window_panel_focus.xul
toolkit/content/tests/chrome/window_popup_anchor.xul
toolkit/content/tests/chrome/window_popup_anchoratrect.xul
toolkit/content/tests/chrome/window_popup_preventdefault_chrome.xul
toolkit/content/tests/chrome/window_subframe_origin.xul
toolkit/content/tests/chrome/window_titlebar.xul
toolkit/content/tests/chrome/window_tooltip.xul
toolkit/content/tests/widgets/popup_shared.js
toolkit/mozapps/handling/ContentDispatchChooser.jsm
widget/tests/bug586713_window.xul
widget/tests/chrome_context_menus_win.xul
widget/tests/native_menus_window.xul
widget/tests/native_mouse_mac_window.xul
widget/tests/standalone_native_menu_window.xul
widget/tests/system_font_changes.xul
widget/tests/test_bug1123480.xul
widget/tests/test_bug429954.xul
widget/tests/test_bug478536.xul
widget/tests/test_bug522217.xul
widget/tests/test_bug538242.xul
widget/tests/test_bug586713.xul
widget/tests/test_chrome_context_menus_win.xul
widget/tests/test_composition_text_querycontent.xul
widget/tests/test_input_events_on_deactive_window.xul
widget/tests/test_mouse_scroll.xul
widget/tests/test_native_menus.xul
widget/tests/test_native_mouse_mac.xul
widget/tests/test_picker_no_crash.html
widget/tests/test_position_on_resize.xul
widget/tests/test_secure_input.html
widget/tests/test_standalone_native_menu.xul
widget/tests/test_system_font_changes.xul
widget/tests/test_transferable_overflow.xul
widget/tests/test_wheeltransaction.xul
widget/tests/window_bug429954.xul
widget/tests/window_bug478536.xul
widget/tests/window_bug522217.xul
widget/tests/window_composition_text_querycontent.xul
widget/tests/window_imestate_iframes.html
widget/tests/window_mouse_scroll_win.html
widget/tests/window_wheeltransaction.xul
--- a/accessible/tests/mochitest/browser.js
+++ b/accessible/tests/mochitest/browser.js
@@ -114,17 +114,17 @@ function openBrowserWindowIntl() {
     if ("width" in rect) {
       params += ",width=" + rect.width;
     }
     if ("height" in rect) {
       params += ",height=" + rect.height;
     }
   }
 
-  gBrowserContext.browserWnd = window.docShell.rootTreeItem.domWindow.openDialog(
+  gBrowserContext.browserWnd = window.openDialog(
     AppConstants.BROWSER_CHROME_URL,
     "_blank",
     params,
     gBrowserContext.startURL || "data:text/html,<html></html>"
   );
 
   whenDelayedStartupFinished(browserWindow(), function() {
     addA11yLoadEvent(startBrowserTests, browserWindow());
--- a/accessible/tests/mochitest/events/docload/test_docload_root.html
+++ b/accessible/tests/mochitest/events/docload/test_docload_root.html
@@ -33,17 +33,17 @@
         } catch (e) {
           ok(false, `Can't get parent for ${prettyName(docAcc)}`);
           throw e;
         }
       }
 
       this.eventSeq = [ new invokerChecker(EVENT_REORDER, gRootAcc) ];
 
-      this.invoke = () => (gDialog = docShell.rootTreeItem.domWindow.openDialog(aURL));
+      this.invoke = () => (gDialog = window.openDialog(aURL));
 
       this.finalCheck = () => {
         const accTree = {
           role: ROLE_APP_ROOT,
           children: [
             {
               role: ROLE_CHROME_WINDOW,
             },
--- a/accessible/tests/mochitest/events/docload/test_docload_shutdown.html
+++ b/accessible/tests/mochitest/events/docload/test_docload_shutdown.html
@@ -49,17 +49,17 @@
           },
           get targetDescr() {
             return "inner iframe of docload_wnd.html document";
           },
         },
       ];
 
 
-      this.invoke = () => gDialog = window.docShell.rootTreeItem.domWindow.openDialog(aURL);
+      this.invoke = () => gDialog = window.openDialog(aURL);
 
       this.finalCheck = () => {
         const accTree = {
           role: ROLE_APP_ROOT,
           children: [
             {
               role: ROLE_CHROME_WINDOW,
             },
--- a/accessible/tests/mochitest/focus/test_focusedChild.html
+++ b/accessible/tests/mochitest/focus/test_focusedChild.html
@@ -19,18 +19,17 @@
 
   <script type="application/javascript">
     function openWnd() {
       this.eventSeq = [ new invokerChecker(EVENT_FOCUS,
                                            getDialogAccessible,
                                            this) ];
 
       this.invoke = function openWnd_invoke() {
-        this.dialog = window.docShell.rootTreeItem.domWindow
-                            .openDialog("about:mozilla",
+        this.dialog = window.openDialog("about:mozilla",
                                         "AboutMozilla",
                                         "chrome,width=600,height=600");
       };
 
       this.finalCheck = function openWnd_finalCheck() {
         var app = getApplicationAccessible();
         is(app.focusedChild, getDialogAccessible(this),
            "Wrong focused child");
--- a/browser/base/content/test/general/browser_bug484315.js
+++ b/browser/base/content/test/general/browser_bug484315.js
@@ -1,14 +1,24 @@
-add_task(async function test() {
-  window.open("about:blank", "", "width=100,height=100,noopener");
+function test() {
+  var contentWin = window.open("about:blank", "", "width=100,height=100");
+  for (let win of Services.wm.getEnumerator("navigator:browser")) {
+    if (win.content == contentWin) {
+      Services.prefs.setBoolPref("browser.tabs.closeWindowWithLastTab", false);
+      win.gBrowser.removeCurrentTab();
+      ok(win.closed, "popup is closed");
 
-  let win = Services.wm.getMostRecentWindow("navigator:browser");
-  Services.prefs.setBoolPref("browser.tabs.closeWindowWithLastTab", false);
-  win.gBrowser.removeCurrentTab();
-  ok(win.closed, "popup is closed");
+      // clean up
+      if (!win.closed) {
+        win.close();
+      }
+      if (
+        Services.prefs.prefHasUserValue("browser.tabs.closeWindowWithLastTab")
+      ) {
+        Services.prefs.clearUserPref("browser.tabs.closeWindowWithLastTab");
+      }
 
-  // clean up
-  if (!win.closed) {
-    win.close();
+      return;
+    }
   }
-  Services.prefs.clearUserPref("browser.tabs.closeWindowWithLastTab");
-});
+
+  throw new Error("couldn't find the content window");
+}
--- a/browser/components/extensions/test/browser/browser_ext_sidebarAction.js
+++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction.js
@@ -175,18 +175,17 @@ add_task(async function sidebar_isOpen()
     result: true,
   });
   await sendMessage(extension2, "isOpen", {
     arg: { windowId: WINDOW_ID_CURRENT },
     result: false,
   });
 
   info("Open a new window");
-  open("", "", "noopener");
-  let newWin = Services.wm.getMostRecentWindow("navigator:browser");
+  let newWin = open();
 
   info("The new window has no sidebar");
   await sendMessage(extension1, "isOpen", { result: false });
   await sendMessage(extension2, "isOpen", { result: false });
 
   info("But the original window still does");
   await sendMessage(extension1, "isOpen", { arg: { windowId }, result: true });
   await sendMessage(extension2, "isOpen", { arg: { windowId }, result: false });
--- a/browser/components/preferences/in-content/subdialogs.js
+++ b/browser/components/preferences/in-content/subdialogs.js
@@ -95,18 +95,17 @@ SubDialog.prototype = {
       this._closingPromise.then(() => {
         this.open.apply(this, args);
       });
       return;
     }
     this._addDialogEventListeners();
 
     let features =
-      (aFeatures ? aFeatures + "," : "") +
-      "resizable,dialog=no,centerscreen,chrome=no";
+      (aFeatures ? aFeatures + "," : "") + "resizable,dialog=no,centerscreen";
     let dialog = window.openDialog(
       aURL,
       `dialogFrame-${this._id}`,
       features,
       aParams
     );
     if (aClosingCallback) {
       this._closingCallback = aClosingCallback.bind(dialog);
--- a/browser/modules/SiteDataManager.jsm
+++ b/browser/modules/SiteDataManager.jsm
@@ -503,17 +503,17 @@ var SiteDataManager = {
    */
   promptSiteDataRemoval(win, removals) {
     if (removals) {
       let args = {
         hosts: removals,
         allowed: false,
       };
       let features = "centerscreen,chrome,modal,resizable=no";
-      win.docShell.rootTreeItem.domWindow.openDialog(
+      win.openDialog(
         "chrome://browser/content/preferences/siteDataRemoveSelected.xul",
         "",
         features,
         args
       );
       return args.allowed;
     }
 
--- a/devtools/client/responsive/test/browser/browser_window_close.js
+++ b/devtools/client/responsive/test/browser/browser_window_close.js
@@ -1,16 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 add_task(async function() {
   const newWindowPromise = BrowserTestUtils.waitForNewWindow();
-  window.open("data:text/html;charset=utf-8,", "_blank", "noopener,all");
+  window.open("data:text/html;charset=utf-8,", "_blank");
   const newWindow = await newWindowPromise;
 
   newWindow.focus();
   await BrowserTestUtils.browserLoaded(newWindow.gBrowser.selectedBrowser);
 
   const tab = newWindow.gBrowser.selectedTab;
   await openRDM(tab);
 
--- a/devtools/client/shared/test/browser_dbg_multiple-windows.js
+++ b/devtools/client/shared/test/browser_dbg_multiple-windows.js
@@ -107,11 +107,11 @@ async function continue_remove_tab(clien
   ok(!foundTab2, "Tab2 should be gone.");
 
   ok(tabs[0].selected, "The previously opened tab is selected.");
 }
 
 async function addWindow(url) {
   info("Adding window: " + url);
   const onNewWindow = BrowserTestUtils.waitForNewWindow({ url });
-  window.open(url, "_blank", "noopener");
+  window.open(url);
   return onNewWindow;
 }
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -96,18 +96,16 @@ CanonicalBrowsingContext* BrowsingContex
 }
 
 /* static */
 already_AddRefed<BrowsingContext> BrowsingContext::Create(
     BrowsingContext* aParent, BrowsingContext* aOpener, const nsAString& aName,
     Type aType) {
   MOZ_DIAGNOSTIC_ASSERT(!aParent || aParent->mType == aType);
 
-  MOZ_DIAGNOSTIC_ASSERT(aType != Type::Chrome || XRE_IsParentProcess());
-
   uint64_t id = nsContentUtils::GenerateBrowsingContextId();
 
   MOZ_LOG(GetLog(), LogLevel::Debug,
           ("Creating 0x%08" PRIx64 " in %s", id,
            XRE_IsParentProcess() ? "Parent" : "Child"));
 
   // Determine which BrowsingContextGroup this context should be created in.
   RefPtr<BrowsingContextGroup> group =
@@ -120,18 +118,16 @@ already_AddRefed<BrowsingContext> Browsi
   } else {
     context = new BrowsingContext(aParent, group, id, aType);
   }
 
   // The name and opener fields need to be explicitly initialized. Don't bother
   // using transactions to set them, as we haven't been attached yet.
   context->mName = aName;
   if (aOpener) {
-    MOZ_DIAGNOSTIC_ASSERT(aOpener->Group() == context->Group());
-    MOZ_DIAGNOSTIC_ASSERT(aOpener->mType == context->mType);
     context->mOpenerId = aOpener->Id();
     context->mHadOriginalOpener = true;
   }
   context->mEmbedderPolicy = nsILoadInfo::EMBEDDER_POLICY_NULL;
 
   BrowsingContext* inherit = aParent ? aParent : aOpener;
   if (inherit) {
     context->mOpenerPolicy = inherit->Top()->mOpenerPolicy;
@@ -1028,17 +1024,17 @@ void BrowsingContext::Transaction::Apply
     aBrowsingContext->m##name = std::move(*m##name); \
     aBrowsingContext->DidSet##name();                \
     m##name.reset();                                 \
   }
 #include "mozilla/dom/BrowsingContextFieldList.h"
 }
 
 BrowsingContext::IPCInitializer BrowsingContext::GetIPCInitializer() {
-  MOZ_DIAGNOSTIC_ASSERT(mType == Type::Content);
+  // FIXME: We should assert that we're loaded in-content here. (bug 1553804)
 
   IPCInitializer init;
   init.mId = Id();
   init.mParentId = mParent ? mParent->Id() : 0;
   init.mCached = IsCached();
 
 #define MOZ_BC_FIELD(name, type) init.m##name = m##name;
 #include "mozilla/dom/BrowsingContextFieldList.h"
--- a/docshell/base/BrowsingContext.h
+++ b/docshell/base/BrowsingContext.h
@@ -207,24 +207,22 @@ class BrowsingContext : public nsWrapper
 
   BrowsingContext* GetParent() const { return mParent; }
 
   BrowsingContext* Top();
 
   already_AddRefed<BrowsingContext> GetOpener() const {
     RefPtr<BrowsingContext> opener(Get(mOpenerId));
     if (!mIsDiscarded && opener && !opener->mIsDiscarded) {
-      MOZ_DIAGNOSTIC_ASSERT(opener->mType == mType);
       return opener.forget();
     }
     return nullptr;
   }
   void SetOpener(BrowsingContext* aOpener) {
     MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->Group() == Group());
-    MOZ_DIAGNOSTIC_ASSERT(!aOpener || aOpener->mType == mType);
     SetOpenerId(aOpener ? aOpener->Id() : 0);
   }
 
   bool HasOpener() const;
 
   bool HadOriginalOpener() const { return mHadOriginalOpener; }
 
   /**
--- a/docshell/test/browser/browser_bug388121-2.js
+++ b/docshell/test/browser/browser_bug388121-2.js
@@ -33,18 +33,17 @@ function test() {
     } else {
       ++iteration;
       doTest();
     }
   }
 
   function doTest() {
     uri = uris[iteration - 1];
-    window.open(uri, "_blank", "width=10,height=10,noopener");
-    w = Services.wm.getMostRecentWindow("navigator:browser").content;
+    w = window.open(uri, "_blank", "width=10,height=10");
     var prin = w.document.nodePrincipal;
     if (!uri) {
       uri = undefined;
     }
     isnot(prin, null, "Forced principal must not be null when loading " + uri);
     isnot(
       prin,
       undefined,
--- a/docshell/test/chrome/bug112564_window.xul
+++ b/docshell/test/chrome/bug112564_window.xul
@@ -17,34 +17,34 @@
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const LISTEN_EVENTS = ["load", "unload", "pageshow", "pagehide"];
 
     var gBrowser;
     var gTestsIterator;
     var gExpected = [];
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function is(a, b, message) {
-      window.arguments[0].SimpleTest.is(a, b, message);
+      window.opener.wrappedJSObject.SimpleTest.is(a, b, message);
     }
 
     function finish() {
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.removeEventListener(eventType, eventListener, true);
       }
 
       // Work around bug 467960
       var history = gBrowser.webNavigation.sessionHistory;
       history.legacySHistory.PurgeHistory(history.count);
 
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad() {
       gBrowser = document.getElementById("content");
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.addEventListener(eventType, eventListener, true);
       }
              
--- a/docshell/test/chrome/bug113934_window.xul
+++ b/docshell/test/chrome/bug113934_window.xul
@@ -11,17 +11,17 @@
     <spacer flex="1"/>
   </hbox>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok", "snapshotWindow",
                     "compareSnapshots", "onerror" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function $(id) {
       return document.getElementById(id);
     }
 
     function addBrowser(parent, id, width, height) {
       var b =
--- a/docshell/test/chrome/bug215405_window.xul
+++ b/docshell/test/chrome/bug215405_window.xul
@@ -12,17 +12,17 @@
         height="600"
         onload="onLoad();"
         title="215405 test">
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     var imports = [ "SimpleTest", "is", "isnot", "ok"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     const text="MOZILLA";
     const nostoreURI = "http://mochi.test:8888/tests/docshell/test/chrome/" +
                        "215405_nostore.html";
     const nocacheURI = "https://example.com:443/tests/docshell/test/chrome/" +
                        "215405_nocache.html";
 
@@ -33,17 +33,17 @@
 
     function finish() {
       gBrowser.removeEventListener("pageshow", eventListener, true);
       // Work around bug 467960
       var history = gBrowser.webNavigation.sessionHistory;
       history.legacySHistory.PurgeHistory(history.count);
 
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad(e) {
       gBrowser = document.getElementById("content");
       gBrowser.addEventListener("pageshow", eventListener, true);
        
       gTestsIterator = testsIterator();
       nextTest();
--- a/docshell/test/chrome/bug364461_window.xul
+++ b/docshell/test/chrome/bug364461_window.xul
@@ -17,28 +17,28 @@
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const LISTEN_EVENTS = ["load", "unload", "pageshow", "pagehide"];
 
     var gBrowser;
     var gTestsIterator;
     var gExpected = [];
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
     function is(a, b, message) {
-      window.arguments[0].SimpleTest.is(a, b, message);
+      window.opener.wrappedJSObject.SimpleTest.is(a, b, message);
     }
     function finish() {
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.removeEventListener(eventType, eventListener, true);
       }
     
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad() {
       gBrowser = document.getElementById("content");
 
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.addEventListener(eventType, eventListener, true);
       }
--- a/docshell/test/chrome/bug396519_window.xul
+++ b/docshell/test/chrome/bug396519_window.xul
@@ -18,28 +18,28 @@
     const LISTEN_EVENTS = ["pageshow"];
 
     var gBrowser;
     var gTestCount = 0;
     var gTestsIterator;
     var gExpected = [];
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
     function is(a, b, message) {
-      window.arguments[0].SimpleTest.is(a, b, message);
+      window.opener.wrappedJSObject.SimpleTest.is(a, b, message);
     }
     function finish() {
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.removeEventListener(eventType, eventListener, true);
       }
     
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad() {
       gBrowser = document.getElementById("content");
 
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.addEventListener(eventType, eventListener, true);
       }
--- a/docshell/test/chrome/bug449778_window.xul
+++ b/docshell/test/chrome/bug449778_window.xul
@@ -5,17 +5,17 @@
 
   <hbox id="parent">
   </hbox>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function $(id) {
       return document.getElementById(id);
     }
 
     function addBrowser(parent, id, width, height) {
       var b =
--- a/docshell/test/chrome/bug449780_window.xul
+++ b/docshell/test/chrome/bug449780_window.xul
@@ -5,17 +5,17 @@
 
   <hbox id="parent">
   </hbox>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function $(id) {
       return document.getElementById(id);
     }
 
     function addBrowser(parent, id, width, height) {
       var b =
--- a/docshell/test/chrome/bug89419_window.xul
+++ b/docshell/test/chrome/bug89419_window.xul
@@ -15,17 +15,17 @@
   <script type="application/javascript"><![CDATA[
     ////
     // A visited link should have the :visited style applied
     // to it when displayed on a page which was fetched from
     // the bfcache.
     //
     async function runTests() {
       // Disable rcwn to make cache behavior deterministic.
-      var {SpecialPowers} = window.arguments[0];
+      var {SpecialPowers} = opener;
       await SpecialPowers.pushPrefEnv({"set":[["network.http.rcwn.enabled", false]]});
 
       // Load a test page containing an image referring to the sjs that returns
       // a different redirect every time it's loaded.
       await new Promise(resolve => {
         doPageNavigation({
           uri: getHttpUrl("89419.html"),
           onNavComplete: resolve,
--- a/docshell/test/chrome/bug92598_window.xul
+++ b/docshell/test/chrome/bug92598_window.xul
@@ -17,34 +17,34 @@
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const LISTEN_EVENTS = ["load", "unload", "pageshow", "pagehide"];
 
     var gBrowser;
     var gTestsIterator;
     var gExpected = [];
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function is(a, b, message) {
-      window.arguments[0].SimpleTest.is(a, b, message);
+      window.opener.wrappedJSObject.SimpleTest.is(a, b, message);
     }
 
     function finish() {
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.removeEventListener(eventType, eventListener, true);
       }
      
       // Work around bug 467960
       var history = gBrowser.webNavigation.sessionHistory;
       history.legacySHistory.PurgeHistory(history.count);
 
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad() {
       gBrowser = document.getElementById("content");
       for (let eventType of LISTEN_EVENTS) {
         gBrowser.addEventListener(eventType, eventListener, true);
       }
              
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -1,11 +1,8 @@
-if (!window.opener && window.arguments) {
-  window.opener = window.arguments[0];
-}
 /**
  * Import common SimpleTest methods so that they're usable in this window.
  */
 var imports = [
   "SimpleTest",
   "is",
   "isnot",
   "ok",
--- a/docshell/test/chrome/mozFrameType_window.xul
+++ b/docshell/test/chrome/mozFrameType_window.xul
@@ -7,18 +7,18 @@
   onload="runTests();">
 
   <html:iframe id="normalFrame"/>
   <html:iframe id="typeContentFrame" mozframetype="content"/>
 
   <script type="application/javascript" src="docshell_helpers.js" />
   <script type="application/javascript"><![CDATA[
     function runTests() {
-      let opener = window.arguments[0];
-      let SimpleTest = opener.SimpleTest;
+      let opener = window.opener;
+      let SimpleTest = opener.wrappedJSObject.SimpleTest;
 
       function getDocShellType(frame) {
         return frame.contentWindow.docShell.itemType;
       }
 
       var normalFrame = document.getElementById("normalFrame");
       var typeContentFrame = document.getElementById("typeContentFrame");
 
--- a/docshell/test/chrome/test_bug112564.xul
+++ b/docshell/test/chrome/test_bug112564.xul
@@ -23,15 +23,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 112564 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug112564_window.xul", "bug112564",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug112564_window.xul", "bug112564",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug113934.xul
+++ b/docshell/test/chrome/test_bug113934.xul
@@ -16,14 +16,14 @@ https://bugzilla.mozilla.org/show_bug.cg
      target="_blank">Mozilla Bug 396519</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     SimpleTest.waitForExplicitFinish();
 
     addLoadEvent(function() {
-      window.openDialog("bug113934_window.xul?content", "bug113934",
-                        "chrome,width=800,height=800,noopener", window);
+      window.open("bug113934_window.xul?content", "bug113934",
+                  "chrome,width=800,height=800");
     });
 
   ]]></script>
 </window>
--- a/docshell/test/chrome/test_bug215405.xul
+++ b/docshell/test/chrome/test_bug215405.xul
@@ -23,15 +23,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 215405 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug215405_window.xul", "bug215405",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug215405_window.xul", "bug215405",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug293235.xul
+++ b/docshell/test/chrome/test_bug293235.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 293235 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug293235_window.xul", "bug293235",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug293235_window.xul", "bug293235",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug294258.xul
+++ b/docshell/test/chrome/test_bug294258.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 294258 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug294258_window.xul", "bug294258",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug294258_window.xul", "bug294258",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug298622.xul
+++ b/docshell/test/chrome/test_bug298622.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 298622 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug298622_window.xul", "bug298622",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug298622_window.xul", "bug298622",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug301397.xul
+++ b/docshell/test/chrome/test_bug301397.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 301397 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug301397_window.xul", "bug301397",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug301397_window.xul", "bug301397",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug303267.xul
+++ b/docshell/test/chrome/test_bug303267.xul
@@ -25,15 +25,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.expectAssertions(0, 1);
 
 /** Test for Bug 303267 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug303267_window.xul", "bug303267",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug303267_window.xul", "bug303267",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug311007.xul
+++ b/docshell/test/chrome/test_bug311007.xul
@@ -28,15 +28,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 if (navigator.platform.startsWith("Win")) {
   SimpleTest.expectAssertions(0, 1);
 }
 
 /** Test for Bug 311007 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug311007_window.xul", "bug311007",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug311007_window.xul", "bug311007",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug321671.xul
+++ b/docshell/test/chrome/test_bug321671.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 321671 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug321671_window.xul", "bug321671",
-                  "chrome,width=600,height=600,scrollbars,noopener", window);
+window.open("bug321671_window.xul", "bug321671",
+            "chrome,width=600,height=600,scrollbars");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug360511.xul
+++ b/docshell/test/chrome/test_bug360511.xul
@@ -25,15 +25,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 360511 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug360511_window.xul", "bug360511",
-                  "chrome,scrollbars,width=600,height=600,noopener", window);
+window.open("bug360511_window.xul", "bug360511",
+            "chrome,scrollbars,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug364461.xul
+++ b/docshell/test/chrome/test_bug364461.xul
@@ -29,15 +29,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 SimpleTest.waitForExplicitFinish();
 
 SpecialPowers.pushPrefEnv({
   "set":[["security.data_uri.block_toplevel_data_uri_navigations", false]]
 }, runTests);
 
 function runTests() {
-  window.openDialog("bug364461_window.xul", "bug364461",
-                    "chrome,width=600,height=600,noopener", window);
+  window.open("bug364461_window.xul", "bug364461",
+              "chrome,width=600,height=600");
 }
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug396519.xul
+++ b/docshell/test/chrome/test_bug396519.xul
@@ -16,13 +16,13 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
     /** Test for Bug 396519 **/
 
     SimpleTest.waitForExplicitFinish();
-    window.openDialog("bug396519_window.xul", "bug396519",
-                      "chrome,width=600,height=600,noopener", window);
+    window.open("bug396519_window.xul", "bug396519",
+                "chrome,width=600,height=600");
 
   ]]></script>
 </window>
--- a/docshell/test/chrome/test_bug396649.xul
+++ b/docshell/test/chrome/test_bug396649.xul
@@ -27,15 +27,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 396649 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug396649_window.xul", "bug396649",
-                  "chrome,width=600,height=600,scrollbars,noopener", window);
+window.open("bug396649_window.xul", "bug396649",
+            "chrome,width=600,height=600,scrollbars");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug449778.xul
+++ b/docshell/test/chrome/test_bug449778.xul
@@ -16,14 +16,14 @@ https://bugzilla.mozilla.org/show_bug.cg
      target="_blank">Mozilla Bug 396519</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     SimpleTest.waitForExplicitFinish();
 
     addLoadEvent(function() {
-      window.openDialog("bug449778_window.xul", "bug449778",
-                        "chrome,width=800,height=800,noopener", window);
+      window.open("bug449778_window.xul", "bug449778",
+                  "chrome,width=800,height=800");
     });
 
   ]]></script>
 </window>
--- a/docshell/test/chrome/test_bug449780.xul
+++ b/docshell/test/chrome/test_bug449780.xul
@@ -16,14 +16,14 @@ https://bugzilla.mozilla.org/show_bug.cg
      target="_blank">Mozilla Bug 396519</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     SimpleTest.waitForExplicitFinish();
 
     addLoadEvent(function() {
-      window.openDialog("bug449780_window.xul", "bug449780",
-                        "chrome,width=800,height=800,noopener", window);
+      window.open("bug449780_window.xul", "bug449780",
+                  "chrome,width=800,height=800");
     });
 
   ]]></script>
 </window>
--- a/docshell/test/chrome/test_bug456980.xul
+++ b/docshell/test/chrome/test_bug456980.xul
@@ -16,14 +16,14 @@ https://bugzilla.mozilla.org/show_bug.cg
      target="_blank">Mozilla Bug 396519</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
     SimpleTest.waitForExplicitFinish();
 
     addLoadEvent(function() {
-      window.openDialog("bug113934_window.xul?chrome", "bug456980",
-                        "chrome,width=800,height=800,noopener", window);
+      window.open("bug113934_window.xul?chrome", "bug456980",
+                  "chrome,width=800,height=800");
     });
 
   ]]></script>
 </window>
--- a/docshell/test/chrome/test_bug582176.xul
+++ b/docshell/test/chrome/test_bug582176.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 582176 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug582176_window.xul", "bug582176",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug582176_window.xul", "bug582176",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug608669.xul
+++ b/docshell/test/chrome/test_bug608669.xul
@@ -23,18 +23,16 @@ SimpleTest.waitForExplicitFinish();
 addLoadEvent(nextTest);
 
 gen = doTest();
 
 function nextTest() {
   gen.next();
 }
 
-let chromeWindow = docShell.rootTreeItem.domWindow;
-
 function* doTest() {
   var notificationCount = 0;
   var observer = {
     observe: function(aSubject, aTopic, aData) {
       is(aTopic, "chrome-document-global-created",
          "correct topic");
       is(aData, "null",
          "correct data");
@@ -45,36 +43,34 @@ function* doTest() {
   var os = Cc["@mozilla.org/observer-service;1"].
     getService(Ci.nsIObserverService);
   os.addObserver(observer, "chrome-document-global-created");
   os.addObserver(observer, "content-document-global-created");
 
   is(notificationCount, 0, "initial count");
 
   // create a new window
-  var testWin = chromeWindow.open("", "bug 608669", "chrome,width=600,height=600");
+  var testWin = window.open("", "bug 608669", "chrome,width=600,height=600");
   testWin.x = "y";
   is(notificationCount, 1, "after created window");
 
   // Try loading in the window
   testWin.location = "bug608669.xul";
-  chromeWindow.onmessage = nextTest;
+  window.onmessage = nextTest;
   yield undefined;
   is(notificationCount, 1, "after first load");
   is(testWin.x, "y", "reused window");
 
   // Try loading again in the window
   testWin.location = "bug608669.xul?x";
-  chromeWindow.onmessage = nextTest;
+  window.onmessage = nextTest;
   yield undefined;
   is(notificationCount, 2, "after second load");
   is("x" in testWin, false, "didn't reuse window");
 
-  chromeWindow.onmessage = null;
-
   testWin.close();
 
   os.removeObserver(observer, "chrome-document-global-created");
   os.removeObserver(observer, "content-document-global-created");
   SimpleTest.finish();
 }
 
   ]]></script>
--- a/docshell/test/chrome/test_bug662200.xul
+++ b/docshell/test/chrome/test_bug662200.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 662200 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug662200_window.xul", "bug662200",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug662200_window.xul", "bug662200",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug690056.xul
+++ b/docshell/test/chrome/test_bug690056.xul
@@ -14,13 +14,13 @@ https://bugzilla.mozilla.org/show_bug.cg
      target="_blank">Mozilla Bug 690056</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 690056 **/
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug690056_window.xul", "bug690056",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug690056_window.xul", "bug690056",
+            "chrome,width=600,height=600");
   ]]>
   </script>
 </window>
--- a/docshell/test/chrome/test_bug89419.xul
+++ b/docshell/test/chrome/test_bug89419.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 89419 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug89419_window.xul", "bug89419",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug89419_window.xul", "bug89419",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_bug92598.xul
+++ b/docshell/test/chrome/test_bug92598.xul
@@ -23,15 +23,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 92598 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug92598_window.xul", "bug92598",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug92598_window.xul", "bug92598",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_mozFrameType.xul
+++ b/docshell/test/chrome/test_mozFrameType.xul
@@ -27,16 +27,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 if (navigator.platform.startsWith("Win")) {
   SimpleTest.expectAssertions(0, 1);
 }
 
 /** Test for Bug 769771 **/
 SimpleTest.waitForExplicitFinish();
 
 addLoadEvent(function () {
-  window.openDialog("mozFrameType_window.xul", "mozFrameType",
-                    "chrome,width=600,height=600,noopener", window);
+  window.open("mozFrameType_window.xul", "mozFrameType",
+              "chrome,width=600,height=600");
 });
 
 ]]>
 </script>
 
 </window>
--- a/docshell/test/chrome/test_principalInherit.xul
+++ b/docshell/test/chrome/test_principalInherit.xul
@@ -56,17 +56,17 @@ var tests = [
   },
   function testInheritFromCreated(cb) {
     // Open a new chrome window with a type="content" iframe, so that it has no
     // same-type parent.
     // Load a javascript: URI in it to ensure that GetInheritedPrincipal will
     // force creation of a content viewer.
     let xulWinURL = 'data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?>' +
                     '<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>';
-    let newWin = docShell.rootTreeItem.domWindow.openDialog(xulWinURL, "chrome_window", "chrome");
+    let newWin = window.openDialog(xulWinURL, "chrome_window", "chrome");
     loadListener(newWin, function () {
       let frame = newWin.document.createXULElement("iframe");
       frame.setAttribute("type", "content");
       frame.setAttribute("src", "javascript:'1';");
       loadListener(frame, function () {
         is(frame.contentWindow.document.body.textContent, "1", "content viewer was created");
         SimpleTest.executeSoon(function () {
           newWin.close();
--- a/dom/base/test/chrome/cpows_parent.xul
+++ b/dom/base/test/chrome/cpows_parent.xul
@@ -13,29 +13,29 @@
     const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
     var test_state = "remote";
     var test_node = null;
     var reentered = false;
     var savedMM = null;
 
     function info(message) {
-      return window.arguments[0].info(message);
+      return opener.wrappedJSObject.info(message);
     }
 
     function ok(condition, message) {
-      return window.arguments[0].ok(condition, message);
+      return opener.wrappedJSObject.ok(condition, message);
     }
 
     function is(v1, v2, message) {
-      return window.arguments[0].is(v1, v2, message);
+      return opener.wrappedJSObject.is(v1, v2, message);
     }
 
     function todo_is(v1, v2, message) {
-      return window.arguments[0].todo_is(v1, v2, message);
+      return opener.wrappedJSObject.todo_is(v1, v2, message);
     }
 
     // Make sure that an error in this file actually causes the test to fail.
     var gReceivedErrorProbe = false;
     window.onerror = function (msg, url, line) {
       if (/Test Error Probe/.test(msg)) {
         gReceivedErrorProbe = true;
         return;
@@ -406,33 +406,33 @@
       try {
         msg.objects.f();
       } catch (e) {
         if (!/unsafe CPOW usage forbidden/.test(String(e))) {
           throw e;
         }
         failed = true;
       }
-      window.arguments[0].SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
+      opener.wrappedJSObject.SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
       ok(failed, "CPOW should fail when unsafe");
       msg.target.messageManager.sendAsyncMessage("cpows:unsafe_done");
     }
 
     function recvSafe(msg) {
       const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
       Services.prefs.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
       try {
         msg.objects.f();
       } catch (e) {
         if (!/unsafe CPOW usage forbidden/.test(String(e))) {
           throw e;
         }
         ok(false, "cpow failed");
       }
-      window.arguments[0].SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
+      opener.wrappedJSObject.SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
       msg.target.messageManager.sendAsyncMessage("cpows:safe_done");
     }
 
     function recvDead(msg) {
       // Need to do this in a separate turn of the event loop.
       setTimeout(() => {
         msg.objects.gcTrigger();
         try {
@@ -507,16 +507,16 @@
       BrowserTestUtils.loadURI(browser, "http://mochi.test:8888/tests/dom/base/test/chrome/cpows_child.html");
       await BrowserTestUtils.browserLoaded(browser);
 
       run_tests('remote');
     }
 
     function finish() {
       ok(gReceivedErrorProbe, "Should have reported error probe");
-      window.arguments[0].setTimeout(function() { this.done(); }, 0);
+      opener.setTimeout(function() { this.done(); }, 0);
       window.close();
     }
   ]]></script>
 
   <browser type="content" src="about:blank" id="cpowbrowser_remote" remote="true"/>
   <browser type="content" src="about:blank" id="cpowbrowser_inprocess"/>
 </window>
--- a/dom/base/test/chrome/file_bug1139964.xul
+++ b/dom/base/test/chrome/file_bug1139964.xul
@@ -9,17 +9,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   onload="run()">
   <label value="Mozilla Bug 1139964"/>
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
   var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
 
   function ok(cond, msg) {
-    window.arguments[0].ok(cond, msg);
+    opener.wrappedJSObject.ok(cond, msg);
   }
 
   var msgName = "TEST:Global_has_Promise";
 
   function mmScriptForPromiseTest() {
     sendAsyncMessage("TEST:Global_has_Promise",
                      {
                        hasPromise: ("Promise" in this),
@@ -39,17 +39,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   function tabListener(m) {
     messageManager.removeMessageListener(msgName, tabListener);
     ok(m.data.hasPromise, "BrowserChildGlobal should have Promise object in the global scope!");
     ok(m.data.hasTextEncoder, "BrowserChildGlobal should have TextEncoder object in the global scope!");
     ok(m.data.hasWindow, "BrowserChildGlobal should have Window object in the global scope!");
 
-    window.arguments[0].setTimeout(function() { this.done(); }, 0);
+    opener.setTimeout(function() { this.done(); }, 0);
     window.close();
   }
 
   function run() {
     ppm.addMessageListener(msgName, processListener)
     ppm.loadProcessScript("data:,(" + mmScriptForPromiseTest.toString() + ")()", true);
   }
 
--- a/dom/base/test/chrome/file_bug1209621.xul
+++ b/dom/base/test/chrome/file_bug1209621.xul
@@ -7,21 +7,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 -->
 <window title="Mozilla Bug 1209621"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   onload="run()">
   <label value="Mozilla Bug 1209621"/>
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
   function ok(cond, msg) {
-    window.arguments[0].ok(cond, msg);
+    opener.wrappedJSObject.ok(cond, msg);
   }
 
   function is(actual, expected, msg) {
-    window.arguments[0].is(actual, expected, msg);
+    opener.wrappedJSObject.is(actual, expected, msg);
   }
 
   function run() {
     var docshell = window.docShell;
     ok(docshell, "Active window should have a DocShell");
     var treeOwner = docshell.treeOwner;
     ok(treeOwner, "Active docshell should have a TreeOwner!");
 
@@ -59,17 +59,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     remote2.setAttribute("primary", "true");
     var tp2 = remote2.frameLoader.remoteTab;
     ok(tp2, "Remote browsers should have a remoteTab.");
     is(treeOwner.primaryRemoteTab, tp2,
        "primary remote browser should be the primaryRemoteTab.");
     is(treeOwner.primaryContentShell, null,
        "There shouldn't be primaryContentShell because no browser has primary=true.");
 
-    window.arguments[0].setTimeout(function() { this.done(); }, 0);
+    opener.setTimeout(function() { this.done(); }, 0);
     window.close();
   }
 
   ]]></script>
   <browser type="content" src="about:blank" id="inprocess"/>
   <browser type="content" remote="true" src="about:blank" id="remote"/>
   <browser type="content" remote="true" src="about:blank" id="remote2"/>
 </window>
--- a/dom/base/test/chrome/file_bug549682.xul
+++ b/dom/base/test/chrome/file_bug549682.xul
@@ -14,21 +14,21 @@ https://bugzilla.mozilla.org/show_bug.cg
   var didRunAsync = false;
   var didRunLocal = false;
 
   var global = Cc["@mozilla.org/globalmessagemanager;1"].getService();
   var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
   var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
 
   function ok(cond, msg) {
-    window.arguments[0].ok(cond, msg);
+    opener.wrappedJSObject.ok(cond, msg);
   }
 
   function is(actual, expected, msg) {
-    window.arguments[0].is(actual, expected, msg);
+    opener.wrappedJSObject.is(actual, expected, msg);
   }
 
   var asyncPPML = false;
   function ppmASL(m) {
     asyncPPML = true;
   }
   var syncPPML = false;
   function ppmSL(m) {
@@ -114,17 +114,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   };
 
   function weakDoneListener() {
     ok(weakMessageReceived, 'Got "weak" message.');
     finish();
   }
 
   function finish() {
-    window.arguments[0].setTimeout(function() { this.done(); }, 0);
+    opener.setTimeout(function() { this.done(); }, 0);
     var i = document.getElementById("ifr");
     i.remove(); // This is a crash test!
     window.close();
   }
 
   function loadScript() {
     // Async should be processed first!
     messageManager.loadFrameScript("data:,\
--- a/dom/base/test/chrome/file_bug616841.xul
+++ b/dom/base/test/chrome/file_bug616841.xul
@@ -33,31 +33,31 @@ https://bugzilla.mozilla.org/show_bug.cg
         messageManager.broadcastAsyncMessage("cmp",
                                              { i: i, a: pair[0], b: pair[1] });
       }
     }
 
     function recvCmp(m) {
       var i = m.json.i, cmp = m.json.cmp;
       var pair = toCompare[i];
-      window.arguments[0].is(pair[0].localeCompare(pair[1]), cmp, "localeCompare returned same result in frame script");
+      opener.wrappedJSObject.is(pair[0].localeCompare(pair[1]), cmp, "localeCompare returned same result in frame script");
 
       if (toCompare.length == ++nCmps) {
          messageManager.removeMessageListener("cmp", recvCmp);
         finish();
       }
     }
 
     function start() {
       messageManager.addMessageListener("contentReady", recvContentReady);
       messageManager.addMessageListener("cmp", recvCmp);
       messageManager.loadFrameScript(FRAME_SCRIPT, true);
     }
 
     function finish() {
-      window.arguments[0].setTimeout(function() { this.done(); }, 0);
+      opener.setTimeout(function() { this.done(); }, 0);
       window.close();
     }
 
   ]]></script>
 
   <browser id="browser" type="content" src="about:blank"/>
 </window>
--- a/dom/base/test/chrome/file_bug816340.xul
+++ b/dom/base/test/chrome/file_bug816340.xul
@@ -8,17 +8,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <window title="Mozilla Bug 816340"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   onload="start();">
   <label value="Mozilla Bug 816340"/>
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
     function ok(val, msg) {
-      window.arguments[0].ok(val, msg);
+      opener.wrappedJSObject.ok(val, msg);
     }
 
     var elems = 
       [
         "input",
         "textarea",
         "select",
         "fieldset",
@@ -55,16 +55,16 @@ https://bugzilla.mozilla.org/show_bug.cg
       testElement("div", false, true);
       testElement("div", true, true);
 
       for (var i = 0; i < elems.length; ++i) {
         testElement(elems[i], false, true);
         testElement(elems[i], true, false);
       }
       ok(true, "done");
-      window.arguments[0].setTimeout(function() { this.done(); }, 0);
+      opener.setTimeout(function() { this.done(); }, 0);
       window.close();
     }
 
   ]]></script>
 
   <browser id="browser" type="content" src="about:blank"/>
 </window>
--- a/dom/base/test/chrome/file_bug990812-1.xul
+++ b/dom/base/test/chrome/file_bug990812-1.xul
@@ -14,17 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     var FRAME_SCRIPT_GLOBAL = "data:,sendSyncMessage('test', 'global')";
     var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
     var FRAME_SCRIPT_GROUP  = "data:,sendSyncMessage('test', 'group')";
 
     var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
 
     function is(val, exp, msg) {
-      window.arguments[0].is(val, exp, msg);
+      opener.wrappedJSObject.is(val, exp, msg);
     }
 
     /**
      * Ensures that delayed frame scripts are loaded in the expected order.
      * Global frame scripts will be loaded before delayed frame scripts from
      * window message managers. The latter will be loaded before group message
      * manager frame scripts.
      */
@@ -32,20 +32,20 @@ https://bugzilla.mozilla.org/show_bug.cg
       globalMM.loadFrameScript(FRAME_SCRIPT_GLOBAL, true);
       messageManager.loadFrameScript(FRAME_SCRIPT_WINDOW, true);
       getGroupMessageManager("test").loadFrameScript(FRAME_SCRIPT_GROUP, true);
 
       var order = ["global", "window", "group"];
 
       messageManager.addMessageListener("test", function onMessage(msg) {
         var next = order.shift();
-        window.arguments[0].is(msg.data, next, "received test:" + next);
+        opener.wrappedJSObject.is(msg.data, next, "received test:" + next);
 
         if (order.length == 0) {
-          window.arguments[0].setTimeout(function() { this.next(); });
+          opener.setTimeout(function() { this.next(); });
           window.close();
         }
       });
 
       var browser = document.createXULElement("browser");
       browser.setAttribute("messagemanagergroup", "test");
       browser.setAttribute("src", "about:mozilla");
       browser.setAttribute("type", "content");
--- a/dom/base/test/chrome/file_bug990812-2.xul
+++ b/dom/base/test/chrome/file_bug990812-2.xul
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"><![CDATA[
 
     var FRAME_SCRIPT = "data:,sendAsyncMessage('test')";
     var order = ["group", "window", "global"];
 
     var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
 
     function is(val, exp, msg) {
-      window.arguments[0].is(val, exp, msg);
+      opener.wrappedJSObject.is(val, exp, msg);
     }
 
     function promiseMessage(type, mm) {
       return new Promise(function (resolve) {
         mm.addMessageListener("test", function onMessage() {
           mm.removeMessageListener("test", onMessage);
           is(type, order.shift(), "correct type " + type);
           resolve();
@@ -39,17 +39,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       var global = promiseMessage("global", globalMM);
       var window = promiseMessage("window", messageManager);
       var group = promiseMessage("group", getGroupMessageManager("test"));
 
       var browser = document.querySelector("browser");
       browser.messageManager.loadFrameScript(FRAME_SCRIPT, true);
 
       Promise.all([global, window, group]).then(function () {
-        self.arguments[0].setTimeout(function() { this.next(); });
+        opener.setTimeout(function() { this.next(); });
         self.close();
       });
     }
 
   ]]></script>
 
   <browser messagemanagergroup="test" type="content" src="about:mozilla" />
 
--- a/dom/base/test/chrome/file_bug990812-3.xul
+++ b/dom/base/test/chrome/file_bug990812-3.xul
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"><![CDATA[
 
     var FRAME_SCRIPT = "data:,addMessageListener('test', function (msg) {" +
                        "sendSyncMessage('test', msg.data)})";
 
     var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
 
     function is(val, exp, msg) {
-      window.arguments[0].is(val, exp, msg);
+      opener.wrappedJSObject.is(val, exp, msg);
     }
 
     function promiseMessage(type, mm) {
       var order = [type, "window", "global"];
 
       return new Promise(function (resolve) {
         mm.addMessageListener("test", function onMessage(msg) {
           is(msg.data, order.shift(), "correct message " + msg.data);
@@ -50,17 +50,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       mm2.loadFrameScript(FRAME_SCRIPT, true);
 
       getGroupMessageManager("test1").broadcastAsyncMessage("test", "group1");
       getGroupMessageManager("test2").broadcastAsyncMessage("test", "group2");
       messageManager.broadcastAsyncMessage("test", "window");
       globalMM.broadcastAsyncMessage("test", "global");
 
       Promise.all([promise1, promise2]).then(function () {
-        window.arguments[0].setTimeout(function() { this.next(); });
+        opener.setTimeout(function() { this.next(); });
         window.close();
       });
     }
 
   ]]></script>
 
   <browser messagemanagergroup="test1" type="content" src="about:mozilla" />
   <browser messagemanagergroup="test2" type="content" src="about:mozilla" />
--- a/dom/base/test/chrome/file_bug990812-4.xul
+++ b/dom/base/test/chrome/file_bug990812-4.xul
@@ -15,17 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     var FRAME_SCRIPT1 = "data:,addMessageListener('test', function () {" +
                         "sendSyncMessage('test', 'frame1')})";
     var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
                         "sendSyncMessage('test', 'frame2')})";
 
     var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
 
     function is(val, exp, msg) {
-      window.arguments[0].is(val, exp, msg);
+      opener.wrappedJSObject.is(val, exp, msg);
     }
 
     function promiseMessage(type, mm) {
       return new Promise(function (resolve) {
         mm.addMessageListener("test", function onMessage(msg) {
           mm.removeMessageListener("test", onMessage);
           is(msg.data, type, "correct message " + type);
           resolve();
@@ -45,17 +45,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
       var promise1 = promiseMessage("frame2", getGroupMessageManager("test1"));
       var promise2 = promiseMessage("frame1", getGroupMessageManager("test2"));
 
       browser1.swapFrameLoaders(browser2);
       messageManager.broadcastAsyncMessage("test");
 
       Promise.all([promise1, promise2]).then(function () {
-        window.arguments[0].setTimeout(function() { this.next(); });
+        opener.setTimeout(function() { this.next(); });
         window.close();
       });
     }
 
   ]]></script>
 
   <browser messagemanagergroup="test1" type="content" src="about:mozilla" />
   <browser messagemanagergroup="test2" type="content" src="about:mozilla" />
--- a/dom/base/test/chrome/file_bug990812-5.xul
+++ b/dom/base/test/chrome/file_bug990812-5.xul
@@ -15,17 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     var FRAME_SCRIPT1 = "data:,addMessageListener('test', function () {" +
                         "sendSyncMessage('test', 'group1')})";
     var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
                         "sendSyncMessage('test', 'group2')})";
 
     var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
 
     function is(val, exp, msg) {
-      window.arguments[0].is(val, exp, msg);
+      opener.wrappedJSObject.is(val, exp, msg);
     }
 
     function promiseTwoMessages(type, mm) {
       var numLeft = 2;
 
       return new Promise(function (resolve) {
         mm.addMessageListener("test", function onMessage(msg) {
           is(msg.data, type, "correct message " + type);
@@ -53,17 +53,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       gmm2.loadFrameScript(FRAME_SCRIPT2, true);
 
       var promise1 = promiseTwoMessages("group1", gmm1);
       var promise2 = promiseTwoMessages("group2", gmm2);
 
       messageManager.broadcastAsyncMessage("test");
 
       Promise.all([promise1, promise2]).then(function () {
-        window.arguments[0].setTimeout(function() { this.next(); });
+        opener.setTimeout(function() { this.next(); });
         window.close();
       });
     }
 
   ]]></script>
 
   <browser messagemanagergroup="test1" type="content" src="about:mozilla" />
   <browser messagemanagergroup="test1" type="content" src="about:mozilla" />
--- a/dom/base/test/chrome/test_bug1139964.xul
+++ b/dom/base/test/chrome/test_bug1139964.xul
@@ -21,12 +21,12 @@ https://bugzilla.mozilla.org/show_bug.cg
   /** Test for Bug 1139964 **/
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("file_bug1139964.xul", "", "chrome,noopener", window);
+    window.open("file_bug1139964.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_bug1209621.xul
+++ b/dom/base/test/chrome/test_bug1209621.xul
@@ -21,14 +21,14 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("file_bug1209621.xul", "", "chrome,noopener", window);
+    window.open("file_bug1209621.xul", "", "chrome");
   });
 
   ]]>
   </script>
 </window>
--- a/dom/base/test/chrome/test_bug549682.xul
+++ b/dom/base/test/chrome/test_bug549682.xul
@@ -21,12 +21,12 @@ https://bugzilla.mozilla.org/show_bug.cg
   /** Test for Bug 549682 **/
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("file_bug549682.xul", "", "chrome,noopener", window);
+    window.open("file_bug549682.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_bug616841.xul
+++ b/dom/base/test/chrome/test_bug616841.xul
@@ -19,12 +19,12 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("file_bug616841.xul", "", "chrome,noopener", window);
+    window.open("file_bug616841.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_bug814638.xul
+++ b/dom/base/test/chrome/test_bug814638.xul
@@ -18,18 +18,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 814638 **/
 
   SimpleTest.waitForExplicitFinish();
 
   function startTest() {
     let hostURL = "chrome://mochitests/content/chrome/dom/base/test/chrome/host_bug814638.xul";
-    let host1 = docShell.rootTreeItem.domWindow.open(hostURL, "_blank", "chrome");
-    let host2 = docShell.rootTreeItem.domWindow.open(hostURL, "_blank", "chrome");
+    let host1 = window.open(hostURL, "_blank", "chrome");
+    let host2 = window.open(hostURL, "_blank", "chrome");
 
     let isHost1Loaded = isHost2Loaded = false
     host1.onload = function() {
       isHost1Loaded = true;
       if (isHost2Loaded) swapFrames();
     }
     host2.onload = function() {
       isHost2Loaded = true;
--- a/dom/base/test/chrome/test_bug816340.xul
+++ b/dom/base/test/chrome/test_bug816340.xul
@@ -19,12 +19,12 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("file_bug816340.xul", "", "chrome,noopener", window);
+    window.open("file_bug816340.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_bug990812.xul
+++ b/dom/base/test/chrome/test_bug990812.xul
@@ -26,17 +26,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     "file_bug990812-4.xul",
     "file_bug990812-5.xul",
   ];
 
   function next() {
     if (tests.length > 0) {
       var file = tests.shift();
       info("-- running " + file);
-      window.openDialog(file, "_blank", "chrome,noopener", window);
+      window.open(file, "", "chrome");
     } else {
       SimpleTest.finish();
     }
   }
 
   addLoadEvent(next);
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_chromeOuterWindowID.xul
+++ b/dom/base/test/chrome/test_chromeOuterWindowID.xul
@@ -67,17 +67,17 @@ windows.
    * @returns Promise
    *        The Promise resolves with an object with the following properties:
    *
    *        win<num>: a reference to the opened window
    *        remote<num>: a reference to the remote browser in the window
    *        nonRemote<num>: a reference to the non-remote browser in the window
    */
   async function prepareWindow(num, page) {
-    let win = docShell.rootTreeItem.domWindow.open(BROWSER_DOC, "bug1474662-" + num, "chrome,width=200,height=200");
+    let win = window.open(BROWSER_DOC, "bug1474662-" + num, "chrome,width=200,height=200");
     await BrowserTestUtils.waitForEvent(win, "load");
     let remote = win.document.getElementById("remote");
     let nonRemote = win.document.getElementById("non-remote");
 
     ok(remote && remote.isRemoteBrowser,
        "Should have found a remote browser in test window " + num);
     ok(nonRemote && !nonRemote.isRemoteBrowser,
        "Should have found a non-remote browser in test window " + num);
--- a/dom/base/test/chrome/test_cpows.xul
+++ b/dom/base/test/chrome/test_cpows.xul
@@ -23,12 +23,12 @@
     Services.prefs.clearUserPref(PREF_UNSAFE_FORBIDDEN);
   });
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("cpows_parent.xul", "", "chrome,noopener", window);
+    window.open("cpows_parent.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_document-element-inserted.xul
+++ b/dom/base/test/chrome/test_document-element-inserted.xul
@@ -32,17 +32,17 @@ https://bugzilla.mozilla.org/show_bug.cg
         }, "document-element-inserted");
       })
     }
 
     // Load a XUL document that also has an iframe to a subdocument, and
     // expect both events to fire with the docs in the correct state.
     async function testEvents() {
       info(`Waiting for events after loading ${OUTER_URL}`);
-      let win = docShell.rootTreeItem.domWindow.openDialog(OUTER_URL, "_blank", "chrome,dialog=no,all");
+      let win = window.openDialog(OUTER_URL, null, "chrome,dialog=no,all");
       await waitForEvent(OUTER_URL);
       await waitForEvent(INNER_URL);
       win.close();
     }
 
     (async function() {
       // Test the same document twice to make to make sure we are
       // firing properly when loading the protype document.
--- a/dom/base/test/chrome/test_nsITextInputProcessor.xul
+++ b/dom/base/test/chrome/test_nsITextInputProcessor.xul
@@ -16,14 +16,14 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("window_nsITextInputProcessor.xul", "_blank", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("window_nsITextInputProcessor.xul", "_blank", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 </window>
--- a/dom/base/test/chrome/test_swapFrameLoaders.xul
+++ b/dom/base/test/chrome/test_swapFrameLoaders.xul
@@ -14,12 +14,12 @@ Test swapFrameLoaders with different fra
   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1242644"
      target="_blank">Mozilla Bug 1242644</a>
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
 
-  window.openDialog("window_swapFrameLoaders.xul", "bug1242644",
-                    "chrome,width=600,height=600,noopener", window);
+  window.open("window_swapFrameLoaders.xul", "bug1242644",
+              "chrome,width=600,height=600");
   ]]></script>
 </window>
--- a/dom/base/test/chrome/test_title.xul
+++ b/dom/base/test/chrome/test_title.xul
@@ -17,13 +17,13 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 481777 **/
 
     SimpleTest.waitForExplicitFinish();
-    window.openDialog("title_window.xul", "bug481777",
-                      "chrome,width=100,height=100,noopener", window);
+    window.open("title_window.xul", "bug481777",
+                "chrome,width=100,height=100");
   ]]>
   </script>
 </window>
--- a/dom/base/test/chrome/title_window.xul
+++ b/dom/base/test/chrome/title_window.xul
@@ -17,17 +17,17 @@
   <iframe id="xul2" src="file_title.xul"/>
   <iframe type="content" id="svg1" src="data:text/xml,&lt;svg xmlns='http://www.w3.org/2000/svg'&gt;&lt;title id='t'&gt;Test&lt;/title&gt;&lt;/svg&gt;"/>
   <iframe type="content" id="svg2" src="data:text/xml,&lt;svg xmlns='http://www.w3.org/2000/svg'&gt;&lt;title id='t'&gt;Test&lt;/title&gt;&lt;/svg&gt;"/>
 
   <script type="application/javascript">
     <![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function testStatics() {
       function testStatic(id, expect, description) {
         is(document.getElementById(id).contentDocument.title, expect, description);
       }
 
       testStatic("html1", "Test", "HTML <title>");
--- a/dom/base/test/chrome/window_nsITextInputProcessor.xul
+++ b/dom/base/test/chrome/window_nsITextInputProcessor.xul
@@ -20,17 +20,17 @@
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-var SimpleTest = window.arguments[0].SimpleTest;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 
 SimpleTest.waitForFocus(runTests, window);
 
 function ok(aCondition, aMessage)
 {
   SimpleTest.ok(aCondition, aMessage);
 }
 
@@ -73,17 +73,17 @@ function checkInputEvent(aEvent, aIsComp
 }
 
 const kIsMac = (navigator.platform.indexOf("Mac") == 0);
 
 var iframe = document.getElementById("iframe");
 var childWindow = iframe.contentWindow;
 var textareaInFrame;
 var input = document.getElementById("input");
-var otherWindow = window.arguments[0];
+var otherWindow = window.opener;
 var otherDocument = otherWindow.document;
 var inputInChildWindow = otherDocument.getElementById("input");
 
 function createTIP()
 {
   return Cc["@mozilla.org/text-input-processor;1"].
            createInstance(Ci.nsITextInputProcessor);
 }
--- a/dom/base/test/chrome/window_swapFrameLoaders.xul
+++ b/dom/base/test/chrome/window_swapFrameLoaders.xul
@@ -5,17 +5,17 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=1242644
 Test swapFrameLoaders with different frame types and remoteness
 -->
 <window title="Mozilla Bug 1242644"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script type="application/javascript"><![CDATA[
   ["SimpleTest", "SpecialPowers", "info", "is", "ok", "add_task"].forEach(key => {
-    window[key] = window.arguments[0][key];
+    window[key] = window.opener[key];
   })
 
   const NS = {
     xul: "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
     html: "http://www.w3.org/1999/xhtml",
   }
 
   const TAG = {
--- a/dom/base/test/test_bug1016960.html
+++ b/dom/base/test/test_bug1016960.html
@@ -7,18 +7,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta charset="utf-8">
   <title>Test for Bug 1016960</title>
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug 1016960 **/
 
-  var chromeWindow = docShell.rootTreeItem.domWindow.open("chrome://mochitests/content/chrome/dom/base/test/file_empty.html", "1016960", "chrome");
-  ok(chromeWindow.isChromeWindow, "A chrome window should return true for .isChromeWindow.");
+  var chromeWindow = window.open("chrome://mochitests/content/chrome/dom/base/test/file_empty.html", "1016960", "chrome");
+  ok(chromeWindow.isChromeWindow, "A chrome window should return true for |instanceof ChromeWindow|.");
   chromeWindow.close();
 
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1016960">Mozilla Bug 1016960</a>
 <p id="display"></p>
 <div id="content" style="display: none">
--- a/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
+++ b/dom/canvas/test/chrome/test_drawWindow_widget_layers.html
@@ -24,18 +24,18 @@
     // for regular windows.
     // (The reftest framework doesn't have this problem because it doesn't use
     // a regular window with a titlebar, so there are no rounded corners.)
     const WINDOW_INNER_WIDTH = CANVAS_WIDTH;
     const WINDOW_INNER_HEIGHT = CANVAS_HEIGHT + 10;
 
     // Need to open as a toplevel chrome window so that
     // DRAWWINDOW_USE_WIDGET_LAYERS is honored.
-    sourceWindow = docShell.rootTreeItem.domWindow.open("file_drawWindow_source.html", "",
-                                                        `chrome,width=${WINDOW_INNER_WIDTH},height=${WINDOW_INNER_HEIGHT}`);
+    sourceWindow = window.open("file_drawWindow_source.html", "",
+                               `chrome,width=${WINDOW_INNER_WIDTH},height=${WINDOW_INNER_HEIGHT}`);
     SimpleTest.waitForFocus(runTests, sourceWindow);
   }
 
   async function runTests() {
     var cxInterfaceWrap = SpecialPowers.wrap(CanvasRenderingContext2D);
     
     let snapshot = function(context, x, y, width, height, bg) {
       var flags = cxInterfaceWrap.DRAWWINDOW_USE_WIDGET_LAYERS |
--- a/dom/events/test/test_bug1412775.xul
+++ b/dom/events/test/test_bug1412775.xul
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 1412775 **/
   var win;
   function init() {
     SimpleTest.waitForExplicitFinish();
-    win = docShell.rootTreeItem.domWindow.open("window_bug1412775.xul", "_new", "chrome");
+    win = window.open("window_bug1412775.xul", "_new", "chrome");
     win.onload = function() {
       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;
--- a/dom/events/test/test_bug617528.xul
+++ b/dom/events/test/test_bug617528.xul
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     var _window;
     var browser;
 
     function start() {
-      _window = docShell.rootTreeItem.domWindow.open("window_bug617528.xul", "_new", "chrome");
+      _window = window.open("window_bug617528.xul", "_new", "chrome");
       _window.addEventListener("load", onLoad, false);
     }
 
     function onLoad() {
       _window.removeEventListener("load", onLoad, false);
 
       browser = _window.document.getElementById("browser");
       browser.addEventListener("pageshow", onPageShow, false);
--- a/dom/ipc/tests/process_error.xul
+++ b/dom/ipc/tests/process_error.xul
@@ -4,20 +4,20 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 	orient="vertical">
 
   <browser id="thebrowser" type="content" remote="true" />
   <script type="application/javascript"><![CDATA[
     const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
 
-    const ok = window.arguments[0].ok;
-    const is = window.arguments[0].is;
-    const done = window.arguments[0].done;
-    const SimpleTest = window.arguments[0].SimpleTest;
+    const ok = window.opener.wrappedJSObject.ok;
+    const is = window.opener.wrappedJSObject.is;
+    const done = window.opener.wrappedJSObject.done;
+    const SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 
     // Allow the browser to get connected before using the messageManager to cause
     // a crash:
     addEventListener("DOMContentLoaded", () => {
       let browser = document.getElementById('thebrowser');
 
       let observerPromise = new Promise(resolve => {
         let crashObserver = (subject, topic, data) => {
--- a/dom/ipc/tests/test_process_error.xul
+++ b/dom/ipc/tests/test_process_error.xul
@@ -4,17 +4,17 @@
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script>
   SimpleTest.waitForExplicitFinish();
   SimpleTest.expectChildProcessCrash();
 
-  var w = docShell.rootTreeItem.domWindow.openDialog('process_error.xul', '_blank', 'chrome,resizable=yes,width=400,height=600', window);
+  var w = window.open('process_error.xul', '_blank', 'chrome,resizable=yes,width=400,height=600');
 
   function done()
   {
     w.close();
     SimpleTest.finish();
   }
   </script>
 
--- a/dom/messagechannel/tests/mm_messageChannelParent.js
+++ b/dom/messagechannel/tests/mm_messageChannelParent.js
@@ -1,29 +1,29 @@
 let port;
 let mm;
 
 function info(message) {
-  return window.arguments[0].info(message);
+  return opener.wrappedJSObject.info(message);
 }
 
 function ok(condition, message) {
-  return window.arguments[0].ok(condition, message);
+  return opener.wrappedJSObject.ok(condition, message);
 }
 
 function is(v1, v2, message) {
-  return window.arguments[0].is(v1, v2, message);
+  return opener.wrappedJSObject.is(v1, v2, message);
 }
 
 function todo_is(v1, v2, message) {
-  return window.arguments[0].todo_is(v1, v2, message);
+  return opener.wrappedJSObject.todo_is(v1, v2, message);
 }
 
 function cleanUp() {
-  window.arguments[0].setTimeout(function() {
+  opener.setTimeout(function() {
     this.done();
   }, 0);
   window.close();
 }
 
 function debug(msg) {
   dump("[mmMessageChannelParent]" + msg + "\n");
 }
--- a/dom/messagechannel/tests/test_messageChannelWithMessageManager.xul
+++ b/dom/messagechannel/tests/test_messageChannelWithMessageManager.xul
@@ -16,12 +16,12 @@
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     info("done called");
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("mm_messageChannelParent.xul", "", "chrome,noopener", window);
+    window.open("mm_messageChannelParent.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/messagechannel/tests/test_messageChannelWithMessageManagerNotRemote.xul
+++ b/dom/messagechannel/tests/test_messageChannelWithMessageManagerNotRemote.xul
@@ -16,12 +16,12 @@
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     info("done called");
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("mm_messageChannelParentNotRemote.xul", "", "chrome,noopener", window);
+    window.open("mm_messageChannelParentNotRemote.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul
+++ b/dom/plugins/test/mochitest/test_xulbrowser_plugin_visibility.xul
@@ -5,17 +5,17 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript" src="plugin-utils.js"></script>
 
   <script>
   SimpleTest.waitForExplicitFinish();
   setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
 
-  var w = docShell.rootTreeItem.domWindow.openDialog('xulbrowser_plugin_visibility.xul', '_blank', 'chrome,resizable=yes,width=400,height=600', window);
+  var w = window.open('xulbrowser_plugin_visibility.xul', '_blank', 'chrome,resizable=yes,width=400,height=600');
 
   function done()
   {
     w.close();
     SimpleTest.finish();
   }
   </script>
 
--- a/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
+++ b/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
@@ -12,20 +12,20 @@
     <tabpanels flex="1">
       <browser id="browser1" type="content" primary="true" flex="1" src="about:blank"/>
       <browser id="browser2" type="content" primary="true" flex="1" src="about:blank"/>
     </tabpanels>
   </tabbox>
   <script type="application/javascript" src="plugin-utils.js"/>
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
-    const ok = window.arguments[0].ok;
-    const is = window.arguments[0].is;
-    const done = window.arguments[0].done;
-    const SimpleTest = window.arguments[0].SimpleTest;
+    const ok = window.opener.wrappedJSObject.ok;
+    const is = window.opener.wrappedJSObject.is;
+    const done = window.opener.wrappedJSObject.done;
+    const SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 
     const nsIWebProgress = Ci.nsIWebProgress;
     const nsIWebProgressListener = Ci.nsIWebProgressListener;
 
     const kURI = 'http://mochi.test:8888/chrome/dom/plugins/test/mochitest/plugin_visibility_loader.html';
 
     function ProgressListener() {
     }
--- a/dom/tests/browser/browser_test_toolbars_visibility.js
+++ b/dom/tests/browser/browser_test_toolbars_visibility.js
@@ -223,26 +223,26 @@ add_task(async function() {
  * A window opened with "location=no, personalbar=no, toolbar=no, scrollbars=no,
  * menubar=no, status=no", should not have any toolbar visible.
  */
 add_task(async function() {
   // First open a default window from this chrome context
   let defaultWindowPromise = BrowserTestUtils.waitForNewWindow({
     url: TARGET_PAGE,
   });
-  window.open(TARGET_PAGE, "_blank", "noopener");
+  window.open(TARGET_PAGE, "_blank");
   let defaultWindow = await defaultWindowPromise;
 
   // Check that all toolbars are visible
   let toolbars = getToolbarsFromWindowChrome(defaultWindow);
   testDefaultToolbars(toolbars);
 
   // Now lets open a window with toolbars hidden from this chrome context
   let features =
-    "location=no, personalbar=no, toolbar=no, scrollbars=no, menubar=no, status=no, noopener";
+    "location=no, personalbar=no, toolbar=no, scrollbars=no, menubar=no, status=no";
   let popupWindowPromise = BrowserTestUtils.waitForNewWindow({
     url: TARGET_PAGE,
   });
   window.open(TARGET_PAGE, "_blank", features);
   let popupWindow = await popupWindowPromise;
 
   // Test none of the tooolbars are visible
   let hiddenToolbars = getToolbarsFromWindowChrome(popupWindow);
--- a/dom/tests/mochitest/chrome/DOMWindowCreated_chrome.xul
+++ b/dom/tests/mochitest/chrome/DOMWindowCreated_chrome.xul
@@ -7,17 +7,17 @@
 <window id="sample-window" width="400" height="400"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript" 
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" 
           src="chrome://mochikit/content/chrome-harness.js"></script>
 
 <script type="application/javascript">
-var SimpleTest = window.arguments[0].SimpleTest;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 
 document.addEventListener("DOMWindowCreated", function(e) {
   var otherWindow = e.target.defaultView.wrappedJSObject;
   SimpleTest.is(e.type, "DOMWindowCreated", "DOMWindowCreated: " + otherWindow);
   otherWindow.doneFunction = function() {
     SimpleTest.ok(true, "doneFunction was called");
     SimpleTest.finish();
     window.close();
--- a/dom/tests/mochitest/chrome/MozDomFullscreen_chrome.xul
+++ b/dom/tests/mochitest/chrome/MozDomFullscreen_chrome.xul
@@ -21,21 +21,21 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="start();">
 
 <script src="chrome://mochikit/content/chrome-harness.js"></script>
 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 <script type="application/javascript"><![CDATA[
 
 function ok(condition, msg) {
-  window.arguments[0].ok(condition, msg);
+  window.opener.wrappedJSObject.ok(condition, msg);
 }
 
 function is(a, b, msg) {
-  window.arguments[0].is(a, b, msg);
+  window.opener.wrappedJSObject.is(a, b, msg);
 }
 
 var gBrowser = null;
 var gOuterDoc = null;
 var gInnerDoc = null;
 
 var gReceivedFullscreenEnteredEvent = false;
 var gReceivedNewOriginEvent = false;
@@ -83,17 +83,17 @@ function thirdEntry(event) {
 
 function earlyExit(event) {
   ok(false, "MozDOMFullscreen:Exited should only be triggered after cancel all fullscreen");
 }
 
 function lastExit(event) {
   is(event.target, gOuterDoc, "MozDOMFullscreen:Exited should be targeted at the last exited doc");
   ok(gOuterDoc.fullscreenElement == null, "Fullscreen should have been fully exited");
-  window.arguments[0].done();
+  window.opener.wrappedJSObject.done();
 }
 
 function start() {
   SimpleTest.waitForFocus(
     function() {
       gBrowser = document.getElementById("browser");
       gOuterDoc = gBrowser.contentDocument;
       gBrowser.contentWindow.focus();
--- a/dom/tests/mochitest/chrome/file_DOM_element_instanceof.xul
+++ b/dom/tests/mochitest/chrome/file_DOM_element_instanceof.xul
@@ -3,30 +3,30 @@
 <window title="Mozilla Bug 824917"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <iframe type="content"></iframe>
 
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 799299 **/
-  var SimpleTest = window.arguments[0].SimpleTest;
-  var ok = window.arguments[0].ok;
+  var SimpleTest = opener.wrappedJSObject.SimpleTest;
+  var ok = opener.wrappedJSObject.ok;
 
   // Note: We can't use frames[0] here because the type="content" attribute
   // isolates it into a separate browsing context hierarchy.
   var doc = document.querySelector("iframe").contentDocument;
   ok(doc.createElement("body") instanceof HTMLBodyElement,
      "Should be instance of HTMLBodyElement");
   ok(doc.createElement("div") instanceof HTMLDivElement,
      "Should be instance of HTMLDivElement");
   ok(doc.createElement("frameset") instanceof HTMLFrameSetElement,
      "Should be instance of HTMLFrameSetElement");
   ok(doc.createElement("h1") instanceof HTMLHeadingElement,
      "Should be instance of HTMLHeadingElement");
   ok(doc.createElement("label") instanceof HTMLLabelElement,
      "Should be instance of HTMLLabelElement");
 
   window.close();
-  window.arguments[0].SimpleTest.finish();
+  opener.wrappedJSObject.SimpleTest.finish();
   ]]>
   </script>
 </window>
--- a/dom/tests/mochitest/chrome/file_bug1224790-1_modal.xul
+++ b/dom/tests/mochitest/chrome/file_bug1224790-1_modal.xul
@@ -19,15 +19,15 @@ https://bugzilla.mozilla.org/show_bug.cg
   /** Test for Bug 1224790 **/
 
   function runTests() {
     window.openDialog('file_bug1224790-1_nonmodal.xul', '', 'dialog=no');
   }
 
   function nonModalClosed() {
     window.close();
-    window.arguments[0].modalClosed();
+    opener.wrappedJSObject.modalClosed();
   }
 
   SimpleTest.waitForFocus(runTests);
   ]]>
   </script>
 </dialog>
--- a/dom/tests/mochitest/chrome/file_bug1224790-2_modal.xul
+++ b/dom/tests/mochitest/chrome/file_bug1224790-2_modal.xul
@@ -21,15 +21,15 @@ https://bugzilla.mozilla.org/show_bug.cg
   var nonModal = null;
 
   function runTests() {
     nonModal = window.openDialog('file_bug1224790-2_nonmodal.xul', '', 'dialog=no');
   }
 
   function nonModalOpened() {
     window.close();
-    nonModal.modalClosed(window.arguments[0]);
+    nonModal.wrappedJSObject.modalClosed(opener);
   }
 
   SimpleTest.waitForFocus(runTests);
   ]]>
   </script>
 </dialog>
--- a/dom/tests/mochitest/chrome/file_bug799299.xul
+++ b/dom/tests/mochitest/chrome/file_bug799299.xul
@@ -25,39 +25,39 @@ https://bugzilla.mozilla.org/show_bug.cg
     wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
     wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
   }
 
   function runTests() {
     var b1 = document.getElementById("b1");
     var b2 = document.getElementById("b2");
     b1.contentWindow.focus();
-    window.arguments[0].is(document.activeElement, b1,
-                           "Focused first iframe");
+    opener.wrappedJSObject.is(document.activeElement, b1,
+                              "Focused first iframe");
 
     var didCallDummy = false;
     b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
     sendClick(b2.contentWindow);
-    window.arguments[0].ok(didCallDummy, "dummy mousedown handler should fire");
-    window.arguments[0].is(document.activeElement, b2,
-                           "Focus shifted to second iframe");
+    opener.wrappedJSObject.ok(didCallDummy, "dummy mousedown handler should fire");
+    opener.wrappedJSObject.is(document.activeElement, b2,
+                              "Focus shifted to second iframe");
 
     b1.contentWindow.focus();
-    window.arguments[0].is(document.activeElement, b1,
-                           "Re-focused first iframe for the first time");
+    opener.wrappedJSObject.is(document.activeElement, b1,
+                              "Re-focused first iframe for the first time");
 
     var didCallListener = false;
     b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
     sendClick(b2.contentWindow);
-    window.arguments[0].ok(didCallListener, "mousedown handler should fire");
-    window.arguments[0].is(document.activeElement, b2,
-                           "focus should move to the second iframe");
+    opener.wrappedJSObject.ok(didCallListener, "mousedown handler should fire");
+    opener.wrappedJSObject.is(document.activeElement, b2,
+                              "focus should move to the second iframe");
 
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    opener.wrappedJSObject.SimpleTest.finish();
   }
 
   SimpleTest.waitForFocus(runTests);
   ]]>
   </script>
   <hbox flex="1">
     <browser id="b1" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
     <browser id="b2" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
--- a/dom/tests/mochitest/chrome/file_bug800817.xul
+++ b/dom/tests/mochitest/chrome/file_bug800817.xul
@@ -25,51 +25,51 @@ https://bugzilla.mozilla.org/show_bug.cg
     wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
     wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
   }
 
   function runTests() {
     var b1 = document.getElementById("b1");
     var b2 = document.getElementById("b2");
 
-    var testMozBrowser = window.arguments[0].testMozBrowser;
+    var testMozBrowser = opener.wrappedJSObject.testMozBrowser;
     if (testMozBrowser) {
       b1.setAttribute("mozbrowser", "true");
       b2.setAttribute("mozbrowser", "true");
     }
 
     if (testMozBrowser)
-      window.arguments[0].info("Testing with mozbrowser=true");
+      opener.wrappedJSObject.info("Testing with mozbrowser=true");
     else
-      window.arguments[0].info("Testing without mozbrowser");
+      opener.wrappedJSObject.info("Testing without mozbrowser");
 
     b1.contentWindow.focus();
-    window.arguments[0].is(document.activeElement, b1,
-                           "Focused first iframe");
+    opener.wrappedJSObject.is(document.activeElement, b1,
+                              "Focused first iframe");
 
     var didCallDummy = false;
     b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
     sendClick(b2.contentWindow);
-    window.arguments[0].ok(didCallDummy, "dummy mousedown handler should fire");
-    window.arguments[0].is(document.activeElement, b2,
-                           "Focus shifted to second iframe");
+    opener.wrappedJSObject.ok(didCallDummy, "dummy mousedown handler should fire");
+    opener.wrappedJSObject.is(document.activeElement, b2,
+                              "Focus shifted to second iframe");
 
     b1.contentWindow.focus();
-    window.arguments[0].is(document.activeElement, b1,
-                           "Re-focused first iframe for the first time");
+    opener.wrappedJSObject.is(document.activeElement, b1,
+                              "Re-focused first iframe for the first time");
 
     var didCallListener = false;
     b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
     sendClick(b2.contentWindow);
-    window.arguments[0].ok(didCallListener, "mousedown handler should fire");
-    window.arguments[0].is(document.activeElement, b1,
-                           "Did not move focus to the second iframe");
+    opener.wrappedJSObject.ok(didCallListener, "mousedown handler should fire");
+    opener.wrappedJSObject.is(document.activeElement, b1,
+                              "Did not move focus to the second iframe");
 
     window.close();
-    window.arguments[0].finishedTests();
+    opener.wrappedJSObject.finishedTests();
   }
 
   SimpleTest.waitForFocus(runTests);
   ]]>
   </script>
   <iframe xmlns="http://www.w3.org/1999/xhtml"
           id="b1" type="content" src="about:blank"
           style="width: 300px; height: 550px; border: 1px solid black;"/>
--- a/dom/tests/mochitest/chrome/file_bug830858.xul
+++ b/dom/tests/mochitest/chrome/file_bug830858.xul
@@ -29,37 +29,37 @@ https://bugzilla.mozilla.org/show_bug.cg
     var docListenerCalled = 0;
     doc.addEventListener("foo", function() { ++docListenerCalled; }, true);
     var winListenerCalled = 0;
     win.addEventListener("foo", function() { ++winListenerCalled; }, true);
     var iframeListenerCalled = 0;
     b.addEventListener("foo", function() { ++iframeListenerCalled; }, true);
 
     doc.dispatchEvent(new Event("foo"));
-    window.arguments[0].is(docListenerCalled, 1, "Normal dispatch to Document");
-    window.arguments[0].is(winListenerCalled, 1, "Normal dispatch to Document");
-    window.arguments[0].is(iframeListenerCalled, 1, "Normal dispatch to Document");
+    opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Document");
+    opener.wrappedJSObject.is(winListenerCalled, 1, "Normal dispatch to Document");
+    opener.wrappedJSObject.is(iframeListenerCalled, 1, "Normal dispatch to Document");
 
     win.dispatchEvent(new Event("foo"));
-    window.arguments[0].is(docListenerCalled, 1, "Normal dispatch to Window");
-    window.arguments[0].is(winListenerCalled, 2, "Normal dispatch to Window");
-    window.arguments[0].is(iframeListenerCalled, 2, "Normal dispatch to Window");
+    opener.wrappedJSObject.is(docListenerCalled, 1, "Normal dispatch to Window");
+    opener.wrappedJSObject.is(winListenerCalled, 2, "Normal dispatch to Window");
+    opener.wrappedJSObject.is(iframeListenerCalled, 2, "Normal dispatch to Window");
 
     wu.dispatchEventToChromeOnly(doc, new Event("foo"));
-    window.arguments[0].is(docListenerCalled, 1, "Chrome-only dispatch to Document");
-    window.arguments[0].is(winListenerCalled, 2, "Chrome-only dispatch to Document");
-    window.arguments[0].is(iframeListenerCalled, 3, "Chrome-only dispatch to Document");
+    opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Document");
+    opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Document");
+    opener.wrappedJSObject.is(iframeListenerCalled, 3, "Chrome-only dispatch to Document");
 
     wu.dispatchEventToChromeOnly(win, new Event("foo"));
-    window.arguments[0].is(docListenerCalled, 1, "Chrome-only dispatch to Window");
-    window.arguments[0].is(winListenerCalled, 2, "Chrome-only dispatch to Window");
-    window.arguments[0].is(iframeListenerCalled, 4, "Chrome-only dispatch to Window");
+    opener.wrappedJSObject.is(docListenerCalled, 1, "Chrome-only dispatch to Window");
+    opener.wrappedJSObject.is(winListenerCalled, 2, "Chrome-only dispatch to Window");
+    opener.wrappedJSObject.is(iframeListenerCalled, 4, "Chrome-only dispatch to Window");
 
     window.close();
-    window.arguments[0].finishedTests();
+    opener.wrappedJSObject.finishedTests();
   }
 
   SimpleTest.waitForFocus(runTests);
   ]]>
   </script>
   <iframe xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           id="b" type="content" src="about:blank"
           style="width: 300px; height: 550px; border: 1px solid black;"/>
--- a/dom/tests/mochitest/chrome/file_clipboard_events_chrome.html
+++ b/dom/tests/mochitest/chrome/file_clipboard_events_chrome.html
@@ -1,1 +1,1 @@
-<body onload='window.arguments[0].doChecks(this)'><input id='i' value='Sample Text'></body>
+<body onload='window.opener.doChecks(this)'><input id='i' value='Sample Text'></body>
--- a/dom/tests/mochitest/chrome/fullscreen.xul
+++ b/dom/tests/mochitest/chrome/fullscreen.xul
@@ -8,17 +8,17 @@
         sizemode="fullscreen">
 
 <script>
 
 window.addEventListener("fullscreen", onFullScreen, true);
 
 function onFullScreen(event)
 {
-  window.arguments[0].done(window.fullScreen);
+  window.opener.wrappedJSObject.done(window.fullScreen);
 }
 
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 
 <button id="find-button" label="Find"/>
 <button id="cancel-button" label="Cancel"/>
--- a/dom/tests/mochitest/chrome/sizemode_attribute.xul
+++ b/dom/tests/mochitest/chrome/sizemode_attribute.xul
@@ -41,17 +41,17 @@ let tests = [
   },
 
   function test7() {
     listen("resize", () => checkAndContinue("normal"));
     window.restore();
   },
 
   function test8() {
-    window.arguments[0].done();
+    window.opener.wrappedJSObject.done();
   }
 ];
 
 function nextStep() {
   tests.shift()();
 }
 
 function listen(event, fn) {
@@ -72,16 +72,16 @@ function checkAndContinue(sizemode) {
   setTimeout(function() {
     is(window.document.documentElement.getAttribute("sizemode"), sizemode, "sizemode attribute should match actual window state");
     is(window.fullScreen, sizemode == "fullscreen", "window.fullScreen should match actual window state");
     is(window.windowState, windowStates[sizemode], "window.sizeMode should match actual window state");
     nextStep();
   }, 0);
 }
 
-let is = window.arguments[0].is;
+let is = window.opener.wrappedJSObject.is;
 
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 
 </body>
 </window>
--- a/dom/tests/mochitest/chrome/test_DOMWindowCreated.xul
+++ b/dom/tests/mochitest/chrome/test_DOMWindowCreated.xul
@@ -18,12 +18,12 @@
 </div>
 <pre id="test">
 </pre>
 </body>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 var root = getRootDirectory(window.location.href);
-window.openDialog(root + "DOMWindowCreated_chrome.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+window.open(root + "DOMWindowCreated_chrome.xul", "_blank", "chrome,width=600,height=550");
 </script>
 
 </window>
--- a/dom/tests/mochitest/chrome/test_DOM_element_instanceof.xul
+++ b/dom/tests/mochitest/chrome/test_DOM_element_instanceof.xul
@@ -17,17 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <iframe type="content"></iframe>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 824917 **/
 
   function runTests() {
-    window.openDialog("file_DOM_element_instanceof.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+    window.open("file_DOM_element_instanceof.xul", "_blank", "chrome,width=600,height=550");
   }
 
   addLoadEvent(runTests);
 
   SimpleTest.waitForExplicitFinish();
 
   ]]>
   </script>
--- a/dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul
+++ b/dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xul
@@ -33,18 +33,17 @@ pm.removeFromPrincipal(principal, "fulls
 SpecialPowers.pushPrefEnv({"set": [
   ['full-screen-api.enabled', true],
   ['full-screen-api.allow-trusted-requests-only', false],
   ['full-screen-api.transition-duration.enter', '0 0'],
   ['full-screen-api.transition-duration.leave', '0 0']
 ]}, setup);
 
 function setup() {
-   newwindow = docShell.rootTreeItem.domWindow.openDialog(
-      "MozDomFullscreen_chrome.xul", "_blank","chrome,dialog=no,resizable=yes,width=400,height=400", window);
+   newwindow = window.open("MozDomFullscreen_chrome.xul", "_blank","chrome,resizable=yes,width=400,height=400");
 }
 
 function done()
 {
   newwindow.close();
   SimpleTest.finish();
 }
 
--- a/dom/tests/mochitest/chrome/test_activation.xul
+++ b/dom/tests/mochitest/chrome/test_activation.xul
@@ -21,17 +21,17 @@
   <script type="application/javascript" 
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 
 <box id="box" height="100"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 
-newwindow = docShell.rootTreeItem.domWindow.openDialog("window_activation.xul", "_blank","chrome,width=300,height=200", window);
+newwindow = window.open("window_activation.xul", "_blank","chrome,width=300,height=200");
 
 function complete()
 {
   newwindow.close();
   SimpleTest.finish();
 }
 
 </script>
--- a/dom/tests/mochitest/chrome/test_bug1224790-1.xul
+++ b/dom/tests/mochitest/chrome/test_bug1224790-1.xul
@@ -18,17 +18,17 @@ https://bugzilla.mozilla.org/show_bug.cg
    * 1. Opens modal dialog
    * 2. Open non-modal window from modal dialog
    * 3. Close non-modal window
    * 4. Close modal dialog
    * 5. Click button to ensure mouse event is working
    */
 
   function startTest() {
-    window.openDialog('file_bug1224790-1_modal.xul', '', 'modal,noopener', window);
+    window.openDialog('file_bug1224790-1_modal.xul', '', 'modal');
   }
 
   function modalClosed() {
     SimpleTest.waitForFocus(gotFocus);
   }
 
   var timer = null;
   function gotFocus() {
--- a/dom/tests/mochitest/chrome/test_bug1224790-2.xul
+++ b/dom/tests/mochitest/chrome/test_bug1224790-2.xul
@@ -19,17 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
    * 2. Open non-modal window from modal dialog
    * 3. Close modal dialog
    * 4. Wait for a while for destructor for modal dialog
    * 5. Close non-modal window
    * 6. Click button to ensure mouse event is working
    */
 
   function startTest() {
-    window.openDialog('file_bug1224790-2_modal.xul', '', 'modal,noopener', window);
+    window.openDialog('file_bug1224790-2_modal.xul', '', 'modal');
   }
 
   function nonModalClosed() {
     SimpleTest.waitForFocus(gotFocus);
   }
 
   var timer = null;
   function gotFocus() {
--- a/dom/tests/mochitest/chrome/test_bug799299.xul
+++ b/dom/tests/mochitest/chrome/test_bug799299.xul
@@ -16,16 +16,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 799299 **/
 
   function runTests() {
-    window.openDialog("file_bug799299.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+    window.open("file_bug799299.xul", "_blank", "chrome,width=600,height=550");
   }
 
   SimpleTest.waitForExplicitFinish();
 
   ]]>
   </script>
 </window>
--- a/dom/tests/mochitest/chrome/test_bug800817.xul
+++ b/dom/tests/mochitest/chrome/test_bug800817.xul
@@ -18,24 +18,24 @@ https://bugzilla.mozilla.org/show_bug.cg
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 800817 **/
 
   var testMozBrowser = false;
   function runTests() {
     // Run a first round of tests for non-mozbrowser iframes.
-    window.openDialog("file_bug800817.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+    window.open("file_bug800817.xul", "_blank", "chrome,width=600,height=550");
   }
 
   function finishedTests() {
     if (!testMozBrowser) {
       testMozBrowser = true;
       // Run a second round of tests for mozbrowser iframes.
-      window.openDialog("file_bug800817.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+      window.open("file_bug800817.xul", "_blank", "chrome,width=600,height=550");
     } else {
       SimpleTest.finish();
     }
   }
 
   SimpleTest.waitForExplicitFinish();
 
   ]]>
--- a/dom/tests/mochitest/chrome/test_bug830858.xul
+++ b/dom/tests/mochitest/chrome/test_bug830858.xul
@@ -11,17 +11,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 830858 **/
 
   function runTests() {
-    window.openDialog("file_bug830858.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+    window.open("file_bug830858.xul", "_blank", "chrome,width=600,height=550");
   }
 
   function finishedTests() {
     SimpleTest.finish();
   }
 
   SimpleTest.waitForExplicitFinish();
 
--- a/dom/tests/mochitest/chrome/test_clipboard_events_chrome.html
+++ b/dom/tests/mochitest/chrome/test_clipboard_events_chrome.html
@@ -6,17 +6,17 @@
 
 <script>
 // This test checks that the dom.event.clipboardevents.enabled does not apply to chrome shells.
 
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
   SpecialPowers.pushPrefEnv({"set": [['dom.event.clipboardevents.enabled', false]]}, function() {
-    window.openDialog("file_clipboard_events_chrome.html", "_blank", "chrome,width=200,height=200,noopener", window);
+    window.open("file_clipboard_events_chrome.html", "_blank", "chrome,width=200,height=200");
   });
 }
 
 var event_fired = false;
 
 function doChecks(win)
 {
   var windowFocused = function() {
--- a/dom/tests/mochitest/chrome/test_docshell_swap.xul
+++ b/dom/tests/mochitest/chrome/test_docshell_swap.xul
@@ -12,18 +12,18 @@
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
   SimpleTest.waitForExplicitFinish();
 
   // Create two identical windows, each with a <browser> element.
-  let win1 = docShell.rootTreeItem.domWindow.openDialog("window_docshell_swap.xul", "_blank","chrome,width=300,height=200");
-  let win2 = docShell.rootTreeItem.domWindow.openDialog("window_docshell_swap.xul", "_blank","chrome,width=300,height=200");
+  let win1 = window.openDialog("window_docshell_swap.xul", "_blank","chrome,width=300,height=200");
+  let win2 = window.openDialog("window_docshell_swap.xul", "_blank","chrome,width=300,height=200");
 
   let loadCount = 0;
   function loadHandler() {
     loadCount++;
     if (loadCount < 2)
       return;
 
     let browser1 = win1.document.getElementById("browser");
--- a/dom/tests/mochitest/chrome/test_focus.xul
+++ b/dom/tests/mochitest/chrome/test_focus.xul
@@ -11,17 +11,17 @@
 <script>
 if (navigator.platform.startsWith("Win")) {
   SimpleTest.expectAssertions(0, 1);
 }
 
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_focus.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+  window.open("window_focus.xul", "_blank", "chrome,width=600,height=550");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/dom/tests/mochitest/chrome/test_focus_docnav.xul
+++ b/dom/tests/mochitest/chrome/test_focus_docnav.xul
@@ -6,17 +6,17 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_focus_docnav.xul", "_blank", "chrome,width=600,height=550,noopener", window);
+  window.open("window_focus_docnav.xul", "_blank", "chrome,width=600,height=550");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/dom/tests/mochitest/chrome/test_fullscreen.xul
+++ b/dom/tests/mochitest/chrome/test_fullscreen.xul
@@ -8,17 +8,17 @@
         sizemode="fullscreen">
 
   <script type="application/javascript" 
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 
 <script>
 SimpleTest.waitForExplicitFinish();
 
-newwindow = docShell.rootTreeItem.domWindow.openDialog("fullscreen.xul", "_blank","chrome,resizable=yes", window);
+newwindow = window.open("fullscreen.xul", "_blank","chrome,resizable=yes");
 
 function done()
 {
   // because we are cancelling the fullscreen event, it
   // takes a bit for the fullScreen property to be set
   setTimeout(function() { this.complete(); }, 0);
 }
 
--- a/dom/tests/mochitest/chrome/test_sizemode_attribute.xul
+++ b/dom/tests/mochitest/chrome/test_sizemode_attribute.xul
@@ -8,17 +8,17 @@
         sizemode="fullscreen">
 
   <script type="application/javascript" 
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 
 <script>
 SimpleTest.waitForExplicitFinish();
 
-newwindow = docShell.rootTreeItem.domWindow.openDialog("sizemode_attribute.xul", "_blank","chrome,resizable=yes", window);
+newwindow = window.open("sizemode_attribute.xul", "_blank","chrome,resizable=yes");
 
 function done() {
   newwindow.close();
   SimpleTest.finish();
 }
 
 </script>
 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px;"/>
--- a/dom/tests/mochitest/chrome/window_activation.xul
+++ b/dom/tests/mochitest/chrome/window_activation.xul
@@ -13,25 +13,25 @@
 " type="text/css"?>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 <box id="box" height="100"/>
 
 <script type="application/javascript"><![CDATA[
 
-var ok = window.arguments[0].ok;
-var complete = window.arguments[0].complete;
-var openerDoc = window.arguments[0].document;
-var SimpleTest = window.arguments[0].SimpleTest;
+var ok = window.opener.wrappedJSObject.ok;
+var complete = window.opener.wrappedJSObject.complete;
+var openerDoc = window.opener.wrappedJSObject.document;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 
 SimpleTest.waitForFocus(function () {
   ok(getComputedStyle(document.getElementById("box"), "").backgroundColor, "rgb(0, 0, 255)");
   ok(getComputedStyle(openerDoc.getElementById("box"), "").backgroundColor, "rgb(0, 255, 255)");
-  window.arguments[0].focus();
+  window.opener.focus();
   ok(getComputedStyle(document.getElementById("box"), "").backgroundColor, "rgb(0, 255, 255)");
   ok(getComputedStyle(openerDoc.getElementById("box"), "").backgroundColor, "rgb(0, 0, 255)");
   complete();
 }, window);
 
 ]]></script>
 
 </window>
--- a/dom/tests/mochitest/chrome/window_focus.xul
+++ b/dom/tests/mochitest/chrome/window_focus.xul
@@ -34,18 +34,18 @@ var gEvents = "";
 var gExpectedEvents = "";
 var gEventMatched = true;
 var gShowOutput = false;
 var gChildWindow = null;
 
 var gOldExpectedWindow = null;
 var gNewExpectedWindow = null;
 
-function is(l, r, n) { window.arguments[0].SimpleTest.is(l,r,n); }
-function ok(v, n) { window.arguments[0].SimpleTest.ok(v,n); }
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
+function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
 
 function initEvents(target)
 {
   target.addEventListener("focus", eventOccured, true);
   target.addEventListener("blur", eventOccured, true);
   getTopWindow(target).addEventListener("activate", eventOccured, true);
   getTopWindow(target).addEventListener("deactivate", eventOccured, true);
 }
@@ -317,19 +317,19 @@ function mouseOnElement(element, expecte
     expectFocusShift(() => synthesizeMouse(element, 4, 4, { }, element.ownerGlobal),
                      element.ownerGlobal,
                      expectedElement, focusChanged, testid);
   }
 }
 
 function done()
 {
-  var opener = window.arguments[0];
+  var opener = window.opener;
   window.close();
-  window.arguments[0].SimpleTest.finish();
+  opener.wrappedJSObject.SimpleTest.finish();
 }
 
 var pressTab = () => synthesizeKey("KEY_Tab");
 
 function setFocusTo(id, fwindow)
 {
   gLastFocus = getById(id);
   gLastFocusWindow = fwindow;
@@ -1159,18 +1159,17 @@ function modalWindowOpened(modalWindow)
   SimpleTest.waitForFocus(modalWindowClosed);
 }
 
 function modalWindowClosed()
 {
   is(fm.activeWindow, window, "modal window closed activeWindow");
   is(fm.focusedElement, getById("n2"), "modal window closed focusedElement");
 
-  window.arguments[0].framesetWindowLoaded = framesetWindowLoaded;
-  window.arguments[0].open("focus_frameset.html", "_blank", "width=400,height=400,toolbar=no");
+  window.open("focus_frameset.html", "_blank", "width=400,height=400,toolbar=no");
 }
 
 function framesetWindowLoaded(framesetWindow)
 {
   gLastFocus = null;
   gLastFocusWindow = framesetWindow;
   gEvents = "";
 
--- a/dom/tests/mochitest/chrome/window_focus_docnav.xul
+++ b/dom/tests/mochitest/chrome/window_focus_docnav.xul
@@ -20,18 +20,18 @@
 <browser id="browser" type="content" src="focus_frameset.html" width="500" height="400"/>
 
 <script type="application/javascript">
 <![CDATA[
 
 var fm = Cc["@mozilla.org/focus-manager;1"].
            getService(Ci.nsIFocusManager);
 
-function is(l, r, n) { window.arguments[0].SimpleTest.is(l,r,n); }
-function ok(v, n) { window.arguments[0].SimpleTest.ok(v,n); }
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
+function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
 
 function noChildrenTest()
 {
   // Remove the browser element and test navigation when there are no other documents.
   // The focus should move or stay on the first focusable element.
   let browser = document.getElementById("browser");
   browser.remove();
 
@@ -46,18 +46,19 @@ function noChildrenTest()
   previous(window, textbox1.inputField, "Focus backward when no child documents");
   previous(window, textbox1.inputField, "Focus backward again when no child documents");
 
   done();
 }
 
 function done()
 {
+  var opener = window.opener;
   window.close();
-  window.arguments[0].SimpleTest.finish();
+  opener.wrappedJSObject.SimpleTest.finish();
 }
 
 function previous(expectedWindow, expectedElement, desc)
 {
   synthesizeKey("KEY_F6", {shiftKey: true});
   is(fm.focusedWindow, expectedWindow, desc);
   is(fm.focusedElement, expectedElement, desc + " element");
 }
@@ -108,17 +109,17 @@ function runTests(panel, popupCount)
   else if (panel == document.getElementById("panel2"))
     panel.hidePopup();
   else
     document.getElementById("panel").openPopup(null, "after_start");
 }
 
 function start()
 {
-  window.arguments[0].SimpleTest.waitForExplicitFinish();
-  window.arguments[0].SimpleTest.waitForFocus(
+  window.opener.wrappedJSObject.SimpleTest.waitForExplicitFinish();
+  window.opener.wrappedJSObject.SimpleTest.waitForFocus(
     function() { runTests(null, 0); },
     document.getElementById("browser").contentWindow);
 }
 
 ]]></script>
 
 </window>
--- a/dom/xul/test/test_bug583948.xul
+++ b/dom/xul/test/test_bug583948.xul
@@ -9,33 +9,30 @@
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <div id="content" style="display: none"/>
 </body>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 
-let chromeWindow = docShell.rootTreeItem.domWindow;
-
 var attempts = 0;
 
-chromeWindow.update = function () {
+function update() {
   // without the crash fix, this usually crashes after 2 to 4 reloads
   if (++attempts == 6) {
     ok(true, "didn't crash after 6 attempts");
     otherWindow.close();
     SimpleTest.waitForFocus(function() {
-      chromeWindow.update = null;
       SimpleTest.finish();
     });
   } else {
     otherWindow.document.commandDispatcher.updateCommands('');
     setTimeout(function() {
       otherWindow.location.reload()
     }, 0);
   }
 }
 
-var otherWindow = chromeWindow.open("window_bug583948.xul", "_blank", "chrome");
+var otherWindow = window.open("window_bug583948.xul", "_new", "chrome");
 </script>
 
 </window>
--- a/dom/xul/test/test_bug757137.xul
+++ b/dom/xul/test/test_bug757137.xul
@@ -15,17 +15,17 @@
 SimpleTest.waitForExplicitFinish();
 
 // Force off out-of-process mozbrowser because we need to grab its
 // |window| synchronously from here.  Out-of-process docshell creation
 // for mozbrowser haves entirely differently.
 SpecialPowers.pushPrefEnv({"set":[["dom.ipc.tabs.disabled", true]]}, startTest);
 
 function startTest() {
-  var otherWindow = docShell.rootTreeItem.domWindow.open("window_bug757137.xul", "", "chrome");
+  var otherWindow = window.open("window_bug757137.xul", "", "chrome");
   ok(otherWindow.isChromeWindow, 'XUL window should be a ChromeWindow');
 
   otherWindow.onload = function () {
     var w = otherWindow.document.getElementById('f').contentWindow;
     ok(w !== null, 'got the |window| for a mozbrowser iframe');
     ok(!w.isChromeWindow, 'mozbrowser iframe should not be a ChromeWindow');
 
     otherWindow.close();
--- a/js/xpconnect/tests/chrome/bug503926.xul
+++ b/js/xpconnect/tests/chrome/bug503926.xul
@@ -15,15 +15,15 @@ https://bugzilla.mozilla.org/show_bug.cg
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
       var gWindowUtils = window.windowUtils;
       var passed = false;
       var obj = { QueryInterface: function() { passed = true; } }
       gWindowUtils.xpconnectArgument(obj);
       var isDialog = location.hash != '#iframe';
-      var outer = XPCNativeWrapper.unwrap(isDialog ? window.arguments[0] : parent);
+      var outer = XPCNativeWrapper.unwrap(isDialog ? opener : parent);
       outer.ok(passed, "chrome/chrome test passed: " + (isDialog ? "dialog" : "iframe"));
       if (isDialog)
         close();
   ]]>
   </script>
 </window>
--- a/js/xpconnect/tests/chrome/file_bug618176.xul
+++ b/js/xpconnect/tests/chrome/file_bug618176.xul
@@ -16,33 +16,33 @@ https://bugzilla.mozilla.org/show_bug.cg
 "data:text/html,<script>var a=[1,2,3];</script>Hi";
 
     const FRAME_SCRIPT = 
 "data:,addEventListener('pageshow', function() { sendAsyncMessage('test', content.wrappedJSObject.a) }, false);";
    // s/content.wrappedJSObject.a/[ 1, 2, 3]/ and the test passes
 
     function recvTest(m) {
       var a = m.json;
-      window.arguments[0].is(a.length, 3, "array was serialized and deserialized");
+      opener.wrappedJSObject.is(a.length, 3, "array was serialized and deserialized");
 
       messageManager.removeMessageListener("test", recvTest);
       finish();
     }
 
     function start() {
       messageManager.addMessageListener("test", recvTest);
       messageManager.loadFrameScript(FRAME_SCRIPT, true);
       const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
       let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
       setTimeout(function () {
         document.getElementById("browser").loadURI(TEST_PAGE, {triggeringPrincipal});
       }, 0);
     }
 
     function finish() {
-      window.arguments[0].setTimeout(function() { this.done(); }, 0);
+      opener.setTimeout(function() { this.done(); }, 0);
       window.close();
     }
 
   ]]></script>
 
   <browser id="browser" type="content" style="width: 200px; height: 200px;"/>
 </window>
--- a/js/xpconnect/tests/chrome/test_bug1124898.html
+++ b/js/xpconnect/tests/chrome/test_bug1124898.html
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   /** Test for Bug 1124898 **/
   SimpleTest.waitForExplicitFinish();
   (async () => {
     await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", true]]});
 
     SimpleTest.expectAssertions(0, 1); // Dumb unrelated widget assertion - see bug 1126023.
 
-    var w = docShell.rootTreeItem.domWindow.open("about:blank", "w", "chrome");
+    var w = window.open("about:blank", "w", "chrome");
     is(w.eval('typeof getAttention'), 'function', 'getAttention exists on regular chrome window');
     is(w.eval('typeof messageManager'), 'object', 'messageManager exists on regular chrome window');
     var contentURL = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
     w.location = contentURL;
     tryWindow();
 
     function tryWindow() {
       if (w.document.title != 'empty test page') {
--- a/js/xpconnect/tests/chrome/test_bug503926.xul
+++ b/js/xpconnect/tests/chrome/test_bug503926.xul
@@ -42,16 +42,16 @@ https://bugzilla.mozilla.org/show_bug.cg
     // Try with a content object.
     var contentWin = $('ifrContent').contentWindow.wrappedJSObject;
     contentWin.passed = false;
     var contentObj = contentWin.eval('({ QueryInterface: function() { passed = true; } })');
     gWindowUtils.xpconnectArgument(contentObj);
     ok(!contentWin.passed, "untrusted QI should not be called");
 
     // Try with a dialog.
-    docShell.rootTreeItem.domWindow.openDialog("bug503926.xul", "chromeDialog", "modal", window);
+    openDialog("bug503926.xul", "chromeDialog", "modal");
     SimpleTest.finish();
   }
 
   SimpleTest.waitForExplicitFinish();
   ]]>
   </script>
 </window>
--- a/js/xpconnect/tests/chrome/test_bug618176.xul
+++ b/js/xpconnect/tests/chrome/test_bug618176.xul
@@ -19,12 +19,12 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
 
   function done() {
     SimpleTest.finish();
   }
 
   addLoadEvent(function() {
-    window.openDialog("file_bug618176.xul", "", "chrome,noopener", window);
+    window.open("file_bug618176.xul", "", "chrome");
   });
   ]]></script>
 </window>
--- a/layout/base/tests/chrome/bug1041200_window.html
+++ b/layout/base/tests/chrome/bug1041200_window.html
@@ -4,22 +4,22 @@
   <title>Test for Bug 1041200</title>
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
   <script src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
 </head>
 <body>
 <iframe style="width:700px; height:500px; margin-top:200px;" id="ourFrame"></iframe>
 <script>
-var SpecialPowers = window.arguments[0].SpecialPowers;
-var SimpleTest = window.arguments[0].SimpleTest;
-var ok = window.arguments[0].ok;
-var info = window.arguments[0].info;
+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 = ourFrame.contentWindow.docShell.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/chrome_content_integration_window.xul
+++ b/layout/base/tests/chrome/chrome_content_integration_window.xul
@@ -17,17 +17,17 @@
     <!-- the top 100px is a strip of black above the content iframe -->
     <vbox style="border-top:100px solid black;"/>
   </stack>
 
   <script type="application/javascript">
     <![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok", "SpecialPowers" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
     
     function runTests() {
       var testCanvas = snapshotWindow(window);
 
       var refCanvas = snapshotWindow(window);
       var ctx = refCanvas.getContext('2d');
       ctx.fillStyle = "black";
--- a/layout/base/tests/chrome/chrome_over_plugin_window.xul
+++ b/layout/base/tests/chrome/chrome_over_plugin_window.xul
@@ -14,17 +14,17 @@
       <vbox style="height:50px;"/> <!-- plugin should be visible here -->
     </vbox>
   </stack>
 
   <script type="application/javascript">
     <![CDATA[
     var imports = [ "SimpleTest", "is", "isnot", "ok", "todo" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     var plugin;
     function waitForPaint() {
       if (plugin.getPaintCount() < 1) {
         setTimeout(waitForPaint, 0);
         return;
       }
--- a/layout/base/tests/chrome/default_background_window.xul
+++ b/layout/base/tests/chrome/default_background_window.xul
@@ -10,17 +10,17 @@
   <iframe type="content" id="f" src="about:blank" style="border:1px solid black;"/>
 
   <script type="application/javascript">
   <![CDATA[
     SimpleTest.waitForExplicitFinish();
 
     var imports = [ "SimpleTest", "is", "isnot", "ok" ];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
     
     function snapshot(win) {
       var el = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
       el.width = win.innerWidth;
       el.height = win.innerHeight;
 
       var ctx = el.getContext("2d");
--- a/layout/base/tests/chrome/dialog_with_positioning_window.xul
+++ b/layout/base/tests/chrome/dialog_with_positioning_window.xul
@@ -4,20 +4,20 @@
         onload="setTimeout(runTest, 0)">
   <vbox>
     <text value="powered by example.com" style="padding: 16px;"/>
   </vbox>
   <hbox id="t" style="position: fixed; right: 16px; bottom: 16px;">
     <button label="OK"/>
   </hbox>
 <script><![CDATA[
-var SimpleTest = window.arguments[0].SimpleTest;
-var SpecialPowers = window.arguments[0].SpecialPowers;
-var is = window.arguments[0].is;
-var ok = window.arguments[0].ok;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
+var SpecialPowers = window.opener.wrappedJSObject.SpecialPowers;
+var is = window.opener.wrappedJSObject.is;
+var ok = window.opener.wrappedJSObject.ok;
 
 // We run this off a setTimeout from onload, because the XUL window
 // only does its intrinsic-height layout after the load event has
 // finished
 function runTest() {
   var t = document.getElementById("t");
   var tBottom = t.getBoundingClientRect().bottom;
   is(tBottom, document.documentElement.getBoundingClientRect().bottom - 16,
--- a/layout/base/tests/chrome/file_bug1018265.xul
+++ b/layout/base/tests/chrome/file_bug1018265.xul
@@ -26,25 +26,25 @@ https://bugzilla.mozilla.org/show_bug.cg
   function errorPageLoaded() {
     testcontent.addEventListener("pageshow", didGoBack, true);
     setTimeout(function() {testcontent.contentWindow.history.back();}, 0);
   }
 
   function didGoBack(e) {
     testcontent.removeEventListener("pageshow", didGoBack, true);
     shouldHaveTwoNonHiddenContentViewers();
-    window.arguments[0].done();
+    opener.done();
     window.close();
   }
 
   function getContentViewer(win) {
     return win.docShell.contentViewer;
   }
 
   function shouldHaveTwoNonHiddenContentViewers() {
-    window.arguments[0].is(getContentViewer(testcontent.contentWindow).isHidden, false, "Top level ContentViewer should not be hidden.");
-    window.arguments[0].is(getContentViewer(testcontent.contentWindow.frames[0]).isHidden, false, " Iframe's ContentViewer should not be hidden.");
+    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>
 
   <browser type="content" id="testcontent" flex="1" src="data:text/html,&lt;iframe&gt;&lt;/iframe&gt;"/>
 </window>
--- a/layout/base/tests/chrome/printpreview_bug396024_helper.xul
+++ b/layout/base/tests/chrome/printpreview_bug396024_helper.xul
@@ -10,20 +10,20 @@ https://bugzilla.mozilla.org/show_bug.cg
 <iframe id="i" src="about:blank" type="content"></iframe>
 <iframe src="about:blank" type="content"></iframe>
 <script type="application/javascript">
 <![CDATA[
 // Note: We can't use window.frames directly here because the type="content"
 // attributes isolate the frames into their own BrowsingContext hierarchies.
 let frameElts = document.getElementsByTagName("iframe");
 
-var is = window.arguments[0].is;
-var ok = window.arguments[0].ok;
-var todo = window.arguments[0].todo;
-var SimpleTest = window.arguments[0].SimpleTest;
+var is = window.opener.wrappedJSObject.is;
+var ok = window.opener.wrappedJSObject.ok;
+var todo = window.opener.wrappedJSObject.todo;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 var gWbp;
 function printpreview() {
   gWbp = frameElts[1].contentWindow.docShell.initOrReusePrintPreviewViewer();
   var listener = {
     onLocationChange: function(webProgress, request, location, flags) { },
     onProgressChange: function(webProgress, request, curSelfProgress, 
                                maxSelfProgress, curTotalProgress,
                                maxTotalProgress) { },
--- a/layout/base/tests/chrome/printpreview_bug482976_helper.xul
+++ b/layout/base/tests/chrome/printpreview_bug482976_helper.xul
@@ -10,20 +10,20 @@ https://bugzilla.mozilla.org/show_bug.cg
 <iframe src="about:blank" type="content"></iframe>
 <iframe src="about:blank" type="content"></iframe>
 <script type="application/javascript">
 <![CDATA[
 // Note: We can't use window.frames directly here because the type="content"
 // attributes isolate the frames into their own BrowsingContext hierarchies.
 let frameElts = document.getElementsByTagName("iframe");
 
-var is = window.arguments[0].is;
-var ok = window.arguments[0].ok;
-var todo = window.arguments[0].todo;
-var SimpleTest = window.arguments[0].SimpleTest;
+var is = window.opener.wrappedJSObject.is;
+var ok = window.opener.wrappedJSObject.ok;
+var todo = window.opener.wrappedJSObject.todo;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 var gWbp;
 function printpreview() {
   gWbp = frameElts[1].contentWindow.docShell.initOrReusePrintPreviewViewer();
   var listener = {
     onLocationChange: function(webProgress, request, location, flags) { },
     onProgressChange: function(webProgress, request, curSelfProgress, 
                                maxSelfProgress, curTotalProgress,
                                maxTotalProgress) { },
--- a/layout/base/tests/chrome/printpreview_helper.xul
+++ b/layout/base/tests/chrome/printpreview_helper.xul
@@ -7,21 +7,21 @@
 <iframe height="200" width="600" type="content"></iframe>
 <iframe height="200" width="600" type="content"></iframe>
 <script type="application/javascript">
 <![CDATA[
 // Note: We can't use window.frames directly here because the type="content"
 // attributes isolate the frames into their own BrowsingContext hierarchies.
 let frameElts = document.getElementsByTagName("iframe");
 
-var is = window.arguments[0].is;
-var isnot = window.arguments[0].isnot;
-var ok = window.arguments[0].ok;
-var todo = window.arguments[0].todo;
-var SimpleTest = window.arguments[0].SimpleTest;
+var is = window.opener.wrappedJSObject.is;
+var isnot = window.opener.wrappedJSObject.isnot;
+var ok = window.opener.wrappedJSObject.ok;
+var todo = window.opener.wrappedJSObject.todo;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 var gWbp;
 var ctx1;
 var ctx2;
 var counter = 0;
 
 var file = Cc["@mozilla.org/file/directory_service;1"]
              .getService(Ci.nsIProperties)
              .get("TmpD", Ci.nsIFile);
--- a/layout/base/tests/chrome/test_bug1018265.xul
+++ b/layout/base/tests/chrome/test_bug1018265.xul
@@ -14,17 +14,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 1018265 **/
 
   SimpleTest.waitForExplicitFinish();
 
   function run() {
-    window.openDialog("file_bug1018265.xul", "contentViewerTest", "chrome,width=100,height=100,noopener", window);
+    window.open("file_bug1018265.xul", "contentViewerTest", "chrome,width=100,height=100");
   }
 
   function done() {
     ok(true, "done");
     setTimeout(function() { SimpleTest.finish(); }, 0);
   }
   ]]>
   </script>
--- a/layout/base/tests/chrome/test_bug1041200.xul
+++ b/layout/base/tests/chrome/test_bug1041200.xul
@@ -10,13 +10,13 @@
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
     SimpleTest.waitForExplicitFinish();
     // Run the test in a separate window so that the test runs as a chrome
     // window
-    window.openDialog("bug1041200_window.html", "bug1041200",
-                      "chrome,width=800,height=800,noopener", window);
+    window.open("bug1041200_window.html", "bug1041200",
+                "chrome,width=800,height=800");
   ]]>
   </script>
 </window>
--- a/layout/base/tests/chrome/test_bug458898.html
+++ b/layout/base/tests/chrome/test_bug458898.html
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=458898">Mozilla Bug 458898</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
-var win = docShell.rootTreeItem.domWindow.openDialog("file_bug458898.html");
+var win = window.openDialog("file_bug458898.html");
 
 function loaded() {
   var disableWindowResizePref = "dom.disable_window_move_resize";
   SpecialPowers.pushPrefEnv({"set":[[disableWindowResizePref, false]]}, function() {
     win.sizeToContent();
     ok(win.innerWidth >= 100, "innerWidth: " + win.innerWidth + " >= 100 ?");
     ok(win.innerHeight >= 200, "innerHeight: " + win.innerHeight + " >= 200 ?");
     win.close();
--- a/layout/base/tests/chrome/test_chrome_content_integration.xul
+++ b/layout/base/tests/chrome/test_chrome_content_integration.xul
@@ -12,13 +12,13 @@
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
     SimpleTest.waitForExplicitFinish();
     // Run the test in a separate window so that the test runs as a chrome
     // window
     var root = getRootDirectory(window.location.href);
-    window.openDialog(root + "chrome_content_integration_window.xul", "chrome_content_integration",
-                      "chrome,width=200,height=300,noopener", window);
+    window.open(root + "chrome_content_integration_window.xul", "chrome_content_integration",
+                "chrome,width=200,height=300");
   ]]>
   </script>
 </window>
--- a/layout/base/tests/chrome/test_chrome_over_plugin.xul
+++ b/layout/base/tests/chrome/test_chrome_over_plugin.xul
@@ -12,13 +12,13 @@
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
     SimpleTest.waitForExplicitFinish();
     // Run the test in a separate window so that the test runs as a chrome
     // window
     SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
-    var w = window.openDialog("chrome_over_plugin_window.xul", "chrome_over_plugin",
-                              "chrome,width=200,height=300,noopener", window);
+    var w = window.open("chrome_over_plugin_window.xul", "chrome_over_plugin",
+                         "chrome,width=200,height=300");
   ]]>
   </script>
 </window>
--- a/layout/base/tests/chrome/test_css_visibility_propagation.xul
+++ b/layout/base/tests/chrome/test_css_visibility_propagation.xul
@@ -7,22 +7,22 @@
 <body xmlns="http://www.w3.org/1999/xhtml"></body>
 <script>
 <![CDATA[
 const baseURL = "chrome://mochitests/content/chrome/layout/base/tests/chrome/";
 
 // Tests that iframe visibility is updated when it's swapped.
 add_task(async () => {
   // Open two new windows to swap iframes.
-  const window1 = docShell.rootTreeItem.domWindow.open(
-      baseURL + "window_css_visibility_propagation-1.html",
-      "_blank", "chrome");
-  const window2 = docShell.rootTreeItem.domWindow.open(
-      baseURL + "window_css_visibility_propagation-2.html",
-      "_blank", "chrome");
+  const window1 =
+      window.open(baseURL + "window_css_visibility_propagation-1.html",
+                  "_blank", "chrome");
+  const window2 =
+      window.open(baseURL + "window_css_visibility_propagation-2.html",
+                  "_blank", "chrome");
 
   const loadWindow1 =
       new Promise(resolve => window1.addEventListener("load", resolve));
   const loadWindow2 =
       new Promise(resolve => window2.addEventListener("load", resolve));
 
   await Promise.all([ loadWindow1, loadWindow2 ]);
 
--- a/layout/base/tests/chrome/test_default_background.xul
+++ b/layout/base/tests/chrome/test_default_background.xul
@@ -10,13 +10,13 @@
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
     SimpleTest.waitForExplicitFinish();
     // Run the test in a separate window so that the test runs as a chrome
     // window
-    window.openDialog("default_background_window.xul", "default_background",
-                      "chrome,width=200,height=300,noopener", window);
+    window.open("default_background_window.xul", "default_background",
+                "chrome,width=200,height=300");
   ]]>
   </script>
 </window>
--- a/layout/base/tests/chrome/test_dialog_with_positioning.html
+++ b/layout/base/tests/chrome/test_dialog_with_positioning.html
@@ -8,13 +8,13 @@
 </head>
 <body>
 <pre id="test">
 <script type="application/javascript">
 SimpleTest.waitForExplicitFinish();
 
 var root = getRootDirectory(window.location.href);
 window.openDialog(root + "dialog_with_positioning_window.xul", "dialog_with_positioning",
-                  "dialog,chrome,noopener", window);
+                  "dialog,chrome");
 </script>
 </pre>
 </body>
 </html>
--- a/layout/base/tests/chrome/test_printpreview.xul
+++ b/layout/base/tests/chrome/test_printpreview.xul
@@ -5,11 +5,11 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 <body xmlns="http://www.w3.org/1999/xhtml">
 </body>
   <!-- test code goes here -->
 <script type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
-window.openDialog("printpreview_helper.xul", "printpreview", "chrome,width=100,height=100,noopener", window);
+window.open("printpreview_helper.xul", "printpreview", "chrome,width=100,height=100");
 ]]></script>
 </window>
--- a/layout/base/tests/chrome/test_printpreview_bug396024.xul
+++ b/layout/base/tests/chrome/test_printpreview_bug396024.xul
@@ -11,11 +11,11 @@ https://bugzilla.mozilla.org/show_bug.cg
 <body xmlns="http://www.w3.org/1999/xhtml">
 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=396024"
    target="_blank">Mozilla Bug 396024</a>
 </body>
   <!-- test code goes here -->
 <script type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
-window.openDialog("printpreview_bug396024_helper.xul", "bug396024", "chrome,width=100,height=100,noopener", window);
+window.open("printpreview_bug396024_helper.xul", "bug396024", "chrome,width=100,height=100");
 ]]></script>
 </window>
--- a/layout/base/tests/chrome/test_printpreview_bug482976.xul
+++ b/layout/base/tests/chrome/test_printpreview_bug482976.xul
@@ -11,11 +11,11 @@ https://bugzilla.mozilla.org/show_bug.cg
 <body xmlns="http://www.w3.org/1999/xhtml">
 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=482976"
    target="_blank">Mozilla Bug 482976</a>
 </body>
   <!-- test code goes here -->
 <script type="application/javascript">
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
-window.openDialog("printpreview_bug482976_helper.xul", "bug482976", "chrome,width=100,height=100,noopener", window);
+window.open("printpreview_bug482976_helper.xul", "bug482976", "chrome,width=100,height=100");
 ]]></script>
 </window>
--- a/layout/generic/test/file_bug514732_window.xul
+++ b/layout/generic/test/file_bug514732_window.xul
@@ -3,20 +3,16 @@
 
 <window id="514732Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         onload="setTimeout(nextTest,0);"
         title="bug 514732 test">
 
-  <script type="application/javascript"><![CDATA[
-    window.opener = window.arguments[0];
-  ]]></script>
-
   <script src="chrome://mochikit/content/tests/SimpleTest/docshell_helpers.js">
   </script>
 
   <script type="application/javascript"><![CDATA[
   
     // Define the generator-iterator for the tests.
     var tests = testIterator();
 
--- a/layout/generic/test/test_bug514732-2.xul
+++ b/layout/generic/test/test_bug514732-2.xul
@@ -26,15 +26,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 514732 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("file_bug514732_window.xul", "bug514732",
-                  "chrome,width=600,height=600,scrollbars,noopener", window);
+window.open("file_bug514732_window.xul", "bug514732",
+            "chrome,width=600,height=600,scrollbars");
 
 ]]>
 </script>
 
 </window>
--- a/layout/xul/test/test_resizer.xul
+++ b/layout/xul/test/test_resizer.xul
@@ -63,29 +63,29 @@ XUL <resizer> tests
     function doResizerWindowTests() {
       step++;
       if (step == 1) {
         openPopup();
         return;
       }
 
       if (/Mac/.test(navigator.platform)) {
-        window.openDialog("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome,noopener", window);
+        window.open("window_resizer.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
       }
       else {
         // Skip window_resizer.xul tests.
         todo(false, "We can't test GTK and Windows native drag resizing implementations.");
         // Run window_resizer_element.xul test only.
         lastResizerTest();
       }
     }
 
     function lastResizerTest()
     {
-      window.openDialog("window_resizer_element.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome,noopener", window);
+      window.open("window_resizer_element.xul", "_blank", "left=200,top=200,outerWidth=300,outerHeight=300,chrome");
     }
 
     SimpleTest.waitForFocus(openPopup);
    ]]></script>
 
 <panel id="panel" onpopupshown="popupShown(event)" onpopuphidden="doResizerWindowTests()">
   <resizer id="resizer" dir="bottomend" width="16" height="16"/>
   <hbox width="50" height="50" flex="1"/>
--- a/layout/xul/test/test_windowminmaxsize.xul
+++ b/layout/xul/test/test_windowminmaxsize.xul
@@ -81,17 +81,17 @@ function nextTest()
   // the attributes or style defined for that test. The comparisons will be
   // done by windowOpened. gTestId holds the index into the tests array.
   if (++gTestId >= tests.length) {
     // Now do the popup tests
     gTestId = -1;
     SimpleTest.waitForFocus(function () { nextPopupTest(document.getElementById("panel")) } );
   }
   else {
-    tests[gTestId].window = docShell.rootTreeItem.domWindow.open(tests[gTestId].src, "_blank", "chrome,resizable=yes");
+    tests[gTestId].window = window.open(tests[gTestId].src, "_blank", "chrome,resizable=yes");
     SimpleTest.waitForFocus(windowOpened, tests[gTestId].window);
   }
 }
 
 function windowOpened(otherWindow)
 {
   // Check the width and the width plus one due to bug 696746.
   ok(otherWindow.innerWidth == tests[gTestId].width ||
@@ -164,17 +164,17 @@ function doPanelTest(panel)
   panel.hidePopup();
 }
 
 function nextPopupTest(panel)
 {
   if (++gTestId >= popupTests.length) {
     // Next, check a panel that has a titlebar to ensure that it is accounted for
     // properly in the size.
-    var titledPanelWindow = docShell.rootTreeItem.domWindow.open("titledpanelwindow.xul", "_blank", "chrome,resizable=yes");
+    var titledPanelWindow = window.open("titledpanelwindow.xul", "_blank", "chrome,resizable=yes");
     SimpleTest.waitForFocus(titledPanelWindowOpened, titledPanelWindow);
   }
   else {
     function setattr(attr) {
       if (attr in popupTests[gTestId])
         panel.setAttribute(attr, popupTests[gTestId][attr]);
       else
         panel.removeAttribute(attr);
--- a/layout/xul/test/window_resizer.xul
+++ b/layout/xul/test/window_resizer.xul
@@ -1,15 +1,15 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     screenX="200" screenY="200" width="300" height="300"
 	onload="setTimeout(doTest, 0)">
 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 <script><![CDATA[
-var is = window.arguments[0].SimpleTest.is;
+var is = window.opener.SimpleTest.is;
 
 function doTest() {
   // from test_resizer.xul
   var expectX = 200;
   var expectY = 200;
   var expectXMost = 500;
   var expectYMost = 500;
   var screenScale = expectX/window.screenX;
--- a/layout/xul/test/window_resizer_element.xul
+++ b/layout/xul/test/window_resizer_element.xul
@@ -1,15 +1,15 @@
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         align="start">
 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 <script><![CDATA[
-var is = window.arguments[0].SimpleTest.is;
-window.onerror = window.arguments[0].onerror;
+var is = window.opener.SimpleTest.is;
+window.onerror = window.opener.onerror;
 
 const anchorPositions =
   [ "before_start", "before_end", "after_start", "after_end",
     "start_before", "start_after", "end_before", "end_after", "overlap", "screen"];
 var currentPosition;
 
 function testResizer(resizerid, noShrink, hResize, vResize, testid)
 {
@@ -98,17 +98,17 @@ function popupShown(event)
 
   event.target.hidePopup();
 }
 
 function popupHidden()
 {
   if (anchorPositions.length == 0) {
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    window.opener.SimpleTest.finish();
     return;
   }
 
   currentPosition = anchorPositions.shift();
   var anchor = document.getElementById("anchor");
   var popup = document.getElementById("anchored-panel-container");
 
   if (currentPosition == "screen")
@@ -142,17 +142,17 @@ function anchoredPopupShown(event)
 
     document.getElementById("anchored-panel").dir = resizerType;
     testResizer("anchored-panel", false, horiz, vert, currentPosition + " " + resizerType);
   }
 
   event.target.hidePopup();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(doTest, window);
+window.opener.SimpleTest.waitForFocus(doTest, window);
 ]]></script>
 
 <resizer id="outside" dir="bottomend" element="outside-container"/>
 <resizer id="notfound" dir="bottomend" element="nothing"/>
 <hbox id="outside-container">
   <hbox minwidth="46" minheight="39"/>
 </hbox>
 <html:div id="html-container" xmlns:html="http://www.w3.org/1999/xhtml">
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -17,34 +17,34 @@
 **/
 
 var SimpleTest = { };
 var parentRunner = null;
 
 // In normal test runs, the window that has a TestRunner in its parent is
 // the primary window.  In single test runs, if there is no parent and there
 // is no opener then it is the primary window.
-var isSingleTestRun = (parent == window && !(opener || window.arguments && window.arguments[0].SimpleTest));
+var isSingleTestRun = (parent == window && !opener)
 try {
   var isPrimaryTestWindow = !!parent.TestRunner || isSingleTestRun;
 } catch(e) {
   dump("TEST-UNEXPECTED-FAIL, Exception caught: " + e.message +
                 ", at: " + e.fileName + " (" + e.lineNumber +
                 "), location: " + window.location.href + "\n");
 }
 // Finds the TestRunner for this test run and the SpecialPowers object (in
 // case it is not defined) from a parent/opener window.
 //
 // Finding the SpecialPowers object is needed when we have ChromePowers in
 // harness.xul and we need SpecialPowers in the iframe, and also for tests
 // like test_focus.xul where we open a window which opens another window which
 // includes SimpleTest.js.
 (function() {
     function ancestor(w) {
-        return w.parent != w ? w.parent : w.opener || w.arguments && w.arguments[0];
+        return w.parent != w ? w.parent : w.opener;
     }
 
     var w = ancestor(window);
     while (w && (!parentRunner || !window.SpecialPowers)) {
         if (!parentRunner) {
             parentRunner = w.TestRunner;
             if (!parentRunner && w.wrappedJSObject) {
                 parentRunner = w.wrappedJSObject.TestRunner;
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul
@@ -37,17 +37,17 @@
 
   let prefs = [
     ["dom.ipc.processCount", 3],            // Allow up to 3 child processes
     ["memory.report_concurrency", 2]        // Cover more child handling cases
   ];
 
   SpecialPowers.pushPrefEnv({"set": prefs}, function() {
     for (let i = 0; i < numRemotes; i++) {
-      let w = remotes[i] = docShell.rootTreeItem.domWindow.open("remote.xul", "", "chrome");
+      let w = remotes[i] = window.open("remote.xul", "", "chrome");
 
       w.addEventListener("load", function loadHandler() {
         w.removeEventListener("load", loadHandler);
         let remoteBrowser = w.document.getElementById("remote");
         let mm = remoteBrowser.messageManager;
         mm.addMessageListener("test:ready", function readyHandler() {
           mm.removeMessageListener("test:ready", readyHandler);
           numReady++;
--- a/toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xul
+++ b/toolkit/components/aboutmemory/tests/test_dumpGCAndCCLogsToFile.xul
@@ -19,17 +19,17 @@
   let numReady = 0;
 
   // Create some remote processes, and set up message-passing so that
   // we know when each child is fully initialized.
   let remotes = [];
   SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", numRemotes]]},
 			    function() {
     for (let i = 0; i < numRemotes; i++) {
-      let w = remotes[i] = docShell.rootTreeItem.domWindow.open("remote.xul", "", "chrome");
+      let w = remotes[i] = window.open("remote.xul", "", "chrome");
 
       w.addEventListener("load", function loadHandler() {
         w.removeEventListener("load", loadHandler);
         let remoteBrowser = w.document.getElementById("remote");
         let mm = remoteBrowser.messageManager;
         mm.addMessageListener("test:ready", function readyHandler() {
           mm.removeMessageListener("test:ready", readyHandler);
           numReady++;
--- a/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul
+++ b/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul
@@ -26,17 +26,17 @@
   const expectedNumRemotes = numToOpen + socketProcessRunning;
   let numReady = 0;
 
   // Create some remote processes, and set up message-passing so that
   // we know when each child is fully initialized.
   let remotes = [];
   SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 3]]}, function() {
     for (let i = 0; i < numToOpen; i++) {
-      let w = remotes[i] = docShell.rootTreeItem.domWindow.open("remote.xul", "", "chrome");
+      let w = remotes[i] = window.open("remote.xul", "", "chrome");
 
       w.addEventListener("load", function loadHandler() {
         w.removeEventListener("load", loadHandler);
         let remoteBrowser = w.document.getElementById("remote");
         let mm = remoteBrowser.messageManager;
         mm.addMessageListener("test:ready", function readyHandler() {
           mm.removeMessageListener("test:ready", readyHandler);
           numReady++;
--- a/toolkit/components/antitracking/test/browser/antitracking_head.js
+++ b/toolkit/components/antitracking/test/browser/antitracking_head.js
@@ -312,21 +312,17 @@ this.AntiTracking = {
         if (aTopic == "domwindowclosed") {
           Services.ww.unregisterNotification(notification);
           resolve();
         }
       });
     });
 
     info("Let's interact with the tracker");
-    window.open(
-      TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdPartyOpenUI.html",
-      "",
-      "noopener"
-    );
+    window.open(TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdPartyOpenUI.html");
     await windowClosed;
   },
 
   async _setupTest(win, cookieBehavior, extraPrefs) {
     await SpecialPowers.flushPrefEnv();
     await SpecialPowers.pushPrefEnv({
       set: [
         ["dom.storage_access.enabled", true],
--- a/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul
+++ b/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul
@@ -10,30 +10,30 @@
   <browser id="inprocess_enabled" src="about:blank" type="content" />
 
   <browser id="remote_disabled" src="about:blank" type="content" disableglobalhistory="true" />
   <browser id="remote_enabled" src="about:blank" type="content" />
 
   <script type="text/javascript">
 
   Cu.import("resource://testing-common/ContentTask.jsm");
-  ContentTask.setTestScope(window.arguments[0].wrappedJSObject);
+  ContentTask.setTestScope(window.opener.wrappedJSObject);
 
   function expectUseGlobalHistory(id, expected) {
     let browser = document.getElementById(id);
     return ContentTask.spawn(browser, {id, expected}, function({id, expected}) {
       Assert.equal(docShell.useGlobalHistory, expected,
                    "Got the right useGlobalHistory state in the docShell of " + id);
     });
   }
 
   async function run_test() {
     await expectUseGlobalHistory("inprocess_disabled", false);
     await expectUseGlobalHistory("inprocess_enabled", true);
 
     await expectUseGlobalHistory("remote_disabled", false);
     await expectUseGlobalHistory("remote_enabled", true);
-    window.arguments[0].done();
+    window.opener.done();
     ok(true);
   }
 
   </script>
 </window>
--- a/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul
+++ b/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul
@@ -9,17 +9,17 @@
 
   <!-- test results are displayed in the html:body -->
   <body xmlns="http://www.w3.org/1999/xhtml">
   </body>
 
   <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
 
-  let w = docShell.rootTreeItem.domWindow.openDialog('browser_disableglobalhistory.xul', '_blank', 'chrome,resizable=yes,width=400,height=600', window);
+  let w = window.open('browser_disableglobalhistory.xul', '_blank', 'chrome,resizable=yes,width=400,height=600');
 
   function done() {
     w.close();
     SimpleTest.finish();
   }
   </script>
 
 </window>
--- a/toolkit/components/prompts/src/Prompter.jsm
+++ b/toolkit/components/prompts/src/Prompter.jsm
@@ -445,17 +445,17 @@ function openModalWindow(domWin, uri, ar
     domWin = Services.ww.activeWindow;
     // domWin may still be null here if there are _no_ windows open.
   }
   // Note that we don't need to fire DOMWillOpenModalDialog and
   // DOMModalDialogClosed events here, wwatcher's OpenWindowInternal
   // will do that. Similarly for enterModalState / leaveModalState.
 
   Services.ww.openWindow(
-    domWin.docShell.rootTreeItem.domWindow,
+    domWin,
     uri,
     "_blank",
     "centerscreen,chrome,modal,titlebar",
     args
   );
 }
 
 function openTabPrompt(domWin, tabPrompt, args) {
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -723,34 +723,18 @@ nsresult nsWindowWatcher::OpenWindowInte
   SizeSpec sizeSpec;
   CalcSizeSpec(features, sizeSpec);
 
   // XXXbz Why is an AutoJSAPI good enough here?  Wouldn't AutoEntryScript (so
   // we affect the entry global) make more sense?  Or do we just want to affect
   // GetSubjectPrincipal()?
   dom::AutoJSAPI jsapiChromeGuard;
 
-  nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(aParent);
-
   bool windowTypeIsChrome =
       chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
-
-  if (!aForceNoOpener) {
-    if (chromeWin && !windowTypeIsChrome) {
-      NS_WARNING(
-          "Content windows may never have chrome windows as their openers.");
-      return NS_ERROR_INVALID_ARG;
-    }
-    if (aParent && !chromeWin && windowTypeIsChrome) {
-      NS_WARNING(
-          "Chrome windows may never have content windows as their openers.");
-      return NS_ERROR_INVALID_ARG;
-    }
-  }
-
   if (isCallerChrome && !hasChromeParent && !windowTypeIsChrome) {
     // open() is called from chrome on a non-chrome window, initialize an
     // AutoJSAPI with the callee to prevent the caller's privileges from leaking
     // into code that runs while opening the new window.
     //
     // The reasoning for this is in bug 289204. Basically, chrome sometimes does
     // someContentWindow.open(untrustedURL), and wants to be insulated from
     // nasty javascript: URLs and such. But there are also cases where we create
@@ -787,16 +771,17 @@ nsresult nsWindowWatcher::OpenWindowInte
           return NS_ERROR_DOM_INVALID_ACCESS_ERR;
         }
       }
     }
 
     // Now check whether it's ok to ask a window provider for a window.  Don't
     // do it if we're opening a dialog or if our parent is a chrome window or
     // if we're opening something that has modal, dialog, or chrome flags set.
+    nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(aParent);
     if (!aDialog && !chromeWin &&
         !(chromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
                          nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
                          nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
       nsCOMPtr<nsIWindowProvider> provider;
       if (parentTreeOwner) {
         provider = do_GetInterface(parentTreeOwner);
       } else if (XRE_IsContentProcess()) {
--- a/toolkit/components/windowwatcher/test/file_test_dialog.html
+++ b/toolkit/components/windowwatcher/test/file_test_dialog.html
@@ -4,11 +4,11 @@
 This page is opened in a new window by test_dialog_arguments. It is
 a dialog which expects a Symbol to be passed in the dialog arguments.
 Once we load, we call back into the opener with the argument we were
 passed.
 -->
 <head>
 <body>Opened!</body>
 <script>
-  window.arguments[1].done(window.arguments[0]);
+  window.opener.done(window.arguments[0]);
 </script>
 </html>
--- a/toolkit/components/windowwatcher/test/test_dialog_arguments.html
+++ b/toolkit/components/windowwatcher/test/test_dialog_arguments.html
@@ -7,27 +7,29 @@ Test that arguments can be passed to dia
   <meta charset="utf-8">
   <title>Test a modal window</title>
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
 
   <script type="application/javascript">
 
+  ChromeUtils.import("resource://gre/modules/Services.jsm");
+
   const TEST_ITEM = Symbol("test-item");
 
   function done(returnedItem) {
     is(returnedItem, TEST_ITEM,
        "Dialog should have received test item");
     win.close();
     SimpleTest.finish();
   }
 
   SimpleTest.waitForExplicitFinish();
-  let win = window.docShell.rootTreeItem.domWindow.openDialog("file_test_dialog.html", "_blank", "width=100,height=100", TEST_ITEM, window);
+  let win = window.openDialog("file_test_dialog.html", "_blank", "width=100,height=100", TEST_ITEM);
   </script>
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 </pre>
--- a/toolkit/components/windowwatcher/test/test_modal_windows.html
+++ b/toolkit/components/windowwatcher/test/test_modal_windows.html
@@ -28,17 +28,17 @@ that is opened reports itself as being m
       let wbc = treeOwner.QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIWebBrowserChrome);
       ok(wbc.isWindowModal(), "Should report as modal");
 
       win.close();
     });
 
     window.openDialog("data:text/html,<p>This is a modal window for test_modal_windows.html</p>",
-                      "_blank", "modal,noopener", null);
+                      "_blank", "modal", null);
     // Since the modal runs a nested event loop, just to be on the safe side,
     // we'll wait a tick of the main event loop before resolving the task.
     await new Promise(resolve => setTimeout(resolve, 0));
   });
 
   </script>
 </head>
 <body>
--- a/toolkit/components/xulstore/tests/chrome/test_persistence.xul
+++ b/toolkit/components/xulstore/tests/chrome/test_persistence.xul
@@ -6,21 +6,21 @@
         onload="runTest()"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
   <script>
     SimpleTest.waitForExplicitFinish();
     function runTest() {
-      window.openDialog("window_persistence.xul", "_blank", "chrome,noopener", true, window);
+      window.openDialog("window_persistence.xul", "_blank", "chrome", true);
     }
 
     function windowOpened() {
-      window.openDialog("window_persistence.xul", "_blank", "chrome,noopener", false, window);
+      window.openDialog("window_persistence.xul", "_blank", "chrome", false);
     }
 
     function testDone() {
       SimpleTest.finish();
     }
   </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/components/xulstore/tests/chrome/window_persistence.xul
+++ b/toolkit/components/xulstore/tests/chrome/window_persistence.xul
@@ -34,32 +34,32 @@ function runTest()
     button2.setAttribute("foo", "bar");
     XULStore.persist(button2, "foo");
     is(XULStore.getValue(URI, "button2", "foo"), "bar", "attribute persisted");
     button2.removeAttribute("foo");
     XULStore.persist(button2, "foo");
     is(XULStore.hasValue(URI, "button2", "foo"), false, "attribute removed");
 
     window.close();
-    window.arguments[1].windowOpened();
+    window.opener.windowOpened();
   }
   else {
     is(button1.getAttribute("value"), "Pressed",
        "Attribute set");
     is(button2.hasAttribute("value"), true,
        "Attribute cleared");
     is(button2.getAttribute("value"), "",
        "Attribute cleared");
     is(button2.hasAttribute("foo"), false,
        "Attribute cleared");
     is(button2.getAttribute("foo"), "",
        "Attribute cleared");
 
     window.close();
-    window.arguments[1].testDone();
+    window.opener.testDone();
   }
 }
 
-function is(l, r, n) { window.arguments[1].SimpleTest.is(l,r,n); }
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
 
 ]]></script>
 
 </window>
--- a/toolkit/content/tests/chrome/bug263683_window.xul
+++ b/toolkit/content/tests/chrome/bug263683_window.xul
@@ -15,25 +15,25 @@
         height="600"
         onload="SimpleTest.executeSoon(startTest);"
         title="263683 test">
 
   <script type="application/javascript"><![CDATA[
     const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "info", "is"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function startTest() {
       (async function() {
         gFindBar = document.getElementById("FindToolbar");
         // Testing on a remote browser has been disabled due to frequent
         // intermittent failures.
         for (let browserId of ["content"/*, "content-remote"*/]) {
--- a/toolkit/content/tests/chrome/bug304188_window.xul
+++ b/toolkit/content/tests/chrome/bug304188_window.xul
@@ -14,24 +14,24 @@
         height="600"
         onload="onLoad();"
         title="FindbarTest for bug 304188 - 
 find-menu appears in editor element which has had makeEditable() called but designMode not set">
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "info"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function onLoad() {
       (async function() {
         gFindBar = document.getElementById("FindToolbar");
         for (let browserId of ["content", "content-remote"]) {
           await startTestWithBrowser(browserId);
         }
--- a/toolkit/content/tests/chrome/bug331215_window.xul
+++ b/toolkit/content/tests/chrome/bug331215_window.xul
@@ -14,24 +14,24 @@
         width="600"
         height="600"
         onload="SimpleTest.executeSoon(startTest);"
         title="331215 test">
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "info"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
     SimpleTest.requestLongerTimeout(2);
 
     function startTest() {
       (async function() {
         gFindBar = document.getElementById("FindToolbar");
         for (let browserId of ["content", "content-remote"]) {
           await startTestWithBrowser(browserId);
--- a/toolkit/content/tests/chrome/bug360437_window.xul
+++ b/toolkit/content/tests/chrome/bug360437_window.xul
@@ -14,24 +14,24 @@
         width="600"
         height="600"
         onload="startTest();"
         title="360437 test">
 
   <script type="application/javascript"><![CDATA[
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "is", "info"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function startTest() {
       (async function() {
         gFindBar = document.getElementById("FindToolbar");
         for (let browserId of ["content", "content-remote"]) {
           await startTestWithBrowser(browserId);
         }
--- a/toolkit/content/tests/chrome/bug366992_window.xul
+++ b/toolkit/content/tests/chrome/bug366992_window.xul
@@ -44,22 +44,22 @@
       },
       isCommandEnabled: function(aCommand) {
         return aCommand == "cmd_delete";
       },
       doCommand: function(aCommand) { }
     }
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
     function finish() {
       window.controllers.removeController(gShouldNotBeReachedController);
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad() {
       document.getElementById("textbox").focus();
       var deleteDisabled = document.getElementById("cmd_delete")
                                    .getAttribute("disabled") == "true";
       ok(deleteDisabled,
          "cmd_delete should be disabled when the empty textbox is focused");
--- a/toolkit/content/tests/chrome/bug409624_window.xul
+++ b/toolkit/content/tests/chrome/bug409624_window.xul
@@ -16,17 +16,17 @@
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "is"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     function finish() {
       window.close();
       SimpleTest.finish();
     }
 
     function startTest() {
--- a/toolkit/content/tests/chrome/bug429723_window.xul
+++ b/toolkit/content/tests/chrome/bug429723_window.xul
@@ -14,22 +14,22 @@
         title="429723 test">
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     var gFindBar = null;
     var gBrowser;
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function finish() {
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     function onLoad() {
       var _delayedOnLoad = function() {
         gFindBar = document.getElementById("FindToolbar");
         gBrowser = document.getElementById("content");
         gBrowser.addEventListener("pageshow", onPageShow, false);
         BrowserTestUtils.loadURI(gBrowser, "data:text/html,<h2 id='h2'>mozilla</h2>");
--- a/toolkit/content/tests/chrome/bug451540_window.xul
+++ b/toolkit/content/tests/chrome/bug451540_window.xul
@@ -11,33 +11,33 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         title="451540 test">
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
     const SEARCH_TEXT = "minefield";
 
     let gFindBar = null;
     let gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
     let gBrowser;
 
     let sendCtrl = true;
     let sendMeta = false;
     if (navigator.platform.includes("Mac")) {
       sendCtrl = false;
       sendMeta = true;
     }
 
     let imports = [ "SimpleTest", "ok", "is", "info"];
     for (let name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
 
     SimpleTest.requestLongerTimeout(2);
 
     function startTest() {
       gFindBar = document.getElementById("FindToolbar");
       gBrowser = document.getElementById("content");
       gBrowser.addEventListener("pageshow", onPageShow, false);
--- a/toolkit/content/tests/chrome/bug624329_window.xul
+++ b/toolkit/content/tests/chrome/bug624329_window.xul
@@ -1,17 +1,17 @@
 <?xml version="1.0"?>
 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
 
 <window title="Test for bug 624329 context menu position"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         context="menu">
 
   <script>
-    window.arguments[0].SimpleTest.waitForFocus(window.arguments[0].childFocused, window);
+    opener.SimpleTest.waitForFocus(opener.childFocused, window);
   </script>
 
   <menupopup id="menu">
     <!-- The bug demonstrated only when the accesskey was presented separately
          from the label.
          e.g. because the accesskey is not a letter in the label.
 
          The bug demonstrates only on the first show of the context menu
--- a/toolkit/content/tests/chrome/findbar_entireword_window.xul
+++ b/toolkit/content/tests/chrome/findbar_entireword_window.xul
@@ -15,24 +15,24 @@
         title="findbar test - entire words only">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
   <script src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"/>
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "SpecialPowers", "ok", "is", "isnot", "info"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
     SimpleTest.requestLongerTimeout(2);
 
     const kBaseURL = "chrome://mochitests/content/chrome/toolkit/content/tests/chrome";
     const kTests = {
       latin1: {
         testSimpleEntireWord: {
           "and": results => {
--- a/toolkit/content/tests/chrome/findbar_events_window.xul
+++ b/toolkit/content/tests/chrome/findbar_events_window.xul
@@ -14,25 +14,25 @@
         width="600"
         height="600"
         onload="SimpleTest.executeSoon(startTest);"
         title="findbar events test">
 
   <script type="application/javascript"><![CDATA[
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
     const kTimeout = 5000; // 5 seconds.
 
     var imports = ["SimpleTest", "ok", "is", "info"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
     SimpleTest.requestLongerTimeout(2);
 
     function startTest() {
       (async function() {
         gFindBar = document.getElementById("FindToolbar");
         for (let browserId of ["content", "content-remote"]) {
           await startTestWithBrowser(browserId);
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -17,17 +17,17 @@
         title="findbar test">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript"><![CDATA[
     const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
     const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ContentTask.setTestScope(window.arguments[0]);
+    ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
 
     const SAMPLE_URL = "http://www.mozilla.org/";
     const SAMPLE_TEXT = "Some text in a text field.";
     const SEARCH_TEXT = "Text Test";
     const NOT_FOUND_TEXT = "This text is not on the page."
     const ITERATOR_TIMEOUT = gPrefsvc.getIntPref("findbar.iteratorTimeout");
@@ -52,17 +52,17 @@
         gStatusText = aStatusText;
       },
 
       onBeforeLinkTraversal: function() { }
     };
 
     var imports = ["SimpleTest", "ok", "is", "info"];
     for (var name of imports) {
-      window[name] = window.arguments[0][name];
+      window[name] = window.opener.wrappedJSObject[name];
     }
     SimpleTest.requestLongerTimeout(2);
 
     function onLoad() {
       (async function() {
         window.docShell
               .treeOwner
               .QueryInterface(Ci.nsIInterfaceRequestor)
--- a/toolkit/content/tests/chrome/frame_popup_anchor.xul
+++ b/toolkit/content/tests/chrome/frame_popup_anchor.xul
@@ -21,18 +21,18 @@ var isSecondTest = false;
 function openPopup()
 {
   document.getElementById("popup").openPopup(parent.document.getElementById("outerbutton"), "after_start", 3, 1);
 }
 
 function popupShowing(event)
 {
   var buttonrect = document.getElementById("button").getBoundingClientRect();
-  parent.arguments[0].SimpleTest.is(event.clientX, buttonrect.left + 6, "popup clientX with mouse");
-  parent.arguments[0].SimpleTest.is(event.clientY, buttonrect.top + 6, "popup clientY with mouse");
+  parent.opener.wrappedJSObject.SimpleTest.is(event.clientX, buttonrect.left + 6, "popup clientX with mouse");
+  parent.opener.wrappedJSObject.SimpleTest.is(event.clientY, buttonrect.top + 6, "popup clientY with mouse");
 }
 
 function popupShown()
 {
   var left, top;
   var popuprect = document.getElementById("popup").getBoundingClientRect();
   if (isSecondTest) {
     var buttonrect = document.getElementById("button").getBoundingClientRect();
@@ -50,26 +50,26 @@ function popupShown()
     //         iframe border (17px) + iframe padding (0)
     //  top = iframe's top - anchor button's bottom - 1 pixel offset passed to openPopup +
     //        iframe border (0) + iframe padding (3px);
     left = -(Math.round(iframerect.left) - Math.round(buttonrect.left) + 14);
     top = -(Math.round(iframerect.top) - Math.round(buttonrect.bottom) + 2);
   }
 
   var testid = isSecondTest ? "with mouse" : "anchored to parent frame";
-  parent.arguments[0].SimpleTest.is(Math.round(popuprect.left), left, "popup left " + testid);
-  parent.arguments[0].SimpleTest.is(Math.round(popuprect.top), top, "popup top " + testid);
+  parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.left), left, "popup left " + testid);
+  parent.opener.wrappedJSObject.SimpleTest.is(Math.round(popuprect.top), top, "popup top " + testid);
 
   document.getElementById("popup").hidePopup();
 }
 
 function nextTest()
 {
   if (isSecondTest) {
-    parent.arguments[0].SimpleTest.finish();
+    parent.opener.wrappedJSObject.SimpleTest.finish();
     parent.close();
   }
   else {
     // this second test ensures that the popupshowing coordinates when a popup in
     // a frame is opened are correct 
     isSecondTest = true;
     synthesizeMouse(document.getElementById("button"), 6, 6, { });
   }
--- a/toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xul
+++ b/toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xul
@@ -25,18 +25,18 @@ function runTests()
   synthesizeMouse(document.getElementById("frame1"), 3, 4, { type: "mousemove" });
 }
 
 function mouseMove(e) {
   e.stopPropagation();
   var element = e.target;
   var el = document.getElementById("cap1");
   el.label = "client: (" + e.clientX + "," + e.clientY + ")";
-  parent.arguments[0].SimpleTest.is(e.clientX, 3, "mouse event clientX on sub frame 1");
-  parent.arguments[0].SimpleTest.is(e.clientY, 4, "mouse event clientY on sub frame 1");
+  parent.opener.wrappedJSObject.SimpleTest.is(e.clientX, 3, "mouse event clientX on sub frame 1");
+  parent.opener.wrappedJSObject.SimpleTest.is(e.clientY, 4, "mouse event clientY on sub frame 1");
   // fire the next test on the sub frame
   frames[0].runTests();
 }
 
 window.addEventListener("mousemove", mouseMove, false);
 
 </script>
 </page>
--- a/toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xul
+++ b/toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xul
@@ -21,18 +21,18 @@ function runTests()
   synthesizeMouse(document.getElementById("frame2"), 6, 5, { type: "mousemove" });
 }
 
 function mouseMove(e) {
   e.stopPropagation();
   var element = e.target;
   var el = document.getElementById("cap2");
   el.label = "client: (" + e.clientX + "," + e.clientY + ")";
-  parent.parent.arguments[0].SimpleTest.is(e.clientX, 6, "mouse event clientX on sub frame 2");
-  parent.parent.arguments[0].SimpleTest.is(e.clientY, 5, "mouse event clientY on sub frame 2");
-  parent.parent.arguments[0].SimpleTest.finish();
+  parent.parent.opener.wrappedJSObject.SimpleTest.is(e.clientX, 6, "mouse event clientX on sub frame 2");
+  parent.parent.opener.wrappedJSObject.SimpleTest.is(e.clientY, 5, "mouse event clientY on sub frame 2");
+  parent.parent.opener.wrappedJSObject.SimpleTest.finish();
   parent.parent.close();
 }
 
 window.addEventListener("mousemove",mouseMove, false);
 
 </script>
 </page>
--- a/toolkit/content/tests/chrome/test_browser_drop.xul
+++ b/toolkit/content/tests/chrome/test_browser_drop.xul
@@ -7,17 +7,17 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
         <script><![CDATA[
 SimpleTest.waitForExplicitFinish();
 function runTest() {
   add_task(async function() {
-    let win = docShell.rootTreeItem.domWindow.openDialog("window_browser_drop.xul", "_blank", "chrome,width=200,height=200", window);
+    let win = window.open("window_browser_drop.xul", "_blank", "chrome,width=200,height=200");
     await SimpleTest.promiseFocus(win);
     for (let browserType of ["content", "remote-content"]) {
       await win.dropLinksOnBrowser(win.document.getElementById(browserType + "child"), browserType);
     }
     await win.dropLinksOnBrowser(win.document.getElementById("chromechild"), "chrome");
   });
 }
 //]]>
--- a/toolkit/content/tests/chrome/test_bug263683.xul
+++ b/toolkit/content/tests/chrome/test_bug263683.xul
@@ -25,15 +25,15 @@ https://bugzilla.mozilla.org/show_bug.cg
     </pre>
   </body>
 
   <script class="testbody" type="application/javascript">
     <![CDATA[
 
       /** Test for Bug 263683 **/
       SimpleTest.waitForExplicitFinish();
-      window.openDialog("bug263683_window.xul", "263683test",
-                        "chrome,width=600,height=600,noopener", window);
+      window.open("bug263683_window.xul", "263683test", 
+                  "chrome,width=600,height=600");
 
     ]]>
   </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug304188.xul
+++ b/toolkit/content/tests/chrome/test_bug304188.xul
@@ -23,15 +23,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 304188 **/
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug304188_window.xul", "findbartest", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug304188_window.xul", "findbartest", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug331215.xul
+++ b/toolkit/content/tests/chrome/test_bug331215.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 331215 **/
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug331215_window.xul", "331215test", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug331215_window.xul", "331215test", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug360437.xul
+++ b/toolkit/content/tests/chrome/test_bug360437.xul
@@ -23,18 +23,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 360437 **/
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug360437_window.xul", "360437test", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug360437_window.xul", "360437test", 
+            "chrome,width=600,height=600");
 
 
 
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug366992.xul
+++ b/toolkit/content/tests/chrome/test_bug366992.xul
@@ -23,18 +23,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 366992 **/
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug366992_window.xul", "findbartest", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug366992_window.xul", "findbartest", 
+            "chrome,width=600,height=600");
 
 
 
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug409624.xul
+++ b/toolkit/content/tests/chrome/test_bug409624.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
     </pre>
   </body>
 
   <script class="testbody" type="application/javascript">
     <![CDATA[
 
       /** Test for Bug 409624 **/
       SimpleTest.waitForExplicitFinish();
-      window.openDialog("bug409624_window.xul", "409624test",
-                        "chrome,width=600,height=600,noopener", window);
+      window.open("bug409624_window.xul", "409624test",
+                  "chrome,width=600,height=600");
 
     ]]>
   </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug429723.xul
+++ b/toolkit/content/tests/chrome/test_bug429723.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 /** Test for Bug 429723 **/
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug429723_window.xul", "429723test", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug429723_window.xul", "429723test", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug451540.xul
+++ b/toolkit/content/tests/chrome/test_bug451540.xul
@@ -25,15 +25,15 @@ https://bugzilla.mozilla.org/show_bug.cg
     </pre>
   </body>
 
   <script class="testbody" type="application/javascript">
     <![CDATA[
 
       /** Test for Bug 451540 **/
       SimpleTest.waitForExplicitFinish();
-      window.openDialog("bug451540_window.xul", "451540test",
-                        "chrome,width=600,height=600,noopener", window);
+      window.open("bug451540_window.xul", "451540test",
+                  "chrome,width=600,height=600");
 
     ]]>
   </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_bug624329.xul
+++ b/toolkit/content/tests/chrome/test_bug624329.xul
@@ -23,17 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 SimpleTest.waitForExplicitFinish();
 
 var win;
 var timeoutID;
 var menu;
 
 function openTestWindow() {
-    win = docShell.rootTreeItem.domWindow.openDialog("bug624329_window.xul", "_blank", "width=300,resizable=yes,chrome", window);
+    win = open("bug624329_window.xul", "_blank", "width=300,resizable=yes,chrome");
     // Close our window if the test times out so that it doesn't interfere
     // with later tests.
     timeoutID = setTimeout(function () {
         ok(false, "Test timed out.");
         // Provide some time for a screenshot
         setTimeout(finish, 1000);
     }, 20000);
 }
--- a/toolkit/content/tests/chrome/test_chromemargin.xul
+++ b/toolkit/content/tests/chrome/test_chromemargin.xul
@@ -14,17 +14,17 @@
 
 <script>
 
 // Tests parsing of the chrome margin attrib on a window.
 
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_chromemargin.xul", "_blank", "chrome,width=600,height=600,noopener", window);
+  window.open("window_chromemargin.xul", "_blank", "chrome,width=600,height=600");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_cursorsnap.xul
+++ b/toolkit/content/tests/chrome/test_cursorsnap.xul
@@ -60,48 +60,48 @@ function retryCurrentTest()
 function runCurrentTest()
 {
   var position = "top=" + gTestingCount + ",left=" + gTestingCount + ",";
   gTestingCount++;
   switch (gTestingIndex) {
     case 0:
       gDisable = false;
       gHidden = false;
-      window.openDialog("window_cursorsnap_dialog.xul", "_blank",
-                        position + "chrome,width=100,height=100,noopener", window);
+      window.open("window_cursorsnap_dialog.xul", "_blank",
+                  position + "chrome,width=100,height=100");
       break;
     case 1:
       gDisable = true;
       gHidden = false;
-      window.openDialog("window_cursorsnap_dialog.xul", "_blank",
-                        position + "chrome,width=100,height=100,noopener", window);
+      window.open("window_cursorsnap_dialog.xul", "_blank",
+                  position + "chrome,width=100,height=100");
       break;
     case 2:
       gDisable = false;
       gHidden = true;
-      window.openDialog("window_cursorsnap_dialog.xul", "_blank",
-                        position + "chrome,width=100,height=100,noopener", window);
+      window.open("window_cursorsnap_dialog.xul", "_blank",
+                  position + "chrome,width=100,height=100");
       break;
     case 3:
       gDisable = false;
       gHidden = false;
-      window.openDialog("window_cursorsnap_wizard.xul", "_blank",
-                        position + "chrome,width=100,height=100,noopener", window);
+      window.open("window_cursorsnap_wizard.xul", "_blank",
+                  position + "chrome,width=100,height=100");
       break;
     case 4:
       gDisable = true;
       gHidden = false;
-      window.openDialog("window_cursorsnap_wizard.xul", "_blank",
-                        position + "chrome,width=100,height=100,noopener", window);
+      window.open("window_cursorsnap_wizard.xul", "_blank",
+                  position + "chrome,width=100,height=100");
       break;
     case 5:
       gDisable = false;
       gHidden = true;
-      window.openDialog("window_cursorsnap_wizard.xul", "_blank",
-                        position + "chrome,width=100,height=100,noopener", window);
+      window.open("window_cursorsnap_wizard.xul", "_blank",
+                  position + "chrome,width=100,height=100");
       break;
     default:
       SetPrefs(false);
       SimpleTest.finish();
       return;
   }
 }
 
--- a/toolkit/content/tests/chrome/test_dialogfocus.xul
+++ b/toolkit/content/tests/chrome/test_dialogfocus.xul
@@ -53,17 +53,17 @@ function runTest()
   if (step > expected.length || (!fullKeyboardAccess && step == 2)) {
     info("finishing");
     SimpleTest.finish();
     return;
   }
 
   var expectedFocus = expected[step - 1];
   let filename = expectedFocus == "root" ? "dialog_dialogfocus2.xul" : "dialog_dialogfocus.xul";
-  var win = docShell.rootTreeItem.domWindow.openDialog(filename, "_new", "chrome,dialog", step);
+  var win = window.openDialog(filename, "_new", "chrome,dialog", step);
 
   function checkDialogFocus(event)
   {
     info(`checkDialogFocus()`);
     let match = false;
     let activeElement = win.document.activeElement;
 
     if (activeElement == win.document.documentElement) {
--- a/toolkit/content/tests/chrome/test_edit_contextmenu.html
+++ b/toolkit/content/tests/chrome/test_edit_contextmenu.html
@@ -10,17 +10,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
     const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
     SimpleTest.waitForExplicitFinish();
 
     async function runTest() {
-      let win = window.docShell.rootTreeItem.domWindow.open("file_edit_contextmenu.xul", "context-menu", "chrome,width=600,height=600");
+      let win = window.open("file_edit_contextmenu.xul", "context-menu", "chrome,width=600,height=600");
       await new Promise(r => win.addEventListener("load", r, { once: true}));
       await SimpleTest.promiseFocus(win);
 
       const elements = [
         win.document.querySelector("textarea"),
         win.document.querySelector("input"),
         win.document.querySelector("textbox[is='search-textbox']"),
       ];
--- a/toolkit/content/tests/chrome/test_findbar.xul
+++ b/toolkit/content/tests/chrome/test_findbar.xul
@@ -33,15 +33,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 SimpleTest.waitForExplicitFinish();
 
 // Since bug 978861, this pref is set to `false` on OSX. For this test, we'll
 // set it `true` to disable the find clipboard on OSX, which interferes with
 // our tests.
 SpecialPowers.pushPrefEnv({
   set: [["accessibility.typeaheadfind.prefillwithselection", true]]
 }, () => {
-  window.openDialog("findbar_window.xul", "findbartest", "chrome,width=600,height=600,noopener", window);
+  window.open("findbar_window.xul", "findbartest", "chrome,width=600,height=600");
 });
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_findbar_entireword.xul
+++ b/toolkit/content/tests/chrome/test_findbar_entireword.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
     </pre>
   </body>
 
   <script class="testbody" type="application/javascript">
     <![CDATA[
 
       /** Test for Bug 269442 **/
       SimpleTest.waitForExplicitFinish();
-      window.openDialog("findbar_entireword_window.xul", "269442test",
-                        "chrome,width=600,height=600,noopener", window);
+      window.open("findbar_entireword_window.xul", "269442test",
+                  "chrome,width=600,height=600");
 
     ]]>
   </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_findbar_events.xul
+++ b/toolkit/content/tests/chrome/test_findbar_events.xul
@@ -24,15 +24,15 @@ https://bugzilla.mozilla.org/show_bug.cg
     </pre>
   </body>
 
   <script class="testbody" type="application/javascript">
     <![CDATA[
 
       /** Test for Bug 793275 **/
       SimpleTest.waitForExplicitFinish();
-      window.openDialog("findbar_events_window.xul", "793275test",
-                        "chrome,width=600,height=600,noopener", window);
+      window.open("findbar_events_window.xul", "793275test",
+                  "chrome,width=600,height=600");
 
     ]]>
   </script>
 
 </window>
--- a/toolkit/content/tests/chrome/test_keys.xul
+++ b/toolkit/content/tests/chrome/test_keys.xul
@@ -7,17 +7,17 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_keys.xul", "_blank", "chrome,width=200,height=200,noopener", window);
+  window.open("window_keys.xul", "_blank", "chrome,width=200,height=200");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_largemenu.html
+++ b/toolkit/content/tests/chrome/test_largemenu.html
@@ -3,17 +3,17 @@
 <head>
   <meta charset="utf-8">
   <title>Large Menu Tests</title>
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script>
     SimpleTest.waitForExplicitFinish();
     function runTest() {
-      window.openDialog("window_largemenu.xul", "_blank", "chrome,width=200,height=200,noopener", window);
+      window.open("window_largemenu.xul", "_blank", "chrome,width=200,height=200");
     }
   </script>
 </head>
 <body onload="setTimeout(runTest, 0);">
 <p id="display"></p>
 <div id="content" style="display: none"></div>
 <pre id="test">
 </pre>
--- a/toolkit/content/tests/chrome/test_maximized_persist.xul
+++ b/toolkit/content/tests/chrome/test_maximized_persist.xul
@@ -21,19 +21,18 @@
           resolve();
         }
       }
       window.addEventListener("message", listener);
     });
   }
 
   function openWindow(features = "") {
-    return docShell.rootTreeItem.domWindow.openDialog(
-        "window_maximized_persist.xul",
-        "_blank", "chrome,dialog=no,all," + features, window);
+    return window.openDialog("window_maximized_persist.xul",
+                             null, "chrome,dialog=no,all," + features);
   }
 
   function checkWindow(msg, win, sizemode, width, height) {
     is(win.windowState, sizemode, "sizemode should match " + msg);
     if (sizemode == win.STATE_NORMAL) {
       is(win.innerWidth, width, "width should match " + msg);
       is(win.innerHeight, height, "height should match " + msg);
     }
--- a/toolkit/content/tests/chrome/test_menuitem_commands.xul
+++ b/toolkit/content/tests/chrome/test_menuitem_commands.xul
@@ -9,40 +9,40 @@
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
 <script>
 <![CDATA[
 SimpleTest.waitForExplicitFinish();
 
 function checkAttributes(elem, label, accesskey, disabled, hidden, isAfter)
 {
-  var is = window.arguments[0].SimpleTest.is;
+  var is = window.opener.wrappedJSObject.SimpleTest.is;
 
   is(elem.getAttribute("label"), label, elem.id + " label " + (isAfter ? "after" : "before") + " open");
   is(elem.getAttribute("accesskey"), accesskey, elem.id + " accesskey " + (isAfter ? "after" : "before") + " open");
   is(elem.getAttribute("disabled"), disabled, elem.id + " disabled " + (isAfter ? "after" : "before") + " open");
   is(elem.getAttribute("hidden"), hidden, elem.id + " hidden " + (isAfter ? "after" : "before") + " open");
 }
 
 function runOrOpen()
 {
-  if (window.arguments) {
+  if (window.opener) {
     SimpleTest.waitForFocus(runTest);
   }
   else {
-    window.openDialog("test_menuitem_commands.xul", "", "chrome,noopener", window);
+    window.open("test_menuitem_commands.xul", "", "chrome");
   }
 }
 
 function runTest()
 {
   runTestSet("");
   runTestSet("bar");
   window.close();
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
 function runTestSet(suffix)
 {
   var isMac = (navigator.platform.includes("Mac"));
 
   var one = $("one" + suffix);
   var two = $("two" + suffix);
--- a/toolkit/content/tests/chrome/test_navigate_persist.html
+++ b/toolkit/content/tests/chrome/test_navigate_persist.html
@@ -39,27 +39,25 @@ https://bugzilla.mozilla.org/show_bug.cg
     }
 
     async function runTest() {
       // Test that persisted window attributes are loaded when a top level
       // window is navigated. This mimics the behavior of early first paint by
       // first loading about:blank and then navigating to window_navigate_persist.html.
       const PERSIST_SIZE = 200;
       // First, load the document and resize it so the size is persisted.
-      let win = window.docShell.rootTreeItem.domWindow
-                      .openDialog("window_navigate_persist.html", "_blank", `chrome,all,dialog=no`);
+      let win = openDialog("window_navigate_persist.html", "_blank", `chrome,all,dialog=no`);
       await SimpleTest.promiseFocus(win);
       await resize(win, PERSIST_SIZE);
       is(win.outerWidth, PERSIST_SIZE, "Window is resized to desired width");
       is(win.outerHeight, PERSIST_SIZE, "Window is resized to desired height");
       win.close();
 
       // Now mimic early first paint.
-      win = window.docShell.rootTreeItem.domWindow
-                  .openDialog("about:blank", "_blank", `chrome,all,dialog=no`);
+      win = openDialog("about:blank", "_blank", `chrome,all,dialog=no`);
       await SimpleTest.promiseFocus(win, true);
       isnot(win.outerWidth, PERSIST_SIZE, "Initial window width is not the persisted size");
       isnot(win.outerHeight, PERSIST_SIZE, "Initial window height is not the persisted size");
 
       await navigateWindowTo(win, "window_navigate_persist.html");
       is(win.outerWidth, PERSIST_SIZE, "Window width is persisted");
       is(win.outerHeight, PERSIST_SIZE, "Window height is persisted");
       win.close();
@@ -72,9 +70,9 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1460639">Mozilla Bug 1460639</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 </pre>
 </body>
-</html>
+</html>
\ No newline at end of file
--- a/toolkit/content/tests/chrome/test_panel.xul
+++ b/toolkit/content/tests/chrome/test_panel.xul
@@ -8,17 +8,17 @@
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_panel.xul", "_blank", "chrome,left=200,top=200,width=200,height=200,noopener", window);
+  window.open("window_panel.xul", "_blank", "chrome,left=200,top=200,width=200,height=200");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_panel_anchoradjust.xul
+++ b/toolkit/content/tests/chrome/test_panel_anchoradjust.xul
@@ -8,17 +8,17 @@
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_panel_anchoradjust.xul", "_blank", "chrome,left=200,top=200,width=200,height=200,noopener", window);
+  window.open("window_panel_anchoradjust.xul", "_blank", "chrome,left=200,top=200,width=200,height=200");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_panel_focus.xul
+++ b/toolkit/content/tests/chrome/test_panel_focus.xul
@@ -15,17 +15,17 @@
  
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
   // move the mouse so any tooltips that might be open go away, otherwise this
   // test can fail on Mac
   synthesizeMouse(document.documentElement, 1, 1, { type: "mousemove" });
 
-  window.openDialog("window_panel_focus.xul", "_blank", "chrome,width=600,height=600,noopener", window);
+  window.open("window_panel_focus.xul", "_blank", "chrome,width=600,height=600");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_popup_anchor.xul
+++ b/toolkit/content/tests/chrome/test_popup_anchor.xul
@@ -8,17 +8,17 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_popup_anchor.xul", "_blank", "chrome,width=600,height=600,noopener", window);
+  window.open("window_popup_anchor.xul", "_blank", "chrome,width=600,height=600");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_popup_anchoratrect.xul
+++ b/toolkit/content/tests/chrome/test_popup_anchoratrect.xul
@@ -7,17 +7,17 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>      
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_popup_anchoratrect.xul", "_blank", "chrome,width=200,height=200,noopener", window);
+  window.open("window_popup_anchoratrect.xul", "_blank", "chrome,width=200,height=200");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_popup_preventdefault_chrome.xul
+++ b/toolkit/content/tests/chrome/test_popup_preventdefault_chrome.xul
@@ -7,17 +7,17 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_popup_preventdefault_chrome.xul", "_blank", "chrome,width=600,height=600,noopener", window);
+  window.open("window_popup_preventdefault_chrome.xul", "_blank", "chrome,width=600,height=600");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_preferences.xul
+++ b/toolkit/content/tests/chrome/test_preferences.xul
@@ -430,78 +430,78 @@
       kPref.setBoolPref("browser.preferences.instantApply", aInstantApply);
       WritePrefsToSystem(kPrefValueSet1);
     }
 
     function RunTestInstant()
     {
       // test with instantApply
       InitTestPrefs(true);
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences.xul", "", "modal", RunInstantPrefTest, false);
+      openDialog("window_preferences.xul", "", "modal", RunInstantPrefTest, false);
 
       // - test deferred reset in child window
       InitTestPrefs(true);
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences2.xul", "", "modal", RunResetPrefTest, false);
+      openDialog("window_preferences2.xul", "", "modal", RunResetPrefTest, false);
       expected = kPrefValueSet1;
       found    = ReadPrefsFromSystem();
       ok(found.int          === expected.int,          "instant reset deferred int"    );
       ok(found.bool         === expected.bool,         "instant reset deferred bool"   );
       ok(found.string       === expected.string,       "instant reset deferred string" );
       ok(found.unichar      === expected.unichar,      "instant reset deferred unichar");
       ok(found.wstring_data === expected.wstring_data, "instant reset deferred wstring");
       todo(found.file_data  === expected.file_data,    "instant reset deferred file"   );
     }
 
     function RunTestNonInstant()
     {
       // test without instantApply
       // - general tests, similar to instant apply
       InitTestPrefs(false);
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestGeneral, false);
+      openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestGeneral, false);
 
       // - test Cancel
       InitTestPrefs(false);
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestClose, false);
+      openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestClose, false);
       var expected = kPrefValueSet1;
       var found    = ReadPrefsFromSystem();
       ok(found.int          === expected.int,          "non-instant cancel system int"    );
       ok(found.bool         === expected.bool,         "non-instant cancel system bool"   );
       ok(found.string       === expected.string,       "non-instant cancel system string" );
       ok(found.unichar      === expected.unichar,      "non-instant cancel system unichar");
       ok(found.wstring_data === expected.wstring_data, "non-instant cancel system wstring");
       todo(found.file_data  === expected.file_data,    "non-instant cancel system file"   );
       
       // - test Accept
       InitTestPrefs(false);
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestClose, true);
+      openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestClose, true);
       expected = kPrefValueSet2;
       found    = ReadPrefsFromSystem();
       ok(found.int          === expected.int,          "non-instant accept system int"    );
       ok(found.bool         === expected.bool,         "non-instant accept system bool"   );
       ok(found.string       === expected.string,       "non-instant accept system string" );
       ok(found.unichar      === expected.unichar,      "non-instant accept system unichar");
       ok(found.wstring_data === expected.wstring_data, "non-instant accept system wstring");
       todo(found.file_data  === expected.file_data,    "non-instant accept system file"   );
 
       // - test deferred reset in child window
       InitTestPrefs(false);
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences2.xul", "", "modal", RunResetPrefTest, true);
+      openDialog("window_preferences2.xul", "", "modal", RunResetPrefTest, true);
       expected = CreateEmptyPrefValueSet();
       found    = ReadPrefsFromSystem();
       ok(found.int          === expected.int,          "non-instant reset deferred int"    );
       ok(found.bool         === expected.bool,         "non-instant reset deferred bool"   );
       ok(found.string       === expected.string,       "non-instant reset deferred string" );
       ok(found.unichar      === expected.unichar,      "non-instant reset deferred unichar");
       ok(found.wstring_data === expected.wstring_data, "non-instant reset deferred wstring");
       ok(found.file_data    === expected.file_data,    "non-instant reset deferred file"   );
     }
 
     function RunTestCommandRedirect()
     {
-      window.docShell.rootTreeItem.domWindow.openDialog("window_preferences_commandretarget.xul", "", "modal", RunCheckCommandRedirect, true);
+      openDialog("window_preferences_commandretarget.xul", "", "modal", RunCheckCommandRedirect, true);
     }
 
     function RunTest()
     {
       RunTestInstant();
       RunTestNonInstant();
       RunTestCommandRedirect();
       SimpleTest.finish();
--- a/toolkit/content/tests/chrome/test_preferences_beforeaccept.xul
+++ b/toolkit/content/tests/chrome/test_preferences_beforeaccept.xul
@@ -13,17 +13,17 @@
     SpecialPowers.pushPrefEnv({"set":[["browser.preferences.instantApply", false]]}, function() {
 
     SimpleTest.registerCleanupFunction(() => {
       SpecialPowers.clearUserPref("tests.beforeaccept.dialogShown");
       SpecialPowers.clearUserPref("tests.beforeaccept.called");
     });
 
     // No instant-apply for this test
-    var prefWindow = window.docShell.rootTreeItem.domWindow.openDialog("window_preferences_beforeaccept.xul", "", "", windowOnload);
+    var prefWindow = openDialog("window_preferences_beforeaccept.xul", "", "", windowOnload);
 
     function windowOnload() {
       var dialogShown = prefWindow.Preferences.get("tests.beforeaccept.dialogShown");
       var called = prefWindow.Preferences.get("tests.beforeaccept.called");
       is(dialogShown.value, true, "dialog opened, shown pref set");
       is(dialogShown.valueFromPreferences, null, "shown pref not committed");
       is(called.value, null, "beforeaccept not yet called");
       is(called.valueFromPreferences, null, "beforeaccept not yet called, pref not committed");
--- a/toolkit/content/tests/chrome/test_preferences_onsyncfrompreference.xul
+++ b/toolkit/content/tests/chrome/test_preferences_onsyncfrompreference.xul
@@ -19,17 +19,17 @@
 
     SimpleTest.waitForExplicitFinish();
 
     for (let pref of PREFS) {
       Services.prefs.setIntPref(pref, 1);
     }
 
     let counter = 0;
-    let prefWindow = window.docShell.rootTreeItem.domWindow.openDialog("window_preferences_onsyncfrompreference.xul", "", "", onSync);
+    let prefWindow = openDialog("window_preferences_onsyncfrompreference.xul", "", "", onSync);
 
     SimpleTest.registerCleanupFunction(() => {
       for (let pref of PREFS) {
         Services.prefs.clearUserPref(pref);
       }
       prefWindow.close();
     });
 
--- a/toolkit/content/tests/chrome/test_screenPersistence.xul
+++ b/toolkit/content/tests/chrome/test_screenPersistence.xul
@@ -11,34 +11,32 @@
 
 <script class="testbody" type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
   let win;
   var left = 60 + screen.availLeft;
   var upper = 60 + screen.availTop;
 
   function runTest() {
-    win = window.docShell.rootTreeItem.domWindow
-                .openDialog("window_screenPosSize.xul",
-                            "_blank",
+    win = window.openDialog("window_screenPosSize.xul",
+                            null,
                             "chrome,dialog=no,all,screenX=" + left + ",screenY=" + upper + ",outerHeight=200,outerWidth=200");
     SimpleTest.waitForFocus(checkTest, win);
   }
   function checkTest() {
     is(win.screenX, left, "The window should be placed now at x=" + left + "px");
     is(win.screenY, upper, "The window should be placed now at y=" + upper + "px");
     is(win.outerHeight, 200, "The window size should be height=200px");
     is(win.outerWidth, 200, "The window size should be width=200px");
     runTest2();
   }
   function runTest2() {
     win.close();
-    win = window.docShell.rootTreeItem.domWindow
-                .openDialog("window_screenPosSize.xul",
-                            "_blank",
+    win = window.openDialog("window_screenPosSize.xul",
+                            null,
                             "chrome,dialog=no,all");
     SimpleTest.waitForFocus(checkTest2, win);
   }
   function checkTest2() {
     let runTime = Cc["@mozilla.org/xre/app-info;1"]
                     .getService(Ci.nsIXULRuntime);
     if (runTime.OS != "Linux") {
       is(win.screenX, 80, "The window should be placed now at x=80px");
--- a/toolkit/content/tests/chrome/test_showcaret.xul
+++ b/toolkit/content/tests/chrome/test_showcaret.xul
@@ -54,17 +54,17 @@ function runTest()
   document.commandDispatcher.getControllerForCommand("cmd_moveBottom").doCommand("cmd_moveBottom");
 
   ok(frames[1].scrollY <
        frames[1].document.getElementById('s').getBoundingClientRect().top,
      "scrollY for showcaret");
   isnot(sel2.focusNode, frames[1].document.body, "focusNode for showcaret");
   ok(sel2.anchorOffset > 0, "focusOffset for showcaret");
 
-  otherWindow = window.docShell.rootTreeItem.domWindow.open("window_showcaret.xul", "_blank", "chrome,width=400,height=200");
+  otherWindow = window.open("window_showcaret.xul", "_blank", "chrome,width=400,height=200");
   otherWindow.addEventListener("focus", otherWindowFocused, false);
 }
 
 function otherWindowFocused()
 {
   otherWindow.removeEventListener("focus", otherWindowFocused, false);
 
   // enable caret browsing temporarily to test caret movement
--- a/toolkit/content/tests/chrome/test_subframe_origin.xul
+++ b/toolkit/content/tests/chrome/test_subframe_origin.xul
@@ -15,17 +15,17 @@
 <script>
 
 // Added after content child widgets were removed from ui windows. Tests sub frame
 // event client coordinate offsets.
 
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_subframe_origin.xul", "_blank", "chrome,width=600,height=600,noopener", window);
+  window.open("window_subframe_origin.xul", "_blank", "chrome,width=600,height=600");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_titlebar.xul
+++ b/toolkit/content/tests/chrome/test_titlebar.xul
@@ -14,17 +14,17 @@
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
 SimpleTest.waitForExplicitFinish();
 
 function test_titlebar()
 {
-  window.openDialog("window_titlebar.xul", "_blank", "chrome,left=200,top=200,noopener", window);
+  window.open("window_titlebar.xul", "_blank", "chrome,left=200,top=200");
 }
 
 function done(testWindow)
 {
   testWindow.close();
   SimpleTest.finish();
 }
 
--- a/toolkit/content/tests/chrome/test_tooltip.xul
+++ b/toolkit/content/tests/chrome/test_tooltip.xul
@@ -7,17 +7,17 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
 <script>
 SimpleTest.waitForExplicitFinish();
 function runTest()
 {
-  window.openDialog("window_tooltip.xul", "_blank", "chrome,width=700,height=700,noopener", window);
+  window.open("window_tooltip.xul", "_blank", "chrome,width=700,height=700");
 }
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/chrome/test_window_intrinsic_size.xul
+++ b/toolkit/content/tests/chrome/test_window_intrinsic_size.xul
@@ -5,18 +5,17 @@
         onload="runTest()"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 <script class="testbody" type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
 
   function openWindow(features = "") {
-    return window.docShell.rootTreeItem.domWindow
-                 .openDialog("window_intrinsic_size.xul",
+    return window.openDialog("window_intrinsic_size.xul",
                              "", "chrome,dialog=no,all," + features);
   }
 
   function checkWindowSize(win, width, height, msg) {
     is(win.innerWidth, width, "width should match " + msg);
     is(win.innerHeight, height, "height should match " + msg);
   }
 
--- a/toolkit/content/tests/chrome/window_browser_drop.xul
+++ b/toolkit/content/tests/chrome/window_browser_drop.xul
@@ -219,19 +219,19 @@ async function dropLinksOnBrowser(browse
     // Canceling the event, however, should prevent the link from being handled.
     await expectLink(browser,
                       [],
                       [ [ { type: "text/uri-list", data: "http://www.mozilla.org/" } ] ],
                       "text/x-moz-url drop on browser with cancelled drop event", true);
   }
 }
 
-function info(msg) { window.arguments[0].SimpleTest.info(msg); }
-function is(l, r, n) { window.arguments[0].SimpleTest.is(l,r,n); }
-function ok(v, n) { window.arguments[0].SimpleTest.ok(v,n); }
+function info(msg) { window.opener.wrappedJSObject.SimpleTest.info(msg); }
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
+function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
 
 ]]>
 </script>
 
 <browser id="chromechild" src="about:blank"/>
 <browser id="contentchild" type="content" width="100" height="100"
          src="data:text/html,&lt;html draggable='true'&gt;&lt;body draggable='true' style='width: 100px; height: 100px;' ondragover='event.preventDefault()' ondrop='if (window.stopMode) event.stopPropagation(); if (window.cancelMode) event.preventDefault();'&gt;&lt;/body&gt;&lt;/html&gt;"/>
 
--- a/toolkit/content/tests/chrome/window_chromemargin.xul
+++ b/toolkit/content/tests/chrome/window_chromemargin.xul
@@ -8,17 +8,17 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 chrome margins rock!
 <script>
 
 // Tests parsing of the chrome margin attrib on a window.
 
 function ok(condition, message) {
-  window.arguments[0].SimpleTest.ok(condition, message);
+  window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
 }
 
 function doSingleTest(param, shouldSucceed)
 {
   var exception = null;
   try {
     document.documentElement.removeAttribute("chromemargin");
     document.documentElement.setAttribute("chromemargin", param);
@@ -57,16 +57,16 @@ function runTests()
   doSingleTest("12123123", false);
   doSingleTest("0,-1,-1,-1", true);
   doSingleTest("-1,0,-1,-1", true);
   doSingleTest("-1,-1,0,-1", true);
   doSingleTest("-1,-1,-1,0", true);
   doSingleTest("1234567890,1234567890,1234567890,1234567890", true);
   doSingleTest("-1,-1,-1,-1", true);
 
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
   window.close();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 
 </script>
 </window>
--- a/toolkit/content/tests/chrome/window_cursorsnap_dialog.xul
+++ b/toolkit/content/tests/chrome/window_cursorsnap_dialog.xul
@@ -7,37 +7,37 @@
   buttons="accept,cancel"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function ok(aCondition, aMessage)
 {
-  window.arguments[0].SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 function canRetryTest()
 {
-  return window.arguments[0].canRetryTest();
+  return window.opener.wrappedJSObject.canRetryTest();
 }
 
 function getTimeoutTime()
 {
-  return window.arguments[0].getTimeoutTime();
+  return window.opener.wrappedJSObject.getTimeoutTime();
 }
 
 var gTimer;
 var gRetry;
 
 function finishByTimeout()
 {
   var button = document.getElementById("dialog").getButton("accept");
@@ -74,31 +74,31 @@ function onMouseMove(aEvent)
   finish();
 }
 
 function onload()
 {
   var button = document.getElementById("dialog").getButton("accept");
   button.addEventListener("mousemove", onMouseMove, false);
 
-  if (window.arguments[0].gDisable) {
+  if (window.opener.wrappedJSObject.gDisable) {
     button.disabled = true;
   }
-  if (window.arguments[0].gHidden) {
+  if (window.opener.wrappedJSObject.gHidden) {
     button.hidden = true;
   }
   gRetry = false;
   gTimer = setTimeout(finishByTimeout, getTimeoutTime());
 }
 
 function onunload()
 {
   if (gRetry) {
-    window.arguments[0].retryCurrentTest();
+    window.opener.wrappedJSObject.retryCurrentTest();
   } else {
-    window.arguments[0].runNextTest();
+    window.opener.wrappedJSObject.runNextTest();
   }
 }
 
 ]]>
 </script>
 
 </dialog>
--- a/toolkit/content/tests/chrome/window_keys.xul
+++ b/toolkit/content/tests/chrome/window_keys.xul
@@ -115,17 +115,17 @@ function runTest()
   }
 
   menuitem2.removeAttribute("key");
   is(accelText(menuitem2), "", "menuitem2 accelText after remove");
 
   $("menubutton").open = false;
 
   window.close();
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
 function iterateKeys(enabled, testid)
 {
   for (var k = 0; k < keysToTest.length; k++) {
     gExpected = keysToTest[k];
     var expectedKey = gExpected[0];
     if (!gExpected[2].accessKey || !navigator.platform.includes("Mac")) {
@@ -142,18 +142,18 @@ function checkKey(event)
   // that was expected. If this is empty, a handler wasn't expected to be called
   if (gExpected[0])
     is(event.originalTarget.id, gExpected[0], "key " + gExpected[1]);
   else
     is("key " + event.originalTarget.id + " was activated", "", "key " + gExpected[1]);
   gExpected = null;
 }
 
-function is(l, r, n) { window.arguments[0].SimpleTest.is(l,r,n); }
-function ok(v, n) { window.arguments[0].SimpleTest.ok(v,n); }
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
+function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
 
 SimpleTest.waitForFocus(runTest);
 
 ]]>
 </script>
 
 <command id="scommand" oncommand="checkKey(event)"/>
 <command id="scommand-disabled" disabled="true"/>
--- a/toolkit/content/tests/chrome/window_largemenu.xul
+++ b/toolkit/content/tests/chrome/window_largemenu.xul
@@ -156,18 +156,18 @@ function popupShown()
     ok(!gOverflowed && gUnderflowed, gTests[gTestIndex] + " overflow");
   }
 
   is(scrollbox.scrollTop, expectedScrollPos, "menu scroll position")
 
   hidePopup();
 }
 
-function is(l, r, n) { window.arguments[0].SimpleTest.is(l,r,n); }
-function ok(v, n) { window.arguments[0].SimpleTest.ok(v,n); }
+function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
+function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
 
 var oldx, oldy, waitSteps = 0;
 function moveWindowTo(x, y, callback, arg)
 {
   if (!waitSteps) {
     oldx = window.screenX;
     oldy = window.screenY;
     window.moveTo(x, y);
@@ -175,33 +175,33 @@ function moveWindowTo(x, y, callback, ar
     waitSteps++;
     setTimeout(moveWindowTo, 100, x, y, callback, arg);
     return;
   }
 
   if (window.screenX == oldx && window.screenY == oldy) {
     if (waitSteps++ > 10) {
       ok(false, "Window never moved properly to " + x + "," + y);
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
       window.close();
     }
 
     setTimeout(moveWindowTo, 100, x, y, callback, arg);
   }
   else {
     waitSteps = 0;
     callback(arg);
   }
 }
 
 function popupHidden()
 {
   gTestIndex++;
   if (gTestIndex == gTests.length) {
-    window.arguments[0].SimpleTest.finish();
+    window.opener.wrappedJSObject.SimpleTest.finish();
     window.close();
   }
   else if (gTests[gTestIndex] == "context menu enough space below") {
     gContextMenuTests = true;
     moveWindowTo(window.screenX, screen.availTop + 10,
       () => synthesizeMouse(document.getElementById("label"), 4, 4, { type: "contextmenu", button: 2 }));
   }
   else if (gTests[gTestIndex] == "menu movement") {
@@ -387,17 +387,17 @@ function testPopupMovement()
   popup.hidePopup();
 }
 
 function platformIsMac()
 {
   return navigator.platform.indexOf("Mac") > -1;
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 
 ]]>
 </script>
 
 <button id="label" label="OK" context="popup"/>
 <menupopup id="popup" onpopupshown="popupShown();" onpopuphidden="popupHidden();"
                       onoverflow="gOverflowed = true" onunderflow="gUnderflowed = true;">
   <menuitem id="firstitem" label="1"/>
--- a/toolkit/content/tests/chrome/window_maximized_persist.xul
+++ b/toolkit/content/tests/chrome/window_maximized_persist.xul
@@ -4,12 +4,12 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         height="300"
         width="300"
         sizemode="normal"
         id="window"
         persist="height width sizemode">
 <script type="application/javascript"><![CDATA[
   window.addEventListener("sizemodechange", evt => {
-    window.arguments[0].postMessage("sizemodechange", "*");
+    opener.postMessage("sizemodechange", "*");
   });
 ]]></script>
 </window>
--- a/toolkit/content/tests/chrome/window_panel.xul
+++ b/toolkit/content/tests/chrome/window_panel.xul
@@ -31,38 +31,38 @@
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 
 SimpleTest.waitForExplicitFinish();
 
 var currentTest = null;
 
 function ok(condition, message) {
-  window.arguments[0].SimpleTest.ok(condition, message);
+  window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
 }
 
 function is(left, right, message) {
-  window.arguments[0].SimpleTest.is(left, right, message);
+  window.opener.wrappedJSObject.SimpleTest.is(left, right, message);
 }
 
 function test_panels()
 {
   checkTreeCoords();
 
   addEventListener("popupshowing", popupShowing, false);
   addEventListener("popupshown", popupShown, false);
   addEventListener("popuphidden", nextTest, false);
   nextTest();
 }
 
 function nextTest()
 {
   if (!tests.length) {
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    window.opener.wrappedJSObject.SimpleTest.finish();
     return;
   }
 
   currentTest = tests.shift();
   var panel = createPanel(currentTest.attrs);
   currentTest.test(panel);
 }
 
@@ -272,14 +272,14 @@ var tests = [
       is(screenRect.left, -150, testname + " screen left");
       is(screenRect.top, -150, testname + " screen top");
       is(screenRect.width, 120, testname + " screen width");
       is(screenRect.height, 40, testname + " screen height");
     }
   },
 ];
 
-window.arguments[0].SimpleTest.waitForFocus(test_panels, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(test_panels, window);
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/window_panel_anchoradjust.xul
+++ b/toolkit/content/tests/chrome/window_panel_anchoradjust.xul
@@ -155,26 +155,26 @@ function runTests() {
     ok(isWithinHalfPixel(anchor4rect.left, panelrect.left - xarrowdiff), "no follow anchor x");
     ok(isWithinHalfPixel(anchor4rect.bottom, panelrect.top), "no follow anchor y");
 
     popuphidden = waitForPanel(panel, "popuphidden");
     panel.hidePopup();
     await popuphidden;
 
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    window.opener.wrappedJSObject.SimpleTest.finish();
   })();
 }
 
 function ok(condition, message) {
-  window.arguments[0].SimpleTest.ok(condition, message);
+  window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
 }
 
 function is(left, right, message) {
-  window.arguments[0].SimpleTest.is(left, right, message);
+  window.opener.wrappedJSObject.SimpleTest.is(left, right, message);
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/window_panel_focus.xul
+++ b/toolkit/content/tests/chrome/window_panel_focus.xul
@@ -76,21 +76,21 @@ function panelShown()
   synthesizeKeyExpectEvent("KEY_Tab", {shiftKey: true}, $("t2"), "focus", "back tabindex 9");
 
   is(gButtonBlur, 3, "blur events fired within popup");
 
   synthesizeKey("KEY_Escape");
 }
 
 function ok(condition, message) {
-  window.arguments[0].SimpleTest.ok(condition, message);
+  window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
 }
 
 function is(left, right, message) {
-  window.arguments[0].SimpleTest.is(left, right, message);
+  window.opener.wrappedJSObject.SimpleTest.is(left, right, message);
 }
 
 function panelHidden()
 {
   // closing the popup should have blurred the focused element
   is(gButtonBlur, 4, "focus removed when popup closed");
 
   // now that the panel is hidden, pressing tab should focus the elements in
@@ -106,20 +106,20 @@ function noautofocusPanelShown()
   // opened, so key events should still be fired at the checkbox.
   synthesizeKeyExpectEvent(" ", {}, $("b1"), "command", "noautofocus");
   $("noautofocusPanel").hidePopup();
 }
 
 function noautofocusPanelHidden()
 {
   window.close();
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(showPanel, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(showPanel, window);
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
--- a/toolkit/content/tests/chrome/window_popup_anchor.xul
+++ b/toolkit/content/tests/chrome/window_popup_anchor.xul
@@ -5,17 +5,17 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 <script>
 function runTests()
 {
   frames[0].openPopup();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 </script>
 
 <spacer height="13"/>
 <button id="outerbutton" label="Button One" style="margin-left: 6px; -moz-appearance: none;"/>
 <hbox>
   <spacer width="20"/>
   <deck>
     <vbox>
--- a/toolkit/content/tests/chrome/window_popup_anchoratrect.xul
+++ b/toolkit/content/tests/chrome/window_popup_anchoratrect.xul
@@ -71,41 +71,41 @@ function runTest(id)
   menupopup = $("popup");
   nextTest();
 }
 
 function nextTest()
 {
   if (!tests.length) {
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    window.opener.SimpleTest.finish();
     return;
   }
 
   tests[0].test();
 }
 
 function popupshown(popup)
 {
   tests[0].verify(popup);
   tests.shift();
   popup.hidePopup();
 }
 
 function is(left, right, message)
 {
-  window.arguments[0].SimpleTest.is(left, right, message);
+  window.opener.SimpleTest.is(left, right, message);
 }
 
 function ok(value, message)
 {
-  window.arguments[0].SimpleTest.ok(value, message);
+  window.opener.SimpleTest.ok(value, message);
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTest, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window);
 
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
--- a/toolkit/content/tests/chrome/window_popup_preventdefault_chrome.xul
+++ b/toolkit/content/tests/chrome/window_popup_preventdefault_chrome.xul
@@ -14,18 +14,18 @@
 var gBlockShowing = true;
 var gBlockHiding = true;
 var gShownNotAllowed = true;
 var gHiddenNotAllowed = true;
 
 var fm = Components.classes["@mozilla.org/focus-manager;1"].
            getService(Components.interfaces.nsIFocusManager);
 
-var is = function(l, r, v) { window.arguments[0].SimpleTest.is(l, r, v); }
-var isnot = function(l, r, v) { window.arguments[0].SimpleTest.isnot(l, r, v); }
+var is = function(l, r, v) { window.opener.wrappedJSObject.SimpleTest.is(l, r, v); }
+var isnot = function(l, r, v) { window.opener.wrappedJSObject.SimpleTest.isnot(l, r, v); }
 
 function runTest()
 {
   var menu = document.getElementById("menu");
 
   is(fm.activeWindow, window, "active window at start");
   is(fm.focusedWindow, window, "focused window at start");
 
@@ -69,17 +69,17 @@ function popupShowing(event)
                  gShownNotAllowed = false;
                  document.getElementById("menu").open = true;
                }, 3000, true);
   }
 }
 
 function popupShown()
 {
-  window.arguments[0].SimpleTest.ok(!gShownNotAllowed, "popupshowing preventDefault");
+  window.opener.wrappedJSObject.SimpleTest.ok(!gShownNotAllowed, "popupshowing preventDefault");
   document.getElementById("menu").open = false;
 }
 
 function popupHiding(event)
 {
   if (gBlockHiding) {
     event.preventDefault();
     gBlockHiding = false;
@@ -87,22 +87,22 @@ function popupHiding(event)
                  gHiddenNotAllowed = false;
                  document.getElementById("menu").open = false;
                }, 3000, true);
   }
 }
 
 function popupHidden()
 {
-  window.arguments[0].SimpleTest.ok(!gHiddenNotAllowed, "popuphiding preventDefault");
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.ok(!gHiddenNotAllowed, "popuphiding preventDefault");
+  window.opener.wrappedJSObject.SimpleTest.finish();
   window.close();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTest, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window);
 </script>
 
 <button id="menu" type="menu" label="Menu">
   <menupopup onpopupshowing="popupShowing(event);"
              onpopupshown="popupShown();"
              onpopuphiding="popupHiding(event);"
              onpopuphidden="popupHidden();">
     <menuitem label="Item"/>
--- a/toolkit/content/tests/chrome/window_subframe_origin.xul
+++ b/toolkit/content/tests/chrome/window_subframe_origin.xul
@@ -18,24 +18,24 @@
 // Fire a mouse move event aimed at this window, and check to be
 // sure the client coords translate from widget to the dom correctly.
 
 function runTests()
 {
   synthesizeMouse(document.getElementById("window"), 1, 2, { type: "mousemove" });
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 
 function mouseMove(e) {
   var element = e.target;
   var el = document.getElementById("parentcap");
   el.label = "client: (" + e.clientX + "," + e.clientY + ")";
-  window.arguments[0].SimpleTest.is(e.clientX, 1, "mouse event clientX");
-  window.arguments[0].SimpleTest.is(e.clientY, 2, "mouse event clientY");
+  window.opener.wrappedJSObject.SimpleTest.is(e.clientX, 1, "mouse event clientX");
+  window.opener.wrappedJSObject.SimpleTest.is(e.clientY, 2, "mouse event clientY");
   // fire the next test on the sub frame
   frames[0].runTests();
 }
 
 window.addEventListener("mousemove",mouseMove, false);
 
 </script>
 </window>
--- a/toolkit/content/tests/chrome/window_titlebar.xul
+++ b/toolkit/content/tests/chrome/window_titlebar.xul
@@ -47,17 +47,17 @@
     </titlebar>
   </panel>
 
   <button id="button" label="OK"/>
 
 <script>
 <![CDATA[
 
-var SimpleTest = window.arguments[0].SimpleTest;
+var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
 
 SimpleTest.waitForFocus(test_titlebar, window);
 
 var mouseDownTarget;
 var origoldx, origoldy, oldx, oldy, waitSteps = 0;
 function waitForWindowMove(element, x, y, callback, arg, panel, anchored)
 {
   var isPanelMove = (element.id != "label");
@@ -69,17 +69,17 @@ function waitForWindowMove(element, x, y
   }
 
   var newx = isPanelMove ? panel.getBoundingClientRect().left : window.screenX; 
   var newy = isPanelMove ? panel.getBoundingClientRect().top : window.screenY; 
   if (newx == oldx && newy == oldy) {
     if (waitSteps++ > 10) {
       SimpleTest.is(window.screenX + "," + window.screenY, oldx + "," + oldy + " ",
                     "Window never moved properly to " + x + "," + y + (panel ? " " + panel.id : ""));
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
       window.close();
       return;
     }
 
     setTimeout(waitForWindowMove, 100, element, x, y, callback, arg, panel, anchored);
   }
   else {
     waitSteps = 0;
@@ -208,15 +208,15 @@ function popuphidden(nextPopup)
     if (panel.id == "panelnoautohide") {
       panel.openPopupAtScreen(window.screenX + 50, window.screenY + 60, false);
     }
     else {
       panel.openPopup(document.getElementById("button"), "after_start");
     }
   }
   else
-    window.arguments[0].done(window);
+    window.opener.wrappedJSObject.done(window);
 }
 
 ]]>
 </script>
 
 </window>
--- a/toolkit/content/tests/chrome/window_tooltip.xul
+++ b/toolkit/content/tests/chrome/window_tooltip.xul
@@ -331,29 +331,29 @@ function moveWindowTo(x, y, callback, ar
     waitSteps++;
     setTimeout(moveWindowTo, 100, x, y, callback, arg);
     return;
   }
 
   if (window.screenX == oldx && window.screenY == oldy) {
     if (waitSteps++ > 10) {
       ok(false, "Window never moved properly to " + x + "," + y);
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
       window.close();
     }
 
     setTimeout(moveWindowTo, 100, x, y, callback, arg);
   }
   else {
     waitSteps = 0;
     callback(arg);
   }
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTest, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window);
 ]]>
 </script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
 <p id="display">
 </p>
 <div id="content" style="display: none">
 </div>
--- a/toolkit/content/tests/widgets/popup_shared.js
+++ b/toolkit/content/tests/widgets/popup_shared.js
@@ -52,20 +52,16 @@ function startPopupTests(tests) {
   document.addEventListener("DOMMenuBarInactive", eventOccurred);
 
   gPopupTests = tests;
   gWindowUtils = SpecialPowers.getDOMWindowUtils(window);
 
   goNext();
 }
 
-if (!window.opener && window.arguments) {
-  window.opener = window.arguments[0];
-}
-
 function finish() {
   if (window.opener) {
     window.close();
     window.opener.SimpleTest.finish();
     return;
   }
   SimpleTest.finish();
 }
--- a/toolkit/mozapps/handling/ContentDispatchChooser.jsm
+++ b/toolkit/mozapps/handling/ContentDispatchChooser.jsm
@@ -18,19 +18,16 @@ nsContentDispatchChooser.prototype = {
 
   // nsIContentDispatchChooser
 
   ask: function ask(aHandler, aWindowContext, aURI, aReason) {
     var window = null;
     try {
       if (aWindowContext) {
         window = aWindowContext.getInterface(Ci.nsIDOMWindow);
-        if (window) {
-          window = window.docShell.rootTreeItem.domWindow;
-        }
       }
     } catch (e) {
       /* it's OK to not have a window */
     }
 
     var bundle = Services.strings.createBundle(STRINGBUNDLE_URL);
 
     // TODO when this is hooked up for content, we will need different strings
--- a/widget/tests/bug586713_window.xul
+++ b/widget/tests/bug586713_window.xul
@@ -18,22 +18,22 @@
       <menupopup>
         <menuitem label="FooItem0"/>
       </menupopup>
     </menu>
   </menubar>
 
   <script type="application/javascript"><![CDATA[
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function onTestsFinished() {
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     var fooCallCount = 0;
     function foo() {
       fooCallCount++;
       let instruction = document.createProcessingInstruction("xml-stylesheet", 'href="chrome://foo.css" type="text/css"');
       document.insertBefore(instruction, document.documentElement);
       if (fooCallCount == 2) {
--- a/widget/tests/chrome_context_menus_win.xul
+++ b/widget/tests/chrome_context_menus_win.xul
@@ -26,22 +26,22 @@
 <toolbox>
   <toolbar id="nav-toolbar" style="height:30px" context="testmenu">
   </toolbar>
 </toolbox>
 
 <script type="application/javascript"><![CDATA[
 
 function ok(condition, message) {
-    window.arguments[0].SimpleTest.ok(condition, message);
+    window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
 }
 
 function onTestsFinished() {
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
 function openContextMenuFor(element) {
 
     var utils = window.windowUtils;
 
     var tbX = (window.mozInnerScreenX + 10) * utils.screenPixelsPerCSSPixel;
     var tbY = (window.mozInnerScreenY + 10) * utils.screenPixelsPerCSSPixel;
@@ -80,17 +80,17 @@ function menuTimeout() {
 }
 
 function menuDisplayed() {
     clearTimeout(tid);
     ok(true, "Right-click chrome menu displayed despite plugin having focus.");
     onTestsFinished();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(onFocus, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(onFocus, window);
 
 
 ]]></script>
 
 <body xmlns="http://www.w3.org/1999/xhtml">
   <br/>
   <embed id="plugin" type="application/x-test" width="50" height="50"></embed>
 </body>
--- a/widget/tests/native_menus_window.xul
+++ b/widget/tests/native_menus_window.xul
@@ -42,22 +42,22 @@
         </menu>
       </menupopup>
     </menu>
   </menubar>
 
   <script type="application/javascript"><![CDATA[
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function onTestsFinished() {
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     // Force a menu to update itself. All of the menus parents will be updated
     // as well. An empty string will force a complete menu system reload.
     function forceUpdateNativeMenuAt(location) {
       var utils = window.windowUtils;
       try {
         utils.forceUpdateNativeMenuAt(location);
--- a/widget/tests/native_mouse_mac_window.xul
+++ b/widget/tests/native_mouse_mac_window.xul
@@ -17,38 +17,38 @@
 
   <box height="200" id="box"/>
   <menupopup id="popup" width="250" height="50"/>
   <panel id="panel" width="250" height="50" noautohide="true"/>
 
   <script type="application/javascript"><![CDATA[
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function is(a, b, message) {
-      window.arguments[0].SimpleTest.is(a, b, message);
+      window.opener.wrappedJSObject.SimpleTest.is(a, b, message);
     }
 
     function todo(condition, message) {
-      window.arguments[0].SimpleTest.todo(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.todo(condition, message);
     }
 
     function todo_is(a, b, message) {
-      window.arguments[0].SimpleTest.todo_is(a, b, message);
+      window.opener.wrappedJSObject.SimpleTest.todo_is(a, b, message);
     }
 
     function onTestsFinished() {
       clearTimeout(gAfterLoopExecution);
       observe(window, eventMonitor, false);
       observe(gRightWindow, eventMonitor, false);
       observe(gPopup, eventMonitor, false);
       gRightWindow.close();
-      var openerSimpleTest = window.arguments[0].SimpleTest;
+      var openerSimpleTest = window.opener.wrappedJSObject.SimpleTest;
       window.close();
       openerSimpleTest.finish();
     }
 
     const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     const xulWin = 'data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin" type="text/css"?><window xmlns="' + XUL_NS + '"/>';
 
     const NSLeftMouseDown      = 1,
--- a/widget/tests/standalone_native_menu_window.xul
+++ b/widget/tests/standalone_native_menu_window.xul
@@ -40,26 +40,26 @@
 	</menupopup>
       </menu>
     </menupopup>
   </popupset>
 
   <script type="application/javascript"><![CDATA[
 
     function ok(condition, message) {
-      window.arguments[0].SimpleTest.ok(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function todo(condition, message) {
-      window.arguments[0].SimpleTest.todo(condition, message);
+      window.opener.wrappedJSObject.SimpleTest.todo(condition, message);
     }
 
     function onTestsFinished() {
       window.close();
-      window.arguments[0].SimpleTest.finish();
+      window.opener.wrappedJSObject.SimpleTest.finish();
     }
 
     var executedCommandID = "";
 
     function testItem(menu, location, targetID) {
       var correctCommandHandler = false;
       try {
         menu.menuWillOpen();
--- a/widget/tests/system_font_changes.xul
+++ b/widget/tests/system_font_changes.xul
@@ -11,20 +11,20 @@
         width="300"
         height="300"
         onload="start();">
 
 <span id="target" style="font:menu">Hello world</span>
 
 <script type="application/javascript"><![CDATA[
   function is(condition, message) {
-    window.arguments[0].SimpleTest.is(condition, message);
+    window.opener.wrappedJSObject.SimpleTest.is(condition, message);
   }
   function registerCleanupFunction(func) {
-    window.arguments[0].SimpleTest.registerCleanupFunction(func);
+    window.opener.wrappedJSObject.SimpleTest.registerCleanupFunction(func);
   }
 
   async function waitForFrame() {
     return new Promise(resolve => {
       requestAnimationFrame(resolve);
     });
   }
 
@@ -51,12 +51,12 @@
     is(windowUtils.systemFont, 'Serif 11');
 
     await waitForFrame();
     await waitForFrame();
 
     is(getComputedStyle(target).fontFamily, 'Serif');
 
     window.close();
-    window.arguments[0].SimpleTest.finish();
+    window.opener.wrappedJSObject.SimpleTest.finish();
   }
 ]]></script>
 </window>
--- a/widget/tests/test_bug1123480.xul
+++ b/widget/tests/test_bug1123480.xul
@@ -91,17 +91,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     // Sanitize environment again.
     gClipboardHelper.copyString(SHORT_STRING_NO_CACHE);
     is(getClipboardCacheFDCount(), initialFdCount, "should have cleared the clipboard data");
 
     // Repeat procedure of plain text selection with private browsing
     // disabled and enabled
     const {PrivateBrowsingUtils} = ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
     for (let private of [false, true]) {
-      var win = docShell.rootTreeItem.domWindow.open("about:blank", "_blank", "chrome, width=500, height=200" + (private ? ", private" : ""));
+      var win = window.open("about:blank", "_blank", "chrome, width=500, height=200" + (private ? ", private" : ""));
       ok(win, private ? "should open private window" : "should open non-private window");
       is(PrivateBrowsingUtils.isContentWindowPrivate(win), private, "used correct window context");
 
       // Select plaintext in private/non-private channel
       const nsTransferable = Components.Constructor("@mozilla.org/widget/transferable;1", "nsITransferable");
       const nsSupportsString = Components.Constructor("@mozilla.org/supports-string;1", "nsISupportsString");
       var Loadctx = PrivateBrowsingUtils.privacyContextFromWindow(win);
       var Transfer = nsTransferable();
--- a/widget/tests/test_bug429954.xul
+++ b/widget/tests/test_bug429954.xul
@@ -27,18 +27,17 @@ SimpleTest.waitForFocus(function () {
   var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
               getService(Ci.nsIWindowMediator);
   var win = wm.getMostRecentWindow("navigator:browser");
   win.maximize();
   var maxX = win.screenX, maxY = win.screenY;
   var maxWidth = win.outerWidth, maxHeight = win.outerHeight;
   win.restore();
 
-  window.openDialog("window_bug429954.xul", "_blank", 
-                    "chrome,noopener,resizable,width=" + maxWidth + ",height=" + maxHeight +
-                    ",screenX=" + maxX + "screenY=" + maxY,
-                    window);
+  window.open("window_bug429954.xul", "_blank", 
+              "chrome,resizable,width=" + maxWidth + ",height=" + maxHeight +
+              "screenX=" + maxX + "screenY=" + maxY);
 });
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_bug478536.xul
+++ b/widget/tests/test_bug478536.xul
@@ -19,15 +19,15 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("window_bug478536.xul", "_blank", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("window_bug478536.xul", "_blank", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_bug522217.xul
+++ b/widget/tests/test_bug522217.xul
@@ -19,17 +19,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
 
 SimpleTest.waitForFocus(function () {
-  window.openDialog("window_bug522217.xul", "_blank", 
-                    "chrome,resizable,width=400,height=300,noopener", window);
+  window.open("window_bug522217.xul", "_blank", 
+              "chrome,resizable,width=400,height=300");
 });
 
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_bug538242.xul
+++ b/widget/tests/test_bug538242.xul
@@ -29,19 +29,18 @@ SimpleTest.waitForExplicitFinish();
 
 SimpleTest.waitForFocus(function () {
   if (navigator.platform.includes("Lin")) {
     ok(true, "This test is disabled on Linux because it expects moving windows to be synchronous which is not guaranteed on Linux.");
     SimpleTest.finish();
     return;
   }
 
-  var win = docShell.rootTreeItem.domWindow.open(
-      "window_bug538242.xul", "_blank", 
-      "chrome,width=400,height=300,left=100,top=100");
+  var win = window.open("window_bug538242.xul", "_blank", 
+                        "chrome=1,width=400,height=300,left=100,top=100");
   SimpleTest.waitForFocus(function () {
     is(win.screenX, 100, "window should open at 100, 100");
     is(win.screenY, 100, "window should open at 100, 100");
     var [oldX, oldY] = [win.screenX, win.screenY];
     win.moveTo(0, 0);
     isnot(win.screenX, oldX, "window should have moved to a point near 0, 0");
     isnot(win.screenY, oldY, "window should have moved to a point near 0, 0");
     win.close();
--- a/widget/tests/test_bug586713.xul
+++ b/widget/tests/test_bug586713.xul
@@ -15,15 +15,15 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("bug586713_window.xul", "bug586713_window", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("bug586713_window.xul", "bug586713_window", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_chrome_context_menus_win.xul
+++ b/widget/tests/test_chrome_context_menus_win.xul
@@ -8,18 +8,17 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
 <script type="application/javascript" src="utils.js"></script>
 <script>
     setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
     SimpleTest.waitForExplicitFinish();
 
-    var w = docShell.rootTreeItem.domWindow.openDialog(
-        'chrome_context_menus_win.xul', '_blank', 'chrome,resizable=yes,width=600,height=600', window);
+    var w = window.open('chrome_context_menus_win.xul', '_blank', 'chrome,resizable=yes,width=600,height=600');
 
     function done()
     {
         w.close();
         SimpleTest.finish();
     }
 </script>
 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;" />
--- a/widget/tests/test_composition_text_querycontent.xul
+++ b/widget/tests/test_composition_text_querycontent.xul
@@ -20,14 +20,14 @@
 
 // If setting selection with eSetSelection event whose range is larger than
 // the actual range, hits "Can only call this on frames that have been reflowed:
 // '!(GetStateBits() & NS_FRAME_FIRST_REFLOW) || (GetParent()->GetStateBits() &
 // NS_FRAME_TOO_DEEP_IN_FRAME_TREE)'" in nsTextFrame.cpp.
 // Strangely, this doesn't occur with RDP on Windows.
 SimpleTest.expectAssertions(0, 3);
 SimpleTest.waitForExplicitFinish();
-window.openDialog("window_composition_text_querycontent.xul", "_blank", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("window_composition_text_querycontent.xul", "_blank", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 </window>
--- a/widget/tests/test_input_events_on_deactive_window.xul
+++ b/widget/tests/test_input_events_on_deactive_window.xul
@@ -35,19 +35,18 @@ function runTests()
   textarea.focus();
   is(fm.focusedElement, textarea, "we're deactive");
   if (fm.focusedElement != textarea) {
     SimpleTest.finish();
     return;
   }
 
   otherWindow =
-    docShell.rootTreeItem.domWindow.open(
-        "./file_input_events_on_deactive_window.html", "_blank",
-        "chrome,width=100,height=100");
+    window.open("./file_input_events_on_deactive_window.html", "_blank",
+                "chrome,width=100,height=100");
   ok(otherWindow, "failed to open other window");
   if (!otherWindow) {
     SimpleTest.finish();
     return;
   }
 
   SimpleTest.waitForFocus(startTests, otherWindow);
   otherWindow.focus();
--- a/widget/tests/test_mouse_scroll.xul
+++ b/widget/tests/test_mouse_scroll.xul
@@ -23,14 +23,14 @@ SimpleTest.waitForExplicitFinish();
 function onLoad()
 {
   SpecialPowers.pushPrefEnv({"set": [
     ["security.data_uri.unique_opaque_origin", false]]}, runTest);
 }
 
 function runTest()
 {
-  window.openDialog("window_mouse_scroll_win.html", "_blank",
-                    "chrome,width=600,height=600,noopener", window);
+  window.open("window_mouse_scroll_win.html", "_blank",
+              "chrome,width=600,height=600");
 }
 ]]>
 </script>
 </window>
--- a/widget/tests/test_native_menus.xul
+++ b/widget/tests/test_native_menus.xul
@@ -15,15 +15,15 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("native_menus_window.xul", "NativeMenuWindow", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("native_menus_window.xul", "NativeMenuWindow", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_native_mouse_mac.xul
+++ b/widget/tests/test_native_mouse_mac.xul
@@ -15,15 +15,15 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("native_mouse_mac_window.xul", "NativeMouseWindow",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("native_mouse_mac_window.xul", "NativeMouseWindow",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_picker_no_crash.html
+++ b/widget/tests/test_picker_no_crash.html
@@ -9,17 +9,17 @@
 <script type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
 var childWindow;
 
 function testStepOne() {
-  childWindow = window.docShell.rootTreeItem.domWindow.open("window_picker_no_crash_child.html", "childWindow", "width=300,height=150");
+  childWindow = window.open("window_picker_no_crash_child.html", "childWindow", "width=300,height=150");
   SimpleTest.waitForFocus(testStepTwo, childWindow);
 }
 
 function testStepTwo() {
   childWindow.document.form1.uploadbox.click();
   // This should not crash the browser
   childWindow.close();
   setTimeout(testStepThree, 5000);
--- a/widget/tests/test_position_on_resize.xul
+++ b/widget/tests/test_position_on_resize.xul
@@ -10,20 +10,19 @@
   <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
 <script class="testbody" type="application/javascript"><![CDATA[
   SimpleTest.waitForExplicitFinish();
   let win, x, y;
 
   function startTest() {
-    win = docShell.rootTreeItem.domWindow.openDialog(
-        "about:blank",
-        null,
-        "chrome,dialog=no,outerHeight=170,outerWidth=200");
+    win = window.openDialog("about:blank",
+                            null,
+                            "chrome,dialog=no,outerHeight=170,outerWidth=200");
     waitForSuccess(function() { return win.mozPaintCount },
                    "No paint received", checkInitialSize);
   }
 
   function checkInitialSize() {
     let runtime = Cc["@mozilla.org/xre/app-info;1"]
                     .getService(Ci.nsIXULRuntime);
     let test = runtime.widgetToolkit == "windows" ? todo_is : is; // bug 602745
--- a/widget/tests/test_secure_input.html
+++ b/widget/tests/test_secure_input.html
@@ -70,18 +70,18 @@
     $("input_change").type = "password";
     sendAKeyEvent();
     ok(true, "Not crashed: input on <input type=\"password\"> changed from type=\"text\"");
     $("input_change").type = "text";
     sendAKeyEvent();
     ok(true, "Not crashed: input on <input type=\"text\"> changed from type=\"password\"");
 
     var otherWindow =
-      window.docShell.rootTreeItem.domWindow.open("file_secure_input.html",
-                                                  "_blank", "chrome,width=100,height=100");
+      window.open("file_secure_input.html",
+                  "_blank", "chrome,width=100,height=100");
     ok(otherWindow, "failed to open other window");
     if (!otherWindow) {
       SimpleTest.finish();
       return;
     }
 
     $("input_text").focus();
     otherWindow.focus();
--- a/widget/tests/test_standalone_native_menu.xul
+++ b/widget/tests/test_standalone_native_menu.xul
@@ -15,15 +15,15 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("standalone_native_menu_window.xul", "StandaloneNativeMenuWindow", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("standalone_native_menu_window.xul", "StandaloneNativeMenuWindow", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_system_font_changes.xul
+++ b/widget/tests/test_system_font_changes.xul
@@ -14,15 +14,15 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("system_font_changes.xul", "system_font_changes_window",
-                  "chrome,width=600,height=600,noopener", window);
+window.open("system_font_changes.xul", "system_font_changes_window",
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/test_transferable_overflow.xul
+++ b/widget/tests/test_transferable_overflow.xul
@@ -76,17 +76,17 @@
     }
     return count;
   }
 
   function RunTest() {
     const {PrivateBrowsingUtils} = ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
     const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-    var win = docShell.rootTreeItem.domWindow.open("about:blank", "_blank", "chrome, width=500, height=200");
+    var win = window.open("about:blank", "_blank", "chrome, width=500, height=200");
     ok(win, "should open window");
     is(PrivateBrowsingUtils.isContentWindowPrivate(win), false, "used correct window context");
 
     // ### Part 1 - Writing to the clipboard.
 
     var Loadctx = PrivateBrowsingUtils.privacyContextFromWindow(win);
     var Transfer = nsTransferable();
     Transfer.init(Loadctx);
--- a/widget/tests/test_wheeltransaction.xul
+++ b/widget/tests/test_wheeltransaction.xul
@@ -14,14 +14,14 @@
 <pre id="test">
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
-window.openDialog("window_wheeltransaction.xul", "_blank", 
-                  "chrome,width=600,height=600,noopener", window);
+window.open("window_wheeltransaction.xul", "_blank", 
+            "chrome,width=600,height=600");
 
 ]]>
 </script>
 </window>
--- a/widget/tests/window_bug429954.xul
+++ b/widget/tests/window_bug429954.xul
@@ -9,36 +9,36 @@
 <body xmlns="http://www.w3.org/1999/xhtml" id="body">
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function ok(aCondition, aMessage)
 {
-  docShell.rootTreeItem.domWindow.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 function start() {
   var oldWidth = window.outerWidth, oldHeight = window.outerHeight;
   window.maximize();
   window.restore();
   is(window.outerWidth, oldWidth, "wrong window width after maximize+restore");
   is(window.outerHeight, oldHeight, "wrong window height after maximize+restore");
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
   window.close();
 }
 
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/window_bug478536.xul
+++ b/widget/tests/window_bug478536.xul
@@ -34,27 +34,27 @@ Text. Text. Text. Text. Text. Text. Text
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function ok(aCondition, aMessage)
 {
-  window.arguments[0].SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 var gBody = document.getElementById("body");
 var gView = document.getElementById("view");
 
 /**
  * Description:
  *
@@ -118,17 +118,17 @@ function onload()
 }
 
 function onunload()
 {
   resetTimeoutPrefs();
   disableNonTestMouseEvents(false);
   gPrefSvc.clearUserPref(kPrefSmoothScroll);
   SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
 function finish()
 {
   window.close();
 }
 
 // testing code
--- a/widget/tests/window_bug522217.xul
+++ b/widget/tests/window_bug522217.xul
@@ -9,32 +9,32 @@
 <body xmlns="http://www.w3.org/1999/xhtml" id="body">
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function ok(aCondition, aMessage)
 {
-  window.arguments[0].SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 function executeSoon(aFct)
 {
-  window.arguments[0].SimpleTest.executeSoon(aFct);
+  window.opener.wrappedJSObject.SimpleTest.executeSoon(aFct);
 }
 
 function start() {
   window.onfocus = function () {
     window.onfocus = null;
     var oldOuterWidth = window.outerWidth, oldOuterHeight = window.outerHeight;
     var oldInnerWidth = window.innerWidth, oldInnerHeight = window.innerHeight;
     document.documentElement.setAttribute("drawintitlebar", "true");
@@ -52,17 +52,17 @@ function start() {
       is(window.innerHeight, oldOuterHeight, "wrong innerHeight after fullscreen mode");
       document.documentElement.removeAttribute("drawintitlebar");
 
       executeSoon(function() {
         is(window.outerWidth, oldOuterWidth, "wrong outerWidth after removing drawintitlebar");
         is(window.outerHeight, oldOuterHeight, "wrong outerHeight after removing drawintitlebar");
         is(window.innerWidth, oldInnerWidth, "wrong innerWidth after removing drawintitlebar");
         is(window.innerHeight, oldInnerHeight, "wrong innerHeight after removing drawintitlebar");
-        window.arguments[0].SimpleTest.finish();
+        window.opener.wrappedJSObject.SimpleTest.finish();
         window.close();
       });
     });
   }
 }
 
 
 ]]>
--- a/widget/tests/window_composition_text_querycontent.xul
+++ b/widget/tests/window_composition_text_querycontent.xul
@@ -44,42 +44,42 @@
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function ok(aCondition, aMessage)
 {
-  window.arguments[0].SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 function todo(aCondition, aMessage)
 {
-  window.arguments[0].SimpleTest.todo(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.todo(aCondition, aMessage);
 }
 
 function todo_is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.todo_is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.todo_is(aLeft, aRight, aMessage);
 }
 
 function todo_isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.todo_isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.todo_isnot(aLeft, aRight, aMessage);
 }
 
 function isSimilarTo(aLeft, aRight, aAllowedDifference, aMessage)
 {
   if (Math.abs(aLeft - aRight) <= aAllowedDifference) {
     ok(true, aMessage);
   } else {
     ok(false, aMessage + ", got=" + aLeft + ", expected=" + (aRight - aAllowedDifference) + "~" + (aRight + aAllowedDifference));
@@ -9157,17 +9157,17 @@ async function runPasswordMaskDelayTest(
   checkSnapshots(unmaskedResult, unmaskedReference, true,
                  "runPasswordMaskDelayTest(): committed string should be unmasked for a while");
   checkSnapshots(maskedResult, maskedReference, true,
                  "runPasswordMaskDelayTest(): committed string should be masked after a while");
 }
 
 async function runTest()
 {
-  window.addEventListener("unload", window.arguments[0].SimpleTest.finish, {once: true, capture: true});
+  window.addEventListener("unload", window.opener.wrappedJSObject.SimpleTest.finish, {once: true, capture: true});
 
   contenteditable = document.getElementById("iframe4").contentDocument.getElementById("contenteditable");
   windowOfContenteditable = document.getElementById("iframe4").contentWindow;
   textareaInFrame = iframe.contentDocument.getElementById("textarea");
 
   await runIMEContentObserverTest();
   await runEditorReframeTests();
   await runAsyncForceCommitTest();
@@ -9203,14 +9203,14 @@ async function runTest()
   runNativeLineBreakerTest();
   runControlCharTest();
   runFrameTest();
   runMaxLengthTest();
 
   window.close();
 }
 
-window.arguments[0].SimpleTest.waitForFocus(runTest, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window);
 
 ]]>
 </script>
 
 </window>
--- a/widget/tests/window_imestate_iframes.html
+++ b/widget/tests/window_imestate_iframes.html
@@ -30,28 +30,28 @@
           src="data:text/html,&lt;body&gt;&lt;p id='editor' contenteditable='true'&gt;&lt;a href='about:blank'&gt;about:blank;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;"></iframe><br>
 
   <input id="next" readonly><br>
 </p>
 <script class="testbody" type="application/javascript">
 
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-window.opener.SimpleTest.waitForFocus(runTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window);
 
 function ok(aCondition, aMessage) {
-  window.opener.SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage) {
-  window.opener.SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function onUnload() {
-  window.opener.onFinish();
+  window.opener.wrappedJSObject.onFinish();
 }
 
 var gFocusObservingElement = null;
 var gBlurObservingElement = null;
 
 function onFocus(aEvent) {
   if (aEvent.target != gFocusObservingElement) {
     return;
--- a/widget/tests/window_mouse_scroll_win.html
+++ b/widget/tests/window_mouse_scroll_win.html
@@ -9,17 +9,17 @@
 </head>
 <body onunload="onUnload();">
 <div id="display" style="width: 5000px; height: 5000px;">
 <p id="p1" style="font-size: 16px; width: 100px; height: 100px;">1st &lt;p&gt;.</p>
 <p id="p2" style="font-size: 32px; width: 100px; height: 100px;">2nd &lt;p&gt;.</p>
 </div>
 <script class="testbody" type="application/javascript">
 
-window.arguments[0].SimpleTest.waitForFocus(prepareTests, window);
+window.opener.wrappedJSObject.SimpleTest.waitForFocus(prepareTests, window);
 
 const nsIDOMWindowUtils = Ci.nsIDOMWindowUtils;
 
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const WHEEL_PAGESCROLL = 4294967295;
 
 const WM_VSCROLL     = 0x0115;
@@ -78,29 +78,29 @@ var gPageHeight = 0;
 var gPageWidth  = 0;
 
 var gP1 = document.getElementById("p1");
 var gP2 = document.getElementById("p2");
 
 var gOtherWindow;
 
 function ok(aCondition, aMessage) {
-  window.arguments[0].SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage) {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage) {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 function todo_is(aLeft, aRight, aMessage) {
-  window.arguments[0].SimpleTest.todo_is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.todo_is(aLeft, aRight, aMessage);
 }
 
 function onUnload() {
   SpecialPowers.clearUserPref(kAltKeyActionPref);
   SpecialPowers.clearUserPref(kCtrlKeyActionPref);
   SpecialPowers.clearUserPref(kShiftKeyActionPref);
   SpecialPowers.clearUserPref(kWinKeyActionPref);
 
@@ -113,17 +113,17 @@ function onUnload() {
   SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierXPref);
   SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref);
 
   SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref);
   SpecialPowers.clearUserPref(kEmulateWheelByWMSCROLLPref);
   SpecialPowers.clearUserPref(kVAmountPref);
   SpecialPowers.clearUserPref(kHAmountPref);
   SpecialPowers.clearUserPref(kTimeoutPref);
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
 function getWindowUtils(aWindow) {
   if (!aWindow) {
     aWindow = window;
   }
   return aWindow.windowUtils;
 }
@@ -1366,17 +1366,17 @@ var gDeactiveWindowTests = [
     },
   },
 ];
 
 function runDeactiveWindowTests() {
   gOtherWindow = window.open("data:text/html,", "_blank",
                              "chrome,width=100,height=100,top=700,left=700");
 
-  window.arguments[0].SimpleTest.waitForFocus(function() {
+  window.opener.wrappedJSObject.SimpleTest.waitForFocus(function() {
     runNextTest(gDeactiveWindowTests, 0);
   }, gOtherWindow);
 }
 
 function runNextTest(aTests, aIndex) {
   if (aIndex > 0 && aTests[aIndex - 1] && aTests[aIndex - 1].finish) {
     aTests[aIndex - 1].finish();
   }
--- a/widget/tests/window_wheeltransaction.xul
+++ b/widget/tests/window_wheeltransaction.xul
@@ -70,27 +70,27 @@ Text. Text. Text. Text. Text. Text. Text
 </pre>
 </body>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 function ok(aCondition, aMessage)
 {
-  window.arguments[0].SimpleTest.ok(aCondition, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
 }
 
 function is(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.is(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
 }
 
 function isnot(aLeft, aRight, aMessage)
 {
-  window.arguments[0].SimpleTest.isnot(aLeft, aRight, aMessage);
+  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
 }
 
 var gCurrentTestListStatus = { nextListIndex: 0 };
 var gCurrentTest;
 
 const kListenEvent_None                 = 0;
 const kListenEvent_OnScroll             = 1;
 const kListenEvent_OnScrollFailed       = 2;
@@ -184,17 +184,17 @@ async function onload()
 
 function onunload()
 {
   resetTimeoutPrefs();
   gPrefSvc.clearUserPref(kPrefSmoothScroll);
   gPrefSvc.clearUserPref(kPrefTestEventsAsyncEnabled);
   disableNonTestMouseEvents(false);
   SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
-  window.arguments[0].SimpleTest.finish();
+  window.opener.wrappedJSObject.SimpleTest.finish();
 }
 
 const kSubView1Offset = { x: 20, y: 20 };
 const kSubView2Offset = { x: 20, y: 20 + 100 + 20 };
 const kSubView3Offset = { x: 20, y: 20 + (100 + 20) * 2 };
 
 function _getSubViewTestPtForV(aPt)
 {