Bug 1513241: Update frontend consumers of loadURI and pass loadURIOptions dictionary. r=gijs
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Fri, 11 Jan 2019 12:44:20 +0100
changeset 510518 71cb45922e3474b96c93cf736299e4e8b2e2db34
parent 510517 6ae543902cdaaec070a77dd5f554db6b02fde2b1
child 510519 2a99e348fde3d1674296bb82c5f3881e696e8fb6
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs
bugs1513241
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1513241: Update frontend consumers of loadURI and pass loadURIOptions dictionary. r=gijs
browser/base/content/browser.js
browser/base/content/test/general/browser_e10s_switchbrowser.js
browser/components/sessionstore/ContentRestore.jsm
browser/components/sessionstore/test/browser_async_remove_tab.js
browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
browser/components/shell/HeadlessShell.jsm
browser/extensions/webcompat-reporter/experimentalAPIs/tabExtras.js
docshell/test/unit/test_setUsePrivateBrowsing.js
gfx/tests/browser/browser_windowless_troubleshoot_crash.js
layout/tools/reftest/reftest-content.js
mobile/android/chrome/content/aboutAccounts.js
mobile/android/chrome/content/browser.js
mobile/android/extensions/report-site-issue/experimentalAPIs/tabExtras.js
testing/mochitest/browser-test.js
toolkit/actors/WebNavigationChild.jsm
toolkit/components/extensions/ExtensionParent.jsm
toolkit/components/extensions/ExtensionXPCShellUtils.jsm
toolkit/components/extensions/test/xpcshell/test_WebExtensionContentScript.js
toolkit/components/gfx/content/gfxFrameScript.js
toolkit/components/reader/ReaderMode.jsm
toolkit/components/remotebrowserutils/RemoteWebNavigation.js
toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
toolkit/components/thumbnails/BackgroundPageThumbs.jsm
toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
toolkit/components/viewsource/content/viewSource-content.js
toolkit/content/widgets/browser-custom-element.js
toolkit/modules/HiddenFrame.jsm
widget/headless/tests/test_headless.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1058,28 +1058,32 @@ function _loadURI(browser, uri, params =
     // to be a preloaded browser, clear the preloaded state now.
     browser.removeAttribute("preloadedState");
   }
 
   // !requiredRemoteType means we're loading in the parent/this process.
   if (!requiredRemoteType) {
     browser.inLoadURI = true;
   }
