Backed out changeset 523ff2753dea (bug 1490257) for causing Bug 1503757 a=backout
authorGurzau Raul <rgurzau@mozilla.com>
Thu, 01 Nov 2018 15:27:30 +0200
changeset 500335 a0aeeebfeb681cfbd36250cb4477252d34cddc2c
parent 500334 3cff4bff1c9d8e65e73a966fe09c4e5aa1ed734a
child 500336 182a1b088330a2d72310ae2561004d955571e236
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1490257, 1503757
milestone65.0a1
backs out523ff2753dea148b71a2fd4680df0825f18bf0a3
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 changeset 523ff2753dea (bug 1490257) for causing Bug 1503757 a=backout
accessible/tests/browser/events/browser_test_docload.js
browser/components/sessionstore/ContentRestore.jsm
browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
browser/extensions/webcompat-reporter/experimentalAPIs/tabExtras.js
devtools/server/actors/targets/webextension.js
docshell/base/nsDocShell.cpp
docshell/base/nsDocShellLoadState.cpp
docshell/base/nsDocShellTreeOwner.cpp
docshell/test/unit/test_setUsePrivateBrowsing.js
dom/base/MessageBroadcaster.h
dom/base/test/chrome/test_bug430050.xul
dom/base/test/chrome/test_chromeOuterWindowID.xul
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
gfx/tests/browser/browser_windowless_troubleshoot_crash.js
js/xpconnect/tests/chrome/file_bug618176.xul
layout/tools/reftest/reftest-content.js
mobile/android/chrome/content/browser.js
testing/mochitest/browser-test.js
toolkit/components/browser/nsWebBrowser.cpp
toolkit/components/extensions/test/xpcshell/test_WebExtensionContentScript.js
toolkit/components/gfx/content/gfxFrameScript.js
toolkit/components/remotebrowserutils/RemoteWebNavigation.js
toolkit/components/thumbnails/BackgroundPageThumbs.jsm
toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
toolkit/components/windowwatcher/nsWindowWatcher.cpp
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/bug409624_window.xul
toolkit/content/tests/chrome/bug429723_window.xul
toolkit/content/tests/chrome/bug451540_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/modules/HiddenFrame.jsm
widget/tests/test_bug428405.xul
--- a/accessible/tests/browser/events/browser_test_docload.js
+++ b/accessible/tests/browser/events/browser_test_docload.js
@@ -36,30 +36,30 @@ async function runTests(browser, accDoc)
       [EVENT_REORDER, getAccessible(browser)],
       [EVENT_DOCUMENT_LOAD_COMPLETE, "body2"],
       [EVENT_STATE_CHANGE, busyChecker(false)]],
     unexpected: [
       [EVENT_DOCUMENT_LOAD_COMPLETE, inIframeChecker("iframe1")],
       [EVENT_STATE_CHANGE, inIframeChecker("iframe1")]]
   });
 