+  let loadURIOptions = {
+    triggeringPrincipal,
+    loadFlags: flags,
+    referrerURI,
+    referrerPolicy,
+    postData,
+  };
   try {
     if (!mustChangeProcess) {
       if (userContextId) {
         browser.webNavigation.setOriginAttributesBeforeLoading({
           userContextId,
           privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(browser) ? 1 : 0,
         });
       }
-
-      browser.webNavigation.loadURIWithOptions(uri, flags,
-                                               referrerURI, referrerPolicy,
-                                               postData, null, null, triggeringPrincipal);
+      browser.webNavigation.loadURI(uri, loadURIOptions);
     } else {
       // Check if the current browser is allowed to unload.
       let {permitUnload, timedOut} = browser.permitUnload();
       if (!timedOut && !permitUnload) {
         return;
       }
 
       if (postData) {
@@ -1116,19 +1120,17 @@ function _loadURI(browser, uri, params =
       gBrowser.updateBrowserRemotenessByURL(browser, uri);
 
       if (userContextId) {
         browser.webNavigation.setOriginAttributesBeforeLoading({
           userContextId,
           privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(browser) ? 1 : 0,
         });
       }
-
-      browser.webNavigation.loadURIWithOptions(uri, flags, referrerURI, referrerPolicy,
-                                               postData, null, null, triggeringPrincipal);
+      browser.webNavigation.loadURI(uri, loadURIOptions);
     } else {
       throw e;
     }
   } finally {
     if (!requiredRemoteType) {
       browser.inLoadURI = false;
     }
   }
--- a/browser/base/content/test/general/browser_e10s_switchbrowser.js
+++ b/browser/base/content/test/general/browser_e10s_switchbrowser.js
@@ -58,19 +58,20 @@ function clear_history() {
   gExpectedHistory.index = -1;
   gExpectedHistory.entries = [];
 }
 
 // Waits for a load and updates the known history
 var waitForLoad = async function(uri) {
   info("Loading " + uri);
   // Longwinded but this ensures we don't just shortcut to LoadInNewProcess
-  gBrowser.selectedBrowser.webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                                 null, null, null,
-                                                 Services.scriptSecurityManager.getSystemPrincipal());
+  let loadURIOptions = {
+    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+  };
+  gBrowser.selectedBrowser.webNavigation.loadURI(uri, loadURIOptions);
 
   await BrowserTestUtils.browserStopped(gBrowser);
   gExpectedHistory.index++;
   gExpectedHistory.entries.push({
     uri: gBrowser.currentURI.spec,
     title: gBrowser.contentTitle,
   });
 };
--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -199,46 +199,52 @@ ContentRestoreInternal.prototype = {
                        Utils.makeInputStream(loadArguments.postData) : null;
         let triggeringPrincipal = loadArguments.triggeringPrincipal
                                   ? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
                                   : Services.scriptSecurityManager.createNullPrincipal({});
 
         if (loadArguments.userContextId) {
           webNavigation.setOriginAttributesBeforeLoading({ userContextId: loadArguments.userContextId });
         }
-
-        webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
-                                         referrer, referrerPolicy, postData,
-                                         null, null, triggeringPrincipal);
+        let loadURIOptions = {
+          triggeringPrincipal,
+          loadFlags: loadArguments.flags,
+          referrerURI: referrer,
+          referrerPolicy,
+          postData,
+        };
+        webNavigation.loadURI(loadArguments.uri, loadURIOptions);
       } else if (tabData.userTypedValue && tabData.userTypedClear) {
         // If the user typed a URL into the URL bar and hit enter right before
         // we crashed, we want to start loading that page again. A non-zero
         // userTypedClear value means that the load had started.
         // Load userTypedValue and fix up the URL if it's partial/broken.
-        webNavigation.loadURI(tabData.userTypedValue,
-                              Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP,
-                              null, null, null,
-                              Services.scriptSecurityManager.getSystemPrincipal());
+        let loadURIOptions = {
+          triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+          loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP,
+        };
+        webNavigation.loadURI(tabData.userTypedValue, loadURIOptions);
       } else if (tabData.entries.length) {
         // Stash away the data we need for restoreDocument.
         let activeIndex = tabData.index - 1;
         this._restoringDocument = {entry: tabData.entries[activeIndex] || {},
                                    formdata: tabData.formdata || {},
                                    scrollPositions: tabData.scroll || {}};
 
         // In order to work around certain issues in session history, we need to
         // force session history to update its internal index and call reload
         // instead of gotoIndex. See bug 597315.
         history.reloadCurrentEntry();
       } else {
         // If there's nothing to restore, we should still blank the page.
-        webNavigation.loadURI("about:blank",
-                              Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
-                              null, null, null,
-                              Services.scriptSecurityManager.getSystemPrincipal());
+        let loadURIOptions = {
+          triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+          loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
+        };
+        webNavigation.loadURI("about:blank", loadURIOptions);
       }
 
       return true;
     } catch (ex) {
       if (ex instanceof Ci.nsIException) {
         // Ignore page load errors, but return false to signal that the load never
         // happened.
         return false;
@@ -372,19 +378,21 @@ HistoryListener.prototype = {
     // would use the current document and change the displayed URL only.
     this.webNavigation.setCurrentURI(Services.io.newURI("about:blank"));
 
     // Kick off a new load so that we navigate away from about:blank to the
     // new URL that was passed to loadURI(). The new load will cause a
     // STATE_START notification to be sent and the ProgressListener will then
     // notify the parent and do the rest.
     let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
-    this.webNavigation.loadURI(newURI.spec, flags,
-                               null, null, null,
-                               Services.scriptSecurityManager.getSystemPrincipal());
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      loadFlags: flags,
+    };
+    this.webNavigation.loadURI(newURI.spec, loadURIOptions);
   },
 
   OnHistoryReload(reloadURI, reloadFlags) {
     this.callback();
 
     // Cancel the load.
     return false;
   },
--- a/browser/components/sessionstore/test/browser_async_remove_tab.js
+++ b/browser/components/sessionstore/test/browser_async_remove_tab.js
@@ -112,18 +112,17 @@ add_task(async function save_worthy_tabs
 
 add_task(async function save_worthy_tabs_remote_final() {
   let {tab, r} = await createTabWithRandomValue("about:blank");
   let browser = tab.linkedBrowser;
   ok(browser.isRemoteBrowser, "browser is remote");
 
   // Replace about:blank with a new remote page.
   let snippet = 'webNavigation.loadURI("https://example.com/",\
-                                       null, null, null, null,\
-                                       Services.scriptSecurityManager.getSystemPrincipal())';
+    {triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()})';
   await promiseNewLocationAndHistoryEntryReplaced(browser, snippet);
 
   // Remotness shouldn't have changed.
   ok(browser.isRemoteBrowser, "browser is still remote");
 
   // Remove the tab before the update arrives.
   let promise = promiseRemoveTabAndSessionState(tab);
 
--- a/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
+++ b/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
@@ -38,18 +38,20 @@ 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);
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
+    webnav.loadURI(CHROME_URL, loadURIOptions);
   });
   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/components/shell/HeadlessShell.jsm