-  BrowserTestUtils.loadURI(browser, `data:text/html;charset=utf-8,
+  browser.loadURI(`data:text/html;charset=utf-8,
     <html><body id="body2">
       <iframe id="iframe1" src="http://example.com"></iframe>
     </body></html>`);
 
   await onLoadEvents;
 
   onLoadEvents = waitForEvents([
       [EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("about:about")],
       [EVENT_STATE_CHANGE, busyChecker(false)],
       [EVENT_REORDER, getAccessible(browser)]
   ]);
 
-  BrowserTestUtils.loadURI(browser, "about:about");
+  browser.loadURI("about:about");
 
   await onLoadEvents;
 
   onLoadEvents = waitForEvents([
     [EVENT_DOCUMENT_RELOAD, evt => evt.isFromUserInput],
     [EVENT_REORDER, getAccessible(browser)],
     [EVENT_STATE_CHANGE, busyChecker(false)]
   ]);
@@ -69,17 +69,17 @@ async function runTests(browser, accDoc)
   await onLoadEvents;
 
   onLoadEvents = waitForEvents([
     [EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("about:mozilla")],
     [EVENT_STATE_CHANGE, busyChecker(false)],
     [EVENT_REORDER, getAccessible(browser)]
   ]);
 
-  BrowserTestUtils.loadURI(browser, "about:mozilla");
+  browser.loadURI("about:mozilla");
 
   await onLoadEvents;
 
   onLoadEvents = waitForEvents([
     [EVENT_DOCUMENT_RELOAD, evt => !evt.isFromUserInput],
     [EVENT_REORDER, getAccessible(browser)],
     [EVENT_STATE_CHANGE, busyChecker(false)]
   ]);
@@ -89,27 +89,27 @@ async function runTests(browser, accDoc)
   await onLoadEvents;
 
   onLoadEvents = waitForEvents([
     [EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("http://www.wronguri.wronguri/")],
     [EVENT_STATE_CHANGE, busyChecker(false)],
     [EVENT_REORDER, getAccessible(browser)]
   ]);
 
-  BrowserTestUtils.loadURI(browser, "http://www.wronguri.wronguri/");
+  browser.loadURI("http://www.wronguri.wronguri/");
 
   await onLoadEvents;
 
   onLoadEvents = waitForEvents([
     [EVENT_DOCUMENT_LOAD_COMPLETE, urlChecker("https://nocert.example.com/")],
     [EVENT_STATE_CHANGE, busyChecker(false)],
     [EVENT_REORDER, getAccessible(browser)]
   ]);
 
-  BrowserTestUtils.loadURI(browser, "https://nocert.example.com:443/");
+  browser.loadURI("https://nocert.example.com:443/");
 
   await onLoadEvents;
 }
 
 /**
  * Test caching of accessible object states
  */
 addAccessibleTask("", runTests);
--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -194,17 +194,17 @@ ContentRestoreInternal.prototype = {
                        Services.io.newURI(loadArguments.referrer) : null;
         let referrerPolicy = ("referrerPolicy" in loadArguments
             ? loadArguments.referrerPolicy
             : Ci.nsIHttpChannel.REFERRER_POLICY_UNSET);
         let postData = loadArguments.postData ?
                        Utils.makeInputStream(loadArguments.postData) : null;
         let triggeringPrincipal = loadArguments.triggeringPrincipal
                                   ? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
-                                  : Services.scriptSecurityManager.createNullPrincipal({});
+                                  : null;
 
         if (loadArguments.userContextId) {
           webNavigation.setOriginAttributesBeforeLoading({ userContextId: loadArguments.userContextId });
         }
 
         webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
                                          referrer, referrerPolicy, postData,
                                          null, null, triggeringPrincipal);
--- a/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
+++ b/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
@@ -38,18 +38,17 @@ add_task(async function contentToChromeN
     is(sh.count, 1);
     is(sh.legacySHistory.getEntryAtIndex(0).docshellID.toString(), docshell.historyID.toString());
   });
 
   // Force the browser to navigate to the chrome process.
   await ContentTask.spawn(tab.linkedBrowser, null, function() {
     const CHROME_URL = "about:config";
     let webnav = content.window.getInterface(Ci.nsIWebNavigation);
-    let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-    webnav.loadURI(CHROME_URL, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null, systemPrincipal);
+    webnav.loadURI(CHROME_URL, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
   });
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   // Check to be sure that we're in the chrome process.
   let docShell = tab.linkedBrowser.frameLoader.docShell;
 
   // 'cause we're in the chrome process, we can just directly poke at the shistory.
   let sh = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
--- a/browser/extensions/webcompat-reporter/experimentalAPIs/tabExtras.js
+++ b/browser/extensions/webcompat-reporter/experimentalAPIs/tabExtras.js
@@ -125,19 +125,18 @@ this.tabExtras = class extends Extension
                     browser === tab.browser &&
                     locationURI.spec === url) {
                   windowTracker.removeListener("progress", listener);
                   resolve();
                 }
               },
             };
             windowTracker.addListener("progress", listener);
-            let triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
             tab.browser.webNavigation.loadURIWithOptions(url, null, null, null,
-                                                         post, null, null, triggeringPrincipal);
+                                                         post, null, null, null);
           });
         },
         async getWebcompatInfo(tabId) {
           return new Promise(resolve => {
             const messageName = "WebExtension:GetWebcompatInfo";
             const code = `${getInfoFrameScript.toString()};getInfoFrameScript("${messageName}")`;
             const mm = tabManager.get(tabId).browser.messageManager;
             mm.loadFrameScript(`data:,${encodeURI(code)}`, false);
--- a/devtools/server/actors/targets/webextension.js
+++ b/devtools/server/actors/targets/webextension.js
@@ -169,20 +169,19 @@ webExtensionTargetPrototype._createFallb
   this.fallbackWindow = this.fallbackWebNav.document.defaultView;
 
   // Insert the fallback doc message.
   this.fallbackWindow.document.body.innerText = FALLBACK_DOC_MESSAGE;
 };
 
 webExtensionTargetPrototype._destroyFallbackWindow = function() {
   if (this.fallbackWebNav) {
-    const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
     // Explicitly close the fallback windowless browser to prevent it to leak
     // (and to prevent it to freeze devtools xpcshell tests).
-    this.fallbackWebNav.loadURI("about:blank", 0, null, null, null, systemPrincipal);
+    this.fallbackWebNav.loadURI("about:blank", 0, null, null, null);
     this.fallbackWebNav.close();
 
     this.fallbackWebNav = null;
     this.fallbackWindow = null;
   }
 };
 
 // Discovery an extension page to use as a default target window.
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4096,19 +4096,16 @@ nsDocShell::GotoIndex(int32_t aIndex)
 NS_IMETHODIMP
 nsDocShell::LoadURI(const nsAString& aURI,
                     uint32_t aLoadFlags,
                     nsIURI* aReferringURI,
                     nsIInputStream* aPostStream,
                     nsIInputStream* aHeaderStream,
                     nsIPrincipal* aTriggeringPrincipal)
 {
-#ifndef ANDROID
-  MOZ_ASSERT(aTriggeringPrincipal, "LoadURI: Need a valid triggeringPrincipal");
-#endif
   return LoadURIWithOptions(aURI, aLoadFlags, aReferringURI,
                             RP_Unset, aPostStream,
                             aHeaderStream, nullptr, aTriggeringPrincipal);
 }
 
 NS_IMETHODIMP
 nsDocShell::LoadURIWithOptions(const nsAString& aURI,
                                uint32_t aLoadFlags,
@@ -4134,21 +4131,16 @@ nsDocShell::LoadURIWithOptions(const nsA
 
   NS_ConvertUTF16toUTF8 uriString(aURI);
   // Cleanup the empty spaces that might be on each end.
   uriString.Trim(" ");
   // Eliminate embedded newlines, which single-line text fields now allow:
   uriString.StripCRLF();
   NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
 
-#ifndef ANDROID
-  MOZ_ASSERT(aTriggeringPrincipal, "LoadURIWithOptions: Need a valid triggeringPrincipal");
-#endif
-
-
   rv = NS_NewURI(getter_AddRefs(uri), uriString);
   if (uri) {
     aLoadFlags &= ~LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
   }
 
   nsCOMPtr<nsIURIFixupInfo> fixupInfo;
   if (sURIFixup) {
     // Call the fixup object.  This will clobber the rv from NS_NewURI
@@ -9034,19 +9026,16 @@ public:
     , mSourceDocShell(aSourceDocShell)
     , mBaseURI(aBaseURI)
   {
   }
 
   NS_IMETHOD
   Run() override
   {
-#ifndef ANDROID
-    MOZ_ASSERT(mTriggeringPrincipal, "InternalLoadEvent: Should always have a principal here");
-#endif
     return mDocShell->InternalLoad(mURI, mOriginalURI, mResultPrincipalURI,
                                    mKeepResultPrincipalURIIfSet,
                                    mLoadReplace,
                                    mReferrer,
                                    mReferrerPolicy,
                                    mTriggeringPrincipal, mPrincipalToInherit,
                                    mFlags, EmptyString(),
                                    mTypeHint,
@@ -13113,19 +13102,16 @@ nsDocShell::OnLinkClick(nsIContent* aCon
                         const char16_t* aTargetSpec,
                         const nsAString& aFileName,
                         nsIInputStream* aPostDataStream,
                         nsIInputStream* aHeadersDataStream,
                         bool aIsUserTriggered,
                         bool aIsTrusted,
                         nsIPrincipal* aTriggeringPrincipal)
 {
-#ifndef ANDROID
-  MOZ_ASSERT(aTriggeringPrincipal, "Need a valid triggeringPrincipal");
-#endif
   NS_ASSERTION(NS_IsMainThread(), "wrong thread");
 
   if (!IsNavigationAllowed() || !IsOKToLoadURI(aURI)) {
     return NS_OK;
   }
 
   // On history navigation through Back/Forward buttons, don't execute
   // automatic JavaScript redirection such as |anchorElement.click()| or
--- a/docshell/base/nsDocShellLoadState.cpp
+++ b/docshell/base/nsDocShellLoadState.cpp
@@ -490,19 +490,16 @@ nsDocShellLoadState::SetupTriggeringPrin
     if (mReferrer) {
       mTriggeringPrincipal =
         BasePrincipal::CreateCodebasePrincipal(mReferrer, aOriginAttributes);
 
       if (!mTriggeringPrincipal) {
         return NS_ERROR_FAILURE;
       }
     } else {
-#ifndef ANDROID
-      MOZ_ASSERT(false, "LoadURI: System principal required.");
-#endif
       mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
     }
   }
   return NS_OK;
 }
 
 void
 nsDocShellLoadState::CalculateDocShellInternalLoadFlags()
--- a/docshell/base/nsDocShellTreeOwner.cpp
+++ b/docshell/base/nsDocShellTreeOwner.cpp
@@ -973,19 +973,16 @@ nsDocShellTreeOwner::HandleEvent(Event* 
               }
               free(links);
               return rv;
             }
           }
           nsAutoString url;
           if (NS_SUCCEEDED(links[0]->GetUrl(url))) {
             if (!url.IsEmpty()) {
-#ifndef ANDROID
-              MOZ_ASSERT(triggeringPrincipal, "nsDocShellTreeOwner::HandleEvent: Need a valid triggeringPrincipal");
-#endif
               webnav->LoadURI(url, 0, nullptr, nullptr, nullptr,
                               triggeringPrincipal);
             }
           }
 
           for (uint32_t i = 0; i < linksCount; i++) {
             NS_RELEASE(links[i]);
           }
--- a/docshell/test/unit/test_setUsePrivateBrowsing.js
+++ b/docshell/test/unit/test_setUsePrivateBrowsing.js
@@ -29,18 +29,17 @@ add_task(async function() {
         "Should be able to change origin attributes prior to a document load");
 
   oa.privateBrowsingId = 0;
   docShell.setOriginAttributes(oa);
 
   equal(loadContext.usePrivateBrowsing, false,
         "Should be able to change origin attributes prior to a document load");
 
-  let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-  webNav.loadURI("data:text/html,", webNav.LOAD_FLAGS_NONE, null, null, null, systemPrincipal);
+  webNav.loadURI("data:text/html,", webNav.LOAD_FLAGS_NONE, null, null, null);
 
   // Return to the event loop so the load can begin.
   await new Promise(executeSoon);
 
   // This causes a failed assertion rather than an exception on debug
   // builds.
   if (!AppConstants.DEBUG) {
     Assert.throws(() => { loadContext.usePrivateBrowsing = true; },
--- a/dom/base/MessageBroadcaster.h
+++ b/dom/base/MessageBroadcaster.h
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_MessageBroadcaster_h
 #define mozilla_dom_MessageBroadcaster_h
 
 #include "mozilla/dom/MessageListenerManager.h"
-#include "nsContentUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 /**
  * Implementation for the WebIDL MessageBroadcaster interface. Base class for window and
  * process broadcaster message managers.
  */
--- a/dom/base/test/chrome/test_bug430050.xul
+++ b/dom/base/test/chrome/test_bug430050.xul
@@ -28,20 +28,19 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   function startTest() {
     document.documentElement.addEventListener('DOMAttrModified',
       function(evt) {
         if (evt.target == evt.currentTarget) {
           document.getElementById('b').setAttribute("src",
                                                     "data:text/plain,failed");
-          const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-          document.getElementById('b').loadURI('data:text/plain,succeeded', {
-            triggeringPrincipal: systemPrincipal
-          });
+          document.getElementById('b').loadURI('data:text/plain,succeeded',
+                                               null,
+                                               'UTF-8');
           document.getElementById('b').addEventListener("load", endTest);
         }
       }, true);
     document.documentElement.setAttribute("foo", "bar");
   }
   
   SimpleTest.waitForExplicitFinish();
   addLoadEvent(startTest);
--- a/dom/base/test/chrome/test_chromeOuterWindowID.xul
+++ b/dom/base/test/chrome/test_chromeOuterWindowID.xul
@@ -78,19 +78,19 @@ windows.
     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);
 
-    BrowserTestUtils.loadURI(remote, page);
+    remote.loadURI(page);
     await BrowserTestUtils.browserLoaded(remote);
-    BrowserTestUtils.loadURI(nonRemote, page);
+    nonRemote.loadURI(page);
     await BrowserTestUtils.browserLoaded(nonRemote);
 
     let result = {};
     result["win" + num] = win;
     result["remote" + num] = remote;
     result["nonRemote" + num] = nonRemote;
     return result;
   }
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -45,17 +45,16 @@ using mozilla::DefaultXDisplay;
 #include "nsIScrollableFrame.h"
 #include "nsIDocShell.h"
 #include "ImageContainer.h"
 #include "GLContext.h"
 #include "EGLUtils.h"
 #include "nsIContentInlines.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/NullPrincipal.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/DragEvent.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/HTMLObjectElementBinding.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/WheelEventBinding.h"
 #include "nsFrameSelection.h"
@@ -478,18 +477,16 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
   // that security check succeeds. Please note that we do not want to
   // fall back to using the systemPrincipal, because that would also
   // bypass ContentPolicy checks which should still be enforced.
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   if (!aDoCheckLoadURIChecks) {
     mozilla::OriginAttributes attrs =
       BasePrincipal::Cast(content->NodePrincipal())->OriginAttributesRef();
     triggeringPrincipal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
-  } else {
-    triggeringPrincipal = NullPrincipal::CreateWithInheritedAttributes(content->NodePrincipal());
   }
 
   rv = lh->OnLinkClick(content, uri, unitarget.get(), VoidString(),
                        aPostStream, headersDataStream,
                        /* isUserTriggered */ false,
                        /* isTrusted */ true, triggeringPrincipal);
 
   return rv;
--- a/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
+++ b/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
@@ -11,17 +11,16 @@
     </tabs>
     <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[
-    ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     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;
 
@@ -53,20 +52,20 @@
     var browser1 = document.getElementById('browser1');
     var browser2 = document.getElementById('browser2');
 
     var progressListener1, progressListener2;
 
     function setup() {
       progressListener1 = new ProgressListener();
       browser1.addProgressListener(progressListener1, nsIWebProgress.NOTIFY_STATE_WINDOW);
-      BrowserTestUtils.loadURI(browser1, kURI);
+      browser1.loadURI(kURI, null, null);
       progressListener2 = new ProgressListener();
       browser2.addProgressListener(progressListener2, nsIWebProgress.NOTIFY_STATE_WINDOW);
-      BrowserTestUtils.loadURI(browser2, kURI);
+      browser2.loadURI(kURI, null, null);
     }
 
     window.addEventListener("load", setup, false);
 
     var plugin1, plugin2;
 
     const kTimeout = 5000; // 5 seconds
     var paintGiveUp;
--- a/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
+++ b/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
@@ -13,18 +13,17 @@ add_task(async function test_windowlessB
           if (docShell === observedDocShell) {
             Services.obs.removeObserver(listener, "content-document-global-created");
             resolve();
           }
         }
     }
     Services.obs.addObserver(listener, "content-document-global-created");
   });
-  let triggeringPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
-  webNav.loadURI("about:blank", 0, null, null, null, triggeringPrincipal);
+  webNav.loadURI("about:blank", 0, null, null, null);
 
   await onLoaded;
 
   let winUtils = webNav.document.defaultView.windowUtils;
   try {
     is(winUtils.layerManagerType, "Basic", "windowless browser's layerManagerType should be 'Basic'");
   } catch (e) {
     // The windowless browser may not have a layermanager at all yet, and that's ok.
--- a/js/xpconnect/tests/chrome/file_bug618176.xul
+++ b/js/xpconnect/tests/chrome/file_bug618176.xul
@@ -25,20 +25,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
       messageManager.removeMessageListener("test", recvTest);
       finish();
     }
 
     function start() {
       messageManager.addMessageListener("test", recvTest);
       messageManager.loadFrameScript(FRAME_SCRIPT, true);
-      let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-      setTimeout(function () {
-        document.getElementById("browser").loadURI(TEST_PAGE, {triggeringPrincipal});
-      }, 0);
+      setTimeout(function () { document.getElementById("browser").loadURI(TEST_PAGE); }, 0);
     }
 
     function finish() {
       opener.setTimeout("done()", 0);
       window.close();
     }
 
   ]]></script>
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -1067,18 +1067,17 @@ function DoAssertionCheck()
         gAssertionCount = newAssertionCount;
     }
     SendAssertionCount(numAsserts);
 }
 
 function LoadURI(uri)
 {
     var flags = webNavigation().LOAD_FLAGS_NONE;
-    var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-    webNavigation().loadURI(uri, flags, null, null, null, systemPrincipal);
+    webNavigation().loadURI(uri, flags, null, null, null);
 }
 
 function LogWarning(str)
 {
     if (gVerbose) {
         sendSyncMessage("reftest:Log", { type: "warning", msg: str });
     } else {
         sendAsyncMessage("reftest:Log", { type: "warning", msg: str });
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3901,17 +3901,17 @@ Tab.prototype = {
     // not doing this means that we'd get some of the previously cached content.
     let flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE |
                 Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
     if (this.originalURI && !this.originalURI.equals(currentURI)) {
       // We were redirected; reload the original URL
       url = this.originalURI.spec;
     }
 
-    this.browser.docShell.loadURI(url, flags, null, null, null, this.browser.contentPrincipal);
+    this.browser.docShell.loadURI(url, flags, null, null, null);
   },
 
   destroy: function() {
     if (!this.browser)
       return;
 
     this.browser.removeProgressListener(this.filter);
     this.filter.removeProgressListener(this);
@@ -5070,24 +5070,17 @@ var ErrorPageEventHandler = {
                      Services.prefs.getBoolPref("browser.safebrowsing.allowOverride")) {
             if (sendTelemetry) {
               Telemetry.addData(probe, nsISecTel[bucketName + "IGNORE_WARNING"]);
             }
 
             // Allow users to override and continue through to the site,
             let webNav = BrowserApp.selectedBrowser.docShell.QueryInterface(Ci.nsIWebNavigation);
             let location = BrowserApp.selectedBrowser.contentWindow.location;
-            let attrs = {};
-            let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(BrowserApp.selectedBrowser);
-            if (isPrivate) {
-              attrs["privateBrowsingId"] = 1;
-            }
-
-            let triggeringPrincipal = nullServices.scriptSecurityManager.createNullPrincipal(attrs);
-            webNav.loadURI(location, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER, null, null, triggeringPrincipal);
+            webNav.loadURI(location, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER, null, null, null);
 
             // ....but add a notify bar as a reminder, so that they don't lose
             // track after, e.g., tab switching.
             NativeWindow.doorhanger.show(Strings.browser.GetStringFromName("safeBrowsingDoorhanger"), "safebrowsing-warning", [], BrowserApp.selectedTab.id);
           }
         }
         break;
       }
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -83,18 +83,17 @@ function testInit() {
       messageManager.removeMessageListener("chromeEvent", messageHandler);
       var url = m.json.data;
 
       // Window is the [ChromeWindow] for messageManager, so we need content.window
       // Currently chrome tests are run in a content window instead of a ChromeWindow
       // eslint-disable-next-line no-undef
       var webNav = content.window.docShell
                           .QueryInterface(Ci.nsIWebNavigation);
-      var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-      webNav.loadURI(url, null, null, null, null, systemPrincipal);
+      webNav.loadURI(url, null, null, null, null);
     };
 
     var listener = 'data:,function doLoad(e) { var data=e.detail&&e.detail.data;removeEventListener("contentEvent", function (e) { doLoad(e); }, false, true);sendAsyncMessage("chromeEvent", {"data":data}); };addEventListener("contentEvent", function (e) { doLoad(e); }, false, true);';
     // eslint-disable-next-line no-undef
     messageManager.addMessageListener("chromeEvent", messageHandler);
     // eslint-disable-next-line no-undef
     messageManager.loadFrameScript(listener, true);
   }
--- a/toolkit/components/browser/nsWebBrowser.cpp
+++ b/toolkit/components/browser/nsWebBrowser.cpp
@@ -507,19 +507,16 @@ NS_IMETHODIMP
 nsWebBrowser::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
                                  nsIURI* aReferringURI,
                                  uint32_t aReferrerPolicy,
                                  nsIInputStream* aPostDataStream,
                                  nsIInputStream* aExtraHeaderStream,
                                  nsIURI* aBaseURI,
                                  nsIPrincipal* aTriggeringPrincipal)
 {
-#ifndef ANDROID
-  MOZ_ASSERT(aTriggeringPrincipal, "nsWebBrowser::LoadURIWithOptions - Need a valid triggeringPrincipal");
-#endif
   NS_ENSURE_STATE(mDocShell);
 
   return mDocShellAsNav->LoadURIWithOptions(
     aURI, aLoadFlags, aReferringURI, aReferrerPolicy, aPostDataStream,
     aExtraHeaderStream, aBaseURI, aTriggeringPrincipal);
 }
 
 NS_IMETHODIMP
@@ -531,19 +528,16 @@ nsWebBrowser::SetOriginAttributesBeforeL
 
 NS_IMETHODIMP
 nsWebBrowser::LoadURI(const nsAString& aURI, uint32_t aLoadFlags,
                       nsIURI* aReferringURI,
                       nsIInputStream* aPostDataStream,
                       nsIInputStream* aExtraHeaderStream,
                       nsIPrincipal* aTriggeringPrincipal)
 {
-#ifndef ANDROID
-  MOZ_ASSERT(aTriggeringPrincipal, "nsWebBrowser::LoadURI - Need a valid triggeringPrincipal");
-#endif
   NS_ENSURE_STATE(mDocShell);
 
   return mDocShellAsNav->LoadURI(aURI, aLoadFlags, aReferringURI,
                                  aPostDataStream, aExtraHeaderStream,
                                  aTriggeringPrincipal);
 }
 
 NS_IMETHODIMP
--- a/toolkit/components/extensions/test/xpcshell/test_WebExtensionContentScript.js
+++ b/toolkit/components/extensions/test/xpcshell/test_WebExtensionContentScript.js
@@ -62,18 +62,17 @@ async function loadURL(url, {frameCount}
       resolveLoad();
     }
   }
 
   Services.obs.addObserver(requestObserver, "http-on-examine-response");
   Services.obs.addObserver(loadObserver, "content-document-global-created");
 
   let webNav = Services.appShell.createWindowlessBrowser(false);
-  let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-  webNav.loadURI(url, 0, null, null, null, systemPrincipal);
+  webNav.loadURI(url, 0, null, null, null);
 
   await loadPromise;
 
   Services.obs.removeObserver(requestObserver, "http-on-examine-response");
   Services.obs.removeObserver(loadObserver, "content-document-global-created");
 
   return {webNav, windows, requests};
 }
--- a/toolkit/components/gfx/content/gfxFrameScript.js
+++ b/toolkit/components/gfx/content/gfxFrameScript.js
@@ -1,28 +1,26 @@
 /* eslint-env mozilla/frame-script */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const gfxFrameScript = {
   domUtils: null,
 
   init() {
     let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
     let webProgress =  docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                        .getInterface(Ci.nsIWebProgress);
     webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
 
     this.domUtils = content.windowUtils;
 
-    let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
     webNav.loadURI("chrome://gfxsanity/content/sanitytest.html",
                    Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                   null, null, null, triggeringPrincipal);
+                   null, null, null);
 
   },
 
   handleEvent(aEvent) {
     switch (aEvent.type) {
       case "MozAfterPaint":
         sendAsyncMessage("gfxSanity:ContentLoaded");
         removeEventListener("MozAfterPaint", this);
--- a/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
@@ -131,19 +131,17 @@ RemoteWebNavigation.prototype = {
   get currentURI() {
     if (!this._currentURI) {
       this._currentURI = makeURI("about:blank");
     }
 
     return this._currentURI;
   },
   set currentURI(aURI) {
-    // Bug 1498600 verify usages of systemPrincipal here
-    let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-    this.loadURI(aURI.spec, null, null, null, systemPrincipal);
+    this.loadURI(aURI.spec, null, null, null);
   },
 
   referringURI: null,
 
   // Bug 1233803 - accessing the sessionHistory of remote browsers should be
   // done in content scripts.
   get sessionHistory() {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -203,34 +203,22 @@ const BackgroundPageThumbs = {
         webProgress.removeProgressListener(this._listener);
         delete this._listener;
         // Get the window reference via the document.
         this._parentWin = wlBrowser.document.defaultView;
         this._processCaptureQueue();
       }
     };
     webProgress.addProgressListener(this._listener, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
-    let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-    wlBrowser.loadURI("chrome://global/content/backgroundPageThumbs.xhtml",
-                      0, null, null, null, triggeringPrincipal);
+    wlBrowser.loadURI("chrome://global/content/backgroundPageThumbs.xhtml", 0, null, null, null);
     this._windowlessContainer = wlBrowser;
 
     return false;
   },
 
-  get userContextId() {
-    if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) {
-      // Use the private container for thumbnails.
-      let privateIdentity =
-        ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail");
-      return privateIdentity.userContextId;
-    }
-    return 0;
-  },
-
   _init() {
     Services.prefs.addObserver(ABOUT_NEWTAB_SEGREGATION_PREF, this);
     Services.obs.addObserver(this, "profile-before-change");
   },
 
   observe(subject, topic, data) {
     if (topic == "profile-before-change") {
       this._destroy();
@@ -265,17 +253,23 @@ const BackgroundPageThumbs = {
 
     this._destroyBrowser();
     this._renewThumbBrowser = false;
 
     let browser = this._parentWin.document.createXULElement("browser");
     browser.setAttribute("type", "content");
     browser.setAttribute("remote", "true");
     browser.setAttribute("disableglobalhistory", "true");
-    browser.setAttribute("usercontextid", this.userContextId);
+
+    if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) {
+      // Use the private container for thumbnails.
+      let privateIdentity =
+        ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail");
+      browser.setAttribute("usercontextid", privateIdentity.userContextId);
+    }
 
     // Size the browser.  Make its aspect ratio the same as the canvases' that
     // the thumbnails are drawn into; the canvases' aspect ratio is the same as
     // the screen's, so use that.  Aim for a size in the ballpark of 1024x768.
     let [swidth, sheight] = [{}, {}];
     Cc["@mozilla.org/gfx/screenmanager;1"].
       getService(Ci.nsIScreenManager).
       primaryScreen.
@@ -509,18 +503,20 @@ Capture.prototype = {
           callback.call(options, this.url, this.doneReason);
         } catch (err) {
           Cu.reportError(err);
         }
       }
 
       if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) {
         // Clear the data in the private container for thumbnails.
+        let privateIdentity =
+          ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail");
         Services.obs.notifyObservers(null, "clear-origin-attributes-data",
-          JSON.stringify({ userContextId: this.userContextId }));
+          JSON.stringify({ userContextId: privateIdentity.userContextId }));
       }
     };
 
     if (!data) {
       done();
       return;
     }
 
--- a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
+++ b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
@@ -95,21 +95,19 @@ const backgroundPageThumbsContent = {
     if (!this._nextCapture)
       return;
     this._currentCapture = this._nextCapture;
     delete this._nextCapture;
     this._state = STATE_LOADING;
     this._currentCapture.pageLoadStartDate = new Date();
 
     try {
-      // Bug 1498603 verify usages of systemPrincipal here
-      let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
       this._webNav.loadURI(this._currentCapture.url,
                            Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT,
-                           null, null, null, triggeringPrincipal);
+                           null, null, null);
     } catch (e) {
       this._failCurrentCapture("BAD_URI");
     }
   },
 
   onStateChange(webProgress, req, flags, status) {
     if (webProgress.isTopLevel &&
         (flags & Ci.nsIWebProgressListener.STATE_STOP) &&
@@ -219,20 +217,19 @@ const backgroundPageThumbsContent = {
   // We load about:blank to finish all captures, even canceled captures.  Two
   // reasons: GC the captured page, and ensure it can't possibly load any more
   // resources.
   _loadAboutBlank: function _loadAboutBlank() {
     // It's possible we've been destroyed by now, if so don't do anything:
     if (!docShell) {
       return;
     }
-    let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
     this._webNav.loadURI("about:blank",
                          Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT,
-                         null, null, null, triggeringPrincipal);
+                         null, null, null);
   },
 
   QueryInterface: ChromeUtils.generateQI([
     Ci.nsIWebProgressListener,
     Ci.nsISupportsWeakReference,
     Ci.nsIObserver,
   ]),
 };
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -55,17 +55,16 @@
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsContentUtils.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsSandboxFlags.h"
 #include "nsSimpleEnumerator.h"
 #include "mozilla/CheckedInt.h"
-#include "mozilla/NullPrincipal.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Storage.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/TabGroup.h"
 #include "nsIXULWindow.h"
@@ -1029,20 +1028,19 @@ nsWindowWatcher::OpenWindowInternal(mozI
 
   // Now we have to set the right opener principal on the new window.  Note
   // that we have to do this _before_ starting any URI loads, thanks to the
   // sync nature of javascript: loads.
   //
   // Note: The check for the current JSContext isn't necessarily sensical.
   // It's just designed to preserve old semantics during a mass-conversion
   // patch.
-  // Bug 1498605 verify usages of systemPrincipal here
   nsCOMPtr<nsIPrincipal> subjectPrincipal =
     nsContentUtils::GetCurrentJSContext() ? nsContentUtils::SubjectPrincipal() :
-                                            nsContentUtils::GetSystemPrincipal();
+                                            nullptr;
 
   bool isPrivateBrowsingWindow = false;
 
   if (windowIsNew) {
     auto* docShell = static_cast<nsDocShell*>(newDocShell.get());
 
     // If this is not a chrome docShell, we apply originAttributes from the
     // subjectPrincipal unless if it's an expanded or system principal.
@@ -1122,19 +1120,16 @@ nsWindowWatcher::OpenWindowInternal(mozI
 
   RefPtr<nsDocShellLoadState> loadState = aLoadState;
   if (uriToLoad && aNavigate && !loadState) {
     loadState = new nsDocShellLoadState();
 
     if (subjectPrincipal) {
       loadState->SetTriggeringPrincipal(subjectPrincipal);
     }
-#ifndef ANDROID
-    MOZ_ASSERT(subjectPrincipal, "nsWindowWatcher: triggeringPrincipal required");
-#endif
 
     /* use the URL from the *extant* document, if any. The usual accessor
        GetDocument will synchronously create an about:blank document if
        it has no better answer, and we only care about a real document.
        Also using GetDocument to force document creation seems to
        screw up focus in the hidden window; see bug 36016.
     */
     nsCOMPtr<nsIDocument> doc = GetEntryDocument();
--- a/toolkit/content/tests/chrome/bug263683_window.xul
+++ b/toolkit/content/tests/chrome/bug263683_window.xul
@@ -51,17 +51,17 @@
       if (browserId.endsWith("remote") && AppConstants.isPlatformAndVersionAtMost("macosx", 11)) {
         return;
       }
 
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
       gFindBar.browser = gBrowser;
       let promise = BrowserTestUtils.browserLoaded(gBrowser);
-      BrowserTestUtils.loadURI(gBrowser, 'data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
+      gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
       await promise;
       await onDocumentLoaded();
     }
 
     function toggleHighlightAndWait(highlight) {
       return new Promise(resolve => {
         let listener = {
           onHighlightFinished: function() {
@@ -135,17 +135,17 @@
         let inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
 
         Assert.equal(inputSelection.rangeCount, 0, "Correctly removed the range");
       });
 
       // For posterity, test iframes too.
 
       promise = BrowserTestUtils.browserLoaded(gBrowser);
-      BrowserTestUtils.loadURI(gBrowser, 'data:text/html,<h2>Text mozilla</h2><iframe id="leframe" ' +
+      gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><iframe id="leframe" ' +
         'src="data:text/html,Text mozilla"></iframe>');
       await promise;
 
       await toggleHighlightAndWait(true);
 
       await ContentTask.spawn(gBrowser, { search }, async function(args) {
         function getSelection(docShell) {
           let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
--- a/toolkit/content/tests/chrome/bug304188_window.xul
+++ b/toolkit/content/tests/chrome/bug304188_window.xul
@@ -12,17 +12,16 @@
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         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[
-    ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     ChromeUtils.import("resource://testing-common/ContentTask.jsm");
     ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "info"];
     for (var name of imports) {
@@ -48,17 +47,17 @@ find-menu appears in editor element whic
       let promise = ContentTask.spawn(gBrowser, null, async function() {
         return new Promise(resolve => {
           addEventListener("DOMContentLoaded", function listener() {
             removeEventListener("DOMContentLoaded", listener);
             resolve();
           });
         });
       });
-      BrowserTestUtils.loadURI(gBrowser, "data:text/html;charset=utf-8,some%20random%20text");
+      gBrowser.loadURI("data:text/html;charset=utf-8,some%20random%20text");
       await promise;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       await ContentTask.spawn(gBrowser, null, async function() {
         var edsession = content.docShell.editingSession;
         edsession.makeWindowEditable(content, "html", false, true, false);
--- a/toolkit/content/tests/chrome/bug331215_window.xul
+++ b/toolkit/content/tests/chrome/bug331215_window.xul
@@ -42,17 +42,17 @@
       });
     }
 
     async function startTestWithBrowser(browserId) {
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
       gFindBar.browser = gBrowser;
       let promise = BrowserTestUtils.browserLoaded(gBrowser);
-      BrowserTestUtils.loadURI(gBrowser, "data:text/plain,latest");
+      gBrowser.loadURI("data:text/plain,latest");
       await promise;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       document.getElementById("cmd_find").doCommand();
       await promiseEnterStringIntoFindField("test");
       document.commandDispatcher
--- a/toolkit/content/tests/chrome/bug360437_window.xul
+++ b/toolkit/content/tests/chrome/bug360437_window.xul
@@ -13,17 +13,16 @@
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         onload="startTest();"
         title="360437 test">
 
   <script type="application/javascript"><![CDATA[
     ChromeUtils.import("resource://testing-common/ContentTask.jsm");
-    ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "ok", "is", "info"];
     for (var name of imports) {
       window[name] = window.opener.wrappedJSObject[name];
@@ -48,17 +47,17 @@
       let promise = ContentTask.spawn(gBrowser, null, async function() {
         return new Promise(resolve => {
           addEventListener("DOMContentLoaded", function listener() {
             removeEventListener("DOMContentLoaded", listener);
             resolve();
           });
         });
       });
-      BrowserTestUtils.loadURI(gBrowser, "data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>");
+      gBrowser.loadURI("data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>");
       await promise;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       gFindBar.onFindCommand();
 
       // Make sure the findfield is correctly focused on open
--- a/toolkit/content/tests/chrome/bug409624_window.xul
+++ b/toolkit/content/tests/chrome/bug409624_window.xul
@@ -11,17 +11,16 @@
         width="600"
         height="600"
         title="409624 test">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
   <script type="application/javascript"><![CDATA[
-    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.opener.wrappedJSObject[name];
     }
 
@@ -29,17 +28,17 @@
       window.close();
       SimpleTest.finish();
     }
 
     function startTest() {
       gFindBar = document.getElementById("FindToolbar");
       gBrowser = document.getElementById("content");
       gBrowser.addEventListener("pageshow", onPageShow, false);
-      BrowserTestUtils.loadURI(gBrowser, 'data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
+      gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
     }
 
     function onPageShow() {
       gBrowser.removeEventListener("pageshow", onPageShow, false);
       gFindBar.clear();
       let textbox = gFindBar.getElement("findbar-textbox");
 
       // Clear should work regardless of whether the editor has been lazily
--- a/toolkit/content/tests/chrome/bug429723_window.xul
+++ b/toolkit/content/tests/chrome/bug429723_window.xul
@@ -9,17 +9,16 @@
 <window id="429723Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         onload="onLoad();"
         title="429723 test">
 
   <script type="application/javascript"><![CDATA[
-    ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     var gFindBar = null;
     var gBrowser;
 
     function ok(condition, message) {
       window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
     }
 
     function finish() {
@@ -27,17 +26,17 @@
       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>");
+        gBrowser.loadURI("data:text/html,<h2 id='h2'>mozilla</h2>");
       }
       setTimeout(_delayedOnLoad, 1000);
     }
 
     function enterStringIntoFindField(aString) {
       for (var i=0; i < aString.length; i++) {
         var event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
--- a/toolkit/content/tests/chrome/bug451540_window.xul
+++ b/toolkit/content/tests/chrome/bug451540_window.xul
@@ -38,17 +38,17 @@
     SimpleTest.requestLongerTimeout(2);
 
     function startTest() {
       gFindBar = document.getElementById("FindToolbar");
       gBrowser = document.getElementById("content");
       gBrowser.addEventListener("pageshow", onPageShow, false);
       let data = `data:text/html,<input id="inp" type="text" />
                                  <textarea id="tarea"/>`;
-      BrowserTestUtils.loadURI(gBrowser, data);
+      gBrowser.loadURI(data);
     }
 
     function promiseHighlightFinished() {
       return new Promise(resolve => {
         let listener = {
           onHighlightFinished() {
             gFindBar.browser.finder.removeResultListener(listener);
             resolve();
--- a/toolkit/content/tests/chrome/findbar_entireword_window.xul
+++ b/toolkit/content/tests/chrome/findbar_entireword_window.xul
@@ -15,17 +15,16 @@
         title="findbar test - entire words only">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"/>
 
   <script type="application/javascript"><![CDATA[
-    ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
     ChromeUtils.import("resource://testing-common/ContentTask.jsm");
     ContentTask.setTestScope(window.opener.wrappedJSObject);
 
     var gFindBar = null;
     var gBrowser;
 
     var imports = ["SimpleTest", "SpecialPowers", "ok", "is", "isnot", "info"];
     for (var name of imports) {
@@ -128,17 +127,17 @@
       let promise = ContentTask.spawn(gBrowser, null, async function() {
         return new Promise(resolve => {
           addEventListener("DOMContentLoaded", function listener() {
             removeEventListener("DOMContentLoaded", listener);
             resolve();
           });
         });
       });
-      BrowserTestUtils.loadURI(gBrowser, kBaseURL + "/sample_entireword_" + testName + ".html");
+      gBrowser.loadURI(kBaseURL + "/sample_entireword_" + testName + ".html");
       await promise;
       await onDocumentLoaded(testName);
     }
 
     async function onDocumentLoaded(testName) {
       let suite = kTests[testName];
       await testSimpleEntireWord(suite.testSimpleEntireWord);
       await testCaseSensitive(suite.testCaseSensitive);
--- a/toolkit/content/tests/chrome/findbar_events_window.xul
+++ b/toolkit/content/tests/chrome/findbar_events_window.xul
@@ -43,17 +43,17 @@
       });
     }
 
     async function startTestWithBrowser(browserId) {
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
       gFindBar.browser = gBrowser;
       let promise = BrowserTestUtils.browserLoaded(gBrowser);
-      BrowserTestUtils.loadURI(gBrowser, "data:text/html,hello there");
+      gBrowser.loadURI("data:text/html,hello there");
       await promise;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       gFindBar.open();
       gFindBar.onFindCommand();
 
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -84,17 +84,17 @@
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
       gFindBar.browser = gBrowser;
 
       // Tests delays the loading of a document for one second.
       await new Promise(resolve => setTimeout(resolve, 1000));
 
       let promise = BrowserTestUtils.browserLoaded(gBrowser);
-      BrowserTestUtils.loadURI(gBrowser, "data:text/html,<h2 id='h2'>" + SEARCH_TEXT +
+      gBrowser.loadURI("data:text/html,<h2 id='h2'>" + SEARCH_TEXT +
         "</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2><input id='text' type='text' value='" +
         SAMPLE_TEXT + "'></input><input id='button' type='button'></input><img id='img' width='50' height='50'/>");
       await promise;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       await testNormalFind();
--- a/toolkit/modules/HiddenFrame.jsm
+++ b/toolkit/modules/HiddenFrame.jsm
@@ -100,14 +100,13 @@ HiddenFrame.prototype = {
         this._webProgress = null;
         // Get the window reference via the document.
         this._frame = this._browser.document.ownerGlobal;
         this._deferred.resolve(this._frame);
       }
     };
     this._webProgress.addProgressListener(this._listener, Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
     let docShell = this._browser.docShell;
-    let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
-    docShell.createAboutBlankContentViewer(systemPrincipal);
+    docShell.createAboutBlankContentViewer(Services.scriptSecurityManager.getSystemPrincipal());
     docShell.useGlobalHistory = false;
-    this._browser.loadURI(XUL_PAGE, 0, null, null, null, systemPrincipal);
+    this._browser.loadURI(XUL_PAGE, 0, null, null, null);
   },
 };
--- a/widget/tests/test_bug428405.xul
+++ b/widget/tests/test_bug428405.xul
@@ -18,17 +18,16 @@
     </tabs>
     <tabpanels flex="100%">
       <browser onload="configureFirstTab();" id="tab1browser" flex="100%"/>
       <browser onload="configureSecondTab();" id="tab2browser" flex="100%"/>
     </tabpanels>
   </tabbox>
 
   <script type="application/javascript"><![CDATA[
-    ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
 
     SimpleTest.waitForExplicitFinish();
 
     var gCmdOptYReceived = false;
 
     // Look for a cmd-opt-y event.
     function onKeyPress(aEvent) {
       gCmdOptYReceived = false;
@@ -52,17 +51,17 @@
       // it's a cmd-opt-y event.
       gChromeWindow.addEventListener("keypress", onKeyPress, false);
     }
 
     // 1) Start loading first tab.
     // 6) Start reloading first tab.
     function loadFirstTab() {
       var browser = document.getElementById("tab1browser");
-      BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,<body><h2>First Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
+      browser.loadURI("data:text/html;charset=utf-8,<body><h2>First Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
     }
 
     function configureFirstTab() {
       try {
         var button = document.getElementById("tab1browser").contentDocument.getElementById("button1");
         button.addEventListener("click", onFirstTabButtonClicked, false);
         button.focus();
         if (document.getElementById("tabbox").selectedIndex == 0) {
@@ -77,17 +76,17 @@
         }
       } catch(e) {
       }
     }
 
     // 8) Start loading second tab.
     function loadSecondTab() {
       var browser = document.getElementById("tab2browser");
-      BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,<body><h2>Second Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
+      browser.loadURI("data:text/html;charset=utf-8,<body><h2>Second Tab</h2><p><input type='submit' value='Button' id='button1'/></body>");
     }
 
     function configureSecondTab() {
       try {
         var button = document.getElementById("tab2browser").contentDocument.getElementById("button1");
         button.addEventListener("click", onSecondTabButtonClicked, false);
         button.focus();
         if (document.getElementById("tabbox").selectedIndex == 1) {