+++ b/browser/components/shell/HeadlessShell.jsm
@@ -10,17 +10,20 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource://gre/modules/osfile.jsm");
 
 // Refrences to the progress listeners to keep them from being gc'ed
 // before they are called.
 const progressListeners = new Map();
 
 function loadContentWindow(webNavigation, uri, principal) {
   return new Promise((resolve, reject) => {
-    webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null, principal);
+    let loadURIOptions = {
+      triggeringPrincipal: principal,
+    };
+    webNavigation.loadURI(uri, loadURIOptions);
     let docShell = webNavigation.QueryInterface(Ci.nsIInterfaceRequestor)
                                 .getInterface(Ci.nsIDocShell);
     let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                               .getInterface(Ci.nsIWebProgress);
     let progressListener = {
       onLocationChange(progress, request, location, flags) {
         // Ignore inner-frame events
         if (progress != webProgress) {
--- a/browser/extensions/webcompat-reporter/experimentalAPIs/tabExtras.js
+++ b/browser/extensions/webcompat-reporter/experimentalAPIs/tabExtras.js
@@ -125,19 +125,22 @@ 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);
+
+            let loadURIOptions = {
+              triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
+              postData: post,
+            };
+            tab.browser.webNavigation.loadURI(url, loadURIOptions);
           });
         },
         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/docshell/test/unit/test_setUsePrivateBrowsing.js
+++ b/docshell/test/unit/test_setUsePrivateBrowsing.js
@@ -29,18 +29,20 @@ 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);
+  let loadURIOptions = {
+    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+  };
+  webNav.loadURI("data:text/html,", loadURIOptions);
 
   // 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/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
+++ b/gfx/tests/browser/browser_windowless_troubleshoot_crash.js
@@ -13,18 +13,20 @@ 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);
+  let loadURIOptions = {
+    triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
+  };
+  webNav.loadURI("about:blank", loadURIOptions);
 
   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/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -1075,19 +1075,20 @@ function DoAssertionCheck()
         numAsserts = newAssertionCount - gAssertionCount;
         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);
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
+    webNavigation().loadURI(uri, loadURIOptions);
 }
 
 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/aboutAccounts.js
+++ b/mobile/android/chrome/content/aboutAccounts.js
@@ -96,24 +96,32 @@ var wrapper = {
     docShell.QueryInterface(Ci.nsIWebProgress);
     docShell.addProgressListener(this.iframeListener,
                                  Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT |
                                  Ci.nsIWebProgress.NOTIFY_LOCATION);
 
     // Set the iframe's location with loadURI/LOAD_FLAGS_BYPASS_HISTORY to
     // avoid having a new history entry being added.
     let webNav = iframe.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation);
-    webNav.loadURI(url, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null);
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
+    };
+    webNav.loadURI(url, loadURIOptions);
   },
 
   retry: function() {
     deferTransitionToRemoteAfterLoaded();
 
     let webNav = this.iframe.frameLoader.docShell.QueryInterface(Ci.nsIWebNavigation);
-    webNav.loadURI(this.url, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY, null, null, null);
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
+    };
+    webNav.loadURI(this.url, loadURIOptions);
   },
 
   iframeListener: {
     QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]),
 
     onStateChange: function(aWebProgress, aRequest, aState, aStatus) {
       let failure = false;
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3899,18 +3899,21 @@ Tab.prototype = {
     // string, and servers typically don't use the Vary: User-Agent header, so
     // 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);
+    let loadURIOptions = {
+      triggeringPrincipal: this.browser.contentPrincipal,
+      loadFlags: flags,
+    };
+    this.browser.docShell.loadURI(url, loadURIOptions);
   },
 
   destroy: function() {
     if (!this.browser)
       return;
 
     this.browser.removeProgressListener(this.filter);
     this.filter.removeProgressListener(this);
@@ -5074,18 +5077,21 @@ var ErrorPageEventHandler = {
             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);
+            let loadURIOptions = {
+              triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(attrs),
+              loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
+            };
+            webNav.loadURI(location, loadURIOptions);
 
             // ....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/mobile/android/extensions/report-site-issue/experimentalAPIs/tabExtras.js
+++ b/mobile/android/extensions/report-site-issue/experimentalAPIs/tabExtras.js
@@ -159,18 +159,21 @@ this.tabExtras = class extends Extension
                     browser === tab.browser &&
                     locationURI.spec === url) {
                   windowTracker.removeListener("progress", listener);
                   resolve();
                 }
               },
             };
             windowTracker.addListener("progress", listener);
-            tab.browser.webNavigation.loadURIWithOptions(url, null, null, null,
-                                                         post, null, null, null);
+            let loadURIOptions = {
+              triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+              postData: post,
+            };
+            tab.browser.webNavigation.loadURI(url, loadURIOptions);
           });
         },
         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/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -83,18 +83,20 @@ 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);
+      let loadURIOptions = {
+        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      };
+      webNav.loadURI(url, loadURIOptions);
     };
 
     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/actors/WebNavigationChild.jsm
+++ b/toolkit/actors/WebNavigationChild.jsm
@@ -105,19 +105,27 @@ class WebNavigationChild extends ActorCh
       headers = Utils.makeInputStream(headers);
     if (baseURI)
       baseURI = Services.io.newURI(baseURI);
     if (triggeringPrincipal)
       triggeringPrincipal = Utils.deserializePrincipal(triggeringPrincipal);
     if (!triggeringPrincipal) {
       triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal({});
     }
+    let loadURIOptions = {
+      triggeringPrincipal,
+      loadFlags: flags,
+      referrerURI: referrer,
+      referrerPolicy,
+      postData,
+      headers,
+      baseURI,
+    };
     this._wrapURIChangeCall(() => {
-      return this.webNavigation.loadURIWithOptions(uri, flags, referrer, referrerPolicy,
-                                                   postData, headers, baseURI, triggeringPrincipal);
+      return this.webNavigation.loadURI(uri, loadURIOptions);
     });
   }
 
   setOriginAttributes(originAttributes) {
     if (originAttributes) {
       this.webNavigation.setOriginAttributesBeforeLoading(originAttributes);
     }
   }
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/extensions/ExtensionParent.jsm
@@ -1109,17 +1109,20 @@ class HiddenXULWindow {
       let attrs = this.chromeShell.getOriginAttributes();
       attrs.privateBrowsingId = 1;
       this.chromeShell.setOriginAttributes(attrs);
     }
 
     let system = Services.scriptSecurityManager.getSystemPrincipal();
     this.chromeShell.createAboutBlankContentViewer(system);
     this.chromeShell.useGlobalHistory = false;
-    this.chromeShell.loadURI("chrome://extensions/content/dummy.xul", 0, null, null, null, system);
+    let loadURIOptions = {
+      triggeringPrincipal: system,
+    };
+    this.chromeShell.loadURI("chrome://extensions/content/dummy.xul", loadURIOptions);
 
     await promiseObserved("chrome-document-global-created",
                           win => win.document == this.chromeShell.document);
     return promiseDocumentLoaded(windowlessBrowser.document);
   }
 
   /**
    * Creates the browser XUL element that will contain the WebExtension Page.
--- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
+++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm
@@ -133,17 +133,20 @@ class ContentPage {
 
     let system = Services.scriptSecurityManager.getSystemPrincipal();
 
     let chromeShell = this.windowlessBrowser.docShell
                           .QueryInterface(Ci.nsIWebNavigation);
 
     chromeShell.createAboutBlankContentViewer(system);
     chromeShell.useGlobalHistory = false;
-    chromeShell.loadURI("chrome://extensions/content/dummy.xul", 0, null, null, null, system);
+    let loadURIOptions = {
+      triggeringPrincipal: system,
+    };
+    chromeShell.loadURI("chrome://extensions/content/dummy.xul", loadURIOptions);
 
     await promiseObserved("chrome-document-global-created",
                           win => win.document == chromeShell.document);
 
     let chromeDoc = await promiseDocumentLoaded(chromeShell.document);
 
     let browser = chromeDoc.createElement("browser");
     browser.setAttribute("type", "content");
--- a/toolkit/components/extensions/test/xpcshell/test_WebExtensionContentScript.js
+++ b/toolkit/components/extensions/test/xpcshell/test_WebExtensionContentScript.js
@@ -64,18 +64,20 @@ async function loadURL(url, {frameCount}
       }
     }, {once: true});
   }
 
   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);
+  let loadURIOptions = {
+    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+  };
+  webNav.loadURI(url, loadURIOptions);
 
   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
@@ -9,21 +9,20 @@ const gfxFrameScript = {
   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);
-
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
+    webNav.loadURI("chrome://gfxsanity/content/sanitytest.html", loadURIOptions);
   },
 
   handleEvent(aEvent) {
     switch (aEvent.type) {
       case "MozAfterPaint":
         sendAsyncMessage("gfxSanity:ContentLoaded");
         removeEventListener("MozAfterPaint", this);
         break;
--- a/toolkit/components/reader/ReaderMode.jsm
+++ b/toolkit/components/reader/ReaderMode.jsm
@@ -95,17 +95,22 @@ var ReaderMode = {
       referrerURI = Services.io.newURI(url);
       principal = Services.scriptSecurityManager.createCodebasePrincipal(
         referrerURI, win.document.nodePrincipal.originAttributes);
     } catch (e) {
       Cu.reportError(e);
       return;
     }
     let flags = webNav.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
-    webNav.loadURI(originalURL, flags, referrerURI, null, null, principal);
+    let loadURIOptions = {
+      triggeringPrincipal: principal,
+      loadFlags: flags,
+      referrerURI,
+    };
+    webNav.loadURI(originalURL, loadURIOptions);
   },
 
   /**
    * Returns original URL from an about:reader URL.
    *
    * @param url An about:reader URL.
    * @return The original URL for the article, or null if we did not find
    *         a properly formatted about:reader URL.
--- a/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/RemoteWebNavigation.js
@@ -60,34 +60,26 @@ RemoteWebNavigation.prototype = {
     this._sendMessage("WebNavigation:GoBack", {});
   },
   goForward() {
     this._sendMessage("WebNavigation:GoForward", {});
   },
   gotoIndex(aIndex) {
     this._sendMessage("WebNavigation:GotoIndex", {index: aIndex});
   },
-  loadURI(aURI, aLoadFlags, aReferrer, aPostData, aHeaders,
-          aTriggeringPrincipal) {
-    this.loadURIWithOptions(aURI, aLoadFlags, aReferrer,
-                            Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
-                            aPostData, aHeaders, null,
-                            aTriggeringPrincipal);
-  },
-  loadURIWithOptions(aURI, aLoadFlags, aReferrer, aReferrerPolicy,
-                     aPostData, aHeaders, aBaseURI, aTriggeringPrincipal) {
+  loadURI(aURI, aLoadURIOptions) {
     // We know the url is going to be loaded, let's start requesting network
     // connection before the content process asks.
     // Note that we might have already setup the speculative connection in some
     // cases, especially when the url is from location bar or its popup menu.
     if (aURI.startsWith("http:") || aURI.startsWith("https:")) {
       try {
         let uri = makeURI(aURI);
-        let principal = aTriggeringPrincipal;
-        // We usually have a aTriggeringPrincipal assigned, but in case we
+        let principal = aLoadURIOptions.triggeringPrincipal;
+        // We usually have a triggeringPrincipal assigned, but in case we
         // don't have one or if it's a SystemPrincipal, let's create it with OA
         // inferred from the current context.
         if (!principal || principal.isSystemPrincipal) {
           let attrs = {
             userContextId: this._browser.getAttribute("usercontextid") || 0,
             privateBrowsingId: PrivateBrowsingUtils.isBrowserPrivate(this._browser) ? 1 : 0,
           };
           principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, attrs);
@@ -96,24 +88,24 @@ RemoteWebNavigation.prototype = {
       } catch (ex) {
         // Can't setup speculative connection for this uri string for some
         // reason (such as failing to parse the URI), just ignore it.
       }
     }
 
     this._sendMessage("WebNavigation:LoadURI", {
       uri: aURI,
-      flags: aLoadFlags,
-      referrer: aReferrer ? aReferrer.spec : null,
-      referrerPolicy: aReferrerPolicy,
-      postData: aPostData ? Utils.serializeInputStream(aPostData) : null,
-      headers: aHeaders ? Utils.serializeInputStream(aHeaders) : null,
-      baseURI: aBaseURI ? aBaseURI.spec : null,
+      flags: aLoadURIOptions.loadFlags,
+      referrer: aLoadURIOptions.referrerURI ? aLoadURIOptions.referrerURI.spec : null,
+      referrerPolicy: aLoadURIOptions.referrerPolicy,
+      postData: aLoadURIOptions.postData ? Utils.serializeInputStream(aLoadURIOptions.postData) : null,
+      headers: aLoadURIOptions.headers ? Utils.serializeInputStream(aLoadURIOptions.headers) : null,
+      baseURI: aLoadURIOptions.baseURI ? aLoadURIOptions.baseURI.spec : null,
       triggeringPrincipal: Utils.serializePrincipal(
-          aTriggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
+          aLoadURIOptions.triggeringPrincipal || Services.scriptSecurityManager.createNullPrincipal({})),
       requestTime: Services.telemetry.msSystemNow(),
     });
   },
   setOriginAttributesBeforeLoading(aOriginAttributes) {
     this._sendMessage("WebNavigation:SetOriginAttributes", {
       originAttributes: aOriginAttributes,
     });
   },
@@ -133,18 +125,20 @@ RemoteWebNavigation.prototype = {
     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);
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
+    this.loadURI(aURI.spec, loadURIOptions);
   },
 
   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/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_RemoteWebNavigation.js
@@ -1,30 +1,31 @@
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 const SYSTEMPRINCIPAL = Services.scriptSecurityManager.getSystemPrincipal();
 const DUMMY1 = "http://example.com/browser/toolkit/modules/tests/browser/dummy_page.html";
 const DUMMY2 = "http://example.org/browser/toolkit/modules/tests/browser/dummy_page.html";
+const LOAD_URI_OPTIONS = {triggeringPrincipal: SYSTEMPRINCIPAL};
 
 function waitForLoad(uri) {
   return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, uri);
 }
 
 function waitForPageShow(browser = gBrowser.selectedBrowser) {
   return BrowserTestUtils.waitForContentEvent(browser, "pageshow", true);
 }
 
 // Tests that loadURI accepts a referrer and it is included in the load.
 add_task(async function test_referrer() {
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.selectedBrowser;
-
-  browser.webNavigation.loadURI(DUMMY1,
-                                Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                Services.io.newURI(DUMMY2), null, null,
-                                SYSTEMPRINCIPAL);
+  let loadURIOptionsWithReferrer = {
+    triggeringPrincipal: SYSTEMPRINCIPAL,
+    referrerURI: Services.io.newURI(DUMMY2),
+  };
+  browser.webNavigation.loadURI(DUMMY1, loadURIOptionsWithReferrer);
   await waitForLoad(DUMMY1);
 
   await ContentTask.spawn(browser, [ DUMMY1, DUMMY2 ], function([dummy1, dummy2]) {
     is(content.location.href, dummy1, "Should have loaded the right URL");
     is(content.document.referrer, dummy2, "Should have the right referrer");
   });
 
   gBrowser.removeCurrentTab();
@@ -37,26 +38,20 @@ add_task(async function test_history() {
       let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                             .getInterface(Ci.nsISHistory);
       is(history.index, n, "Should be at the right place in history");
     });
   }
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.selectedBrowser;
 
-  browser.webNavigation.loadURI(DUMMY1,
-                                Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                null, null, null,
-                                SYSTEMPRINCIPAL);
+  browser.webNavigation.loadURI(DUMMY1, LOAD_URI_OPTIONS);
   await waitForLoad(DUMMY1);
 
-  browser.webNavigation.loadURI(DUMMY2,
-                                Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                null, null, null,
-                                SYSTEMPRINCIPAL);
+  browser.webNavigation.loadURI(DUMMY2, LOAD_URI_OPTIONS);
   await waitForLoad(DUMMY2);
 
   await ContentTask.spawn(browser, [DUMMY1, DUMMY2], function([dummy1, dummy2]) {
     let history = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                           .getInterface(Ci.nsISHistory);
     is(history.count, 2, "Should be two history items");
     is(history.index, 1, "Should be at the right place in history");
     let entry = history.getEntryAtIndex(0);
@@ -95,61 +90,60 @@ add_task(async function test_flags() {
         let entry = history.getEntryAtIndex(index);
         is(entry.URI.spec, dummy2, "Should have the right history entry");
       });
   }
 
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.selectedBrowser;
 
-  browser.webNavigation.loadURI(DUMMY1,
-                                Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                null, null, null,
-                                SYSTEMPRINCIPAL);
+  browser.webNavigation.loadURI(DUMMY1, LOAD_URI_OPTIONS);
   await waitForLoad(DUMMY1);
-
-  browser.webNavigation.loadURI(DUMMY2,
-                                Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
-                                null, null, null,
-                                SYSTEMPRINCIPAL);
+  let loadURIOptionsReplaceHistory = {
+    triggeringPrincipal: SYSTEMPRINCIPAL,
+    loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
+  };
+  browser.webNavigation.loadURI(DUMMY2, loadURIOptionsReplaceHistory);
   await waitForLoad(DUMMY2);
   await checkHistory(browser, { count: 1, index: 0 });
-
-  browser.webNavigation.loadURI(DUMMY1,
-                                Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
-                                null, null, null,
-                                SYSTEMPRINCIPAL);
+  let loadURIOptionsBypassHistory = {
+    triggeringPrincipal: SYSTEMPRINCIPAL,
+    loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
+  };
+  browser.webNavigation.loadURI(DUMMY1, loadURIOptionsBypassHistory);
   await waitForLoad(DUMMY1);
   await checkHistory(browser, { count: 1, index: 0 });
 
   gBrowser.removeCurrentTab();
 });
 
 // Tests that attempts to use unsupported arguments throw an exception.
 add_task(async function test_badarguments() {
   if (!gMultiProcessBrowser)
     return;
 
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.selectedBrowser;
 
   try {
-    browser.webNavigation.loadURI(DUMMY1,
-                                  Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                  null, {}, null,
-                                  SYSTEMPRINCIPAL);
+    let loadURIOptionsBadPostData = {
+      triggeringPrincipal: SYSTEMPRINCIPAL,
+      postData: {},
+    };
+    browser.webNavigation.loadURI(DUMMY1, loadURIOptionsBadPostData);
     ok(false, "Should have seen an exception from trying to pass some postdata");
   } catch (e) {
     ok(true, "Should have seen an exception from trying to pass some postdata");
   }
 
   try {
-    browser.webNavigation.loadURI(DUMMY1,
-                                  Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
-                                  null, null, {},
-                                  SYSTEMPRINCIPAL);
+    let loadURIOptionsBadHeader = {
+      triggeringPrincipal: SYSTEMPRINCIPAL,
+      headers: {},
+    };
+    browser.webNavigation.loadURI(DUMMY1, loadURIOptionsBadHeader);
     ok(false, "Should have seen an exception from trying to pass some headers");
   } catch (e) {
     ok(true, "Should have seen an exception from trying to pass some headers");
   }
 
   gBrowser.removeCurrentTab();
 });
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -203,19 +203,21 @@ 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();
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
     wlBrowser.loadURI("chrome://global/content/backgroundPageThumbs.xhtml",
-                      0, null, null, null, triggeringPrincipal);
+                      loadURIOptions);
     this._windowlessContainer = wlBrowser;
 
     return false;
   },
 
   _init() {
     Services.prefs.addObserver(ABOUT_NEWTAB_SEGREGATION_PREF, this);
     Services.obs.addObserver(this, "profile-before-change");
--- a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
+++ b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js
@@ -96,20 +96,21 @@ const backgroundPageThumbsContent = {
       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);
+      let loadURIOptions = {
+        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+        loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT,
+      };
+      this._webNav.loadURI(this._currentCapture.url, loadURIOptions);
     } catch (e) {
       this._failCurrentCapture("BAD_URI");
     }
   },
 
   onStateChange(webProgress, req, flags, status) {
     if (webProgress.isTopLevel &&
         (flags & Ci.nsIWebProgressListener.STATE_STOP) &&
@@ -219,20 +220,21 @@ 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);
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_STOP_CONTENT,
+    };
+    this._webNav.loadURI("about:blank", loadURIOptions);
   },
 
   QueryInterface: ChromeUtils.generateQI([
     Ci.nsIWebProgressListener,
     Ci.nsISupportsWeakReference,
     Ci.nsIObserver,
   ]),
 };
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -276,17 +276,21 @@ var ViewSourceContent = {
    * Load some URL in the browser.
    *
    * @param URL
    *        The URL string to load.
    */
   loadSourceFromURL(URL) {
     let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
     let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
-    webNav.loadURI(URL, loadFlags, null, null, null, Services.scriptSecurityManager.getSystemPrincipal());
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      loadFlags,
+    };
+    webNav.loadURI(URL, loadURIOptions);
   },
 
   /**
    * This handler is for click events from:
    *   * error page content, which can show up if the user attempts to view the
    *     source of an attack page.
    *   * in-page context menu actions
    */
@@ -596,21 +600,23 @@ var ViewSourceContent = {
    */
   viewSourceWithSelection(uri, drawSelection, baseURI) {
     this.needsDrawSelection = drawSelection;
 
     // all our content is held by the data:URI and URIs are internally stored as utf-8 (see nsIURI.idl)
     let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
     let referrerPolicy = Ci.nsIHttpChannel.REFERRER_POLICY_UNSET;
     let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
-    webNav.loadURIWithOptions(uri, loadFlags,
-                              null, referrerPolicy, // referrer
-                              null, null, // postData, headers
-                              Services.io.newURI(baseURI),
-                              Services.scriptSecurityManager.getSystemPrincipal());
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      loadFlags,
+      referrerPolicy,
+      baseURI: Services.io.newURI(baseURI),
+    };
+    webNav.loadURI(uri, loadURIOptions);
   },
 
   /**
    * Using special markers left in the serialized source, this helper makes the
    * underlying markup of the selected fragment to automatically appear as
    * selected on the inflated view-source DOM.
    */
   drawSelection() {
--- a/toolkit/content/widgets/browser-custom-element.js
+++ b/toolkit/content/widgets/browser-custom-element.js
@@ -793,21 +793,25 @@ class MozBrowser extends MozElementMixin
 
     let {
       flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
         referrerURI,
         referrerPolicy = Ci.nsIHttpChannel.REFERRER_POLICY_UNSET,
         triggeringPrincipal,
         postData,
     } = aParams || {};
-
+    let loadURIOptions = {
+      triggeringPrincipal,
+      referrerURI,
+      loadFlags: flags,
+      referrerPolicy,
+      postData,
+    };
     this._wrapURIChangeCall(() =>
-      this.webNavigation.loadURIWithOptions(
-        aURI, flags, referrerURI, referrerPolicy,
-        postData, null, null, triggeringPrincipal));
+      this.webNavigation.loadURI(aURI, loadURIOptions));
   }
 
   gotoIndex(aIndex) {
     this._wrapURIChangeCall(() => this.webNavigation.gotoIndex(aIndex));
   }
 
   /**
    * Used by session restore to ensure that currentURI is set so
--- a/toolkit/modules/HiddenFrame.jsm
+++ b/toolkit/modules/HiddenFrame.jsm
@@ -103,11 +103,14 @@ HiddenFrame.prototype = {
         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.useGlobalHistory = false;
-    this._browser.loadURI(XUL_PAGE, 0, null, null, null, systemPrincipal);
+    let loadURIOptions = {
+      triggeringPrincipal: systemPrincipal,
+    };
+    this._browser.loadURI(XUL_PAGE, loadURIOptions);
   },
 };
--- a/widget/headless/tests/test_headless.js
+++ b/widget/headless/tests/test_headless.js
@@ -15,17 +15,20 @@ const HEADLESS_BUTTON_URL = `${BASE}/hea
 registerCleanupFunction(() => { server.stop(() => {})});
 
 // Refrences to the progress listeners to keep them from being gc'ed
 // before they are called.
 const progressListeners = new Map();
 
 function loadContentWindow(windowlessBrowser, uri) {
   return new Promise((resolve, reject) => {
-    windowlessBrowser.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null, Services.scriptSecurityManager.getSystemPrincipal());
+    let loadURIOptions = {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    };
+    windowlessBrowser.loadURI(uri, loadURIOptions);
     let docShell = windowlessBrowser.docShell;
     let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                       .getInterface(Ci.nsIWebProgress);
     let progressListener = {
       onLocationChange: function (progress, request, location, flags) {
         // Ignore inner-frame events
         if (progress != webProgress) {
           return;