mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1513241: Update frontend consumers of loadURI and pass loadURIOptions dictionary. r=gijs
This commit is contained in:
parent
fbb4bafd5c
commit
6756032512
@ -1063,6 +1063,13 @@ function _loadURI(browser, uri, params = {}) {
|
||||
if (!requiredRemoteType) {
|
||||
browser.inLoadURI = true;
|
||||
}
|
||||
let loadURIOptions = {
|
||||
triggeringPrincipal,
|
||||
loadFlags: flags,
|
||||
referrerURI,
|
||||
referrerPolicy,
|
||||
postData,
|
||||
};
|
||||
try {
|
||||
if (!mustChangeProcess) {
|
||||
if (userContextId) {
|
||||
@ -1071,10 +1078,7 @@ function _loadURI(browser, uri, params = {}) {
|
||||
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();
|
||||
@ -1121,9 +1125,7 @@ function _loadURI(browser, uri, params = {}) {
|
||||
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;
|
||||
}
|
||||
|
@ -63,9 +63,10 @@ function clear_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++;
|
||||
|
@ -204,19 +204,24 @@ ContentRestoreInternal.prototype = {
|
||||
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;
|
||||
@ -230,10 +235,11 @@ ContentRestoreInternal.prototype = {
|
||||
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;
|
||||
@ -377,9 +383,11 @@ HistoryListener.prototype = {
|
||||
// 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) {
|
||||
|
@ -117,8 +117,7 @@ add_task(async function save_worthy_tabs_remote_final() {
|
||||
|
||||
// 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.
|
||||
|
@ -43,8 +43,10 @@ add_task(async function contentToChromeNavigate() {
|
||||
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);
|
||||
|
||||
|
@ -15,7 +15,10 @@ 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)
|
||||
|
@ -130,9 +130,12 @@ this.tabExtras = class extends ExtensionAPI {
|
||||
},
|
||||
};
|
||||
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) {
|
||||
|
@ -34,8 +34,10 @@ add_task(async function() {
|
||||
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);
|
||||
|
@ -18,8 +18,10 @@ add_task(async function test_windowlessBrowserTroubleshootCrash() {
|
||||
};
|
||||
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;
|
||||
|
||||
|
@ -1080,9 +1080,10 @@ function DoAssertionCheck()
|
||||
|
||||
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)
|
||||
|
@ -101,14 +101,22 @@ var wrapper = {
|
||||
// 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: {
|
||||
|
@ -3904,8 +3904,11 @@ Tab.prototype = {
|
||||
// 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() {
|
||||
@ -5079,8 +5082,11 @@ var ErrorPageEventHandler = {
|
||||
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.
|
||||
|
@ -164,8 +164,11 @@ this.tabExtras = class extends ExtensionAPI {
|
||||
},
|
||||
};
|
||||
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) {
|
||||
|
@ -88,8 +88,10 @@ function testInit() {
|
||||
// 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);';
|
||||
|
@ -110,9 +110,17 @@ class WebNavigationChild extends ActorChild {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1114,7 +1114,10 @@ class HiddenXULWindow {
|
||||
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);
|
||||
|
@ -138,7 +138,10 @@ class ContentPage {
|
||||
|
||||
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);
|
||||
|
@ -69,8 +69,10 @@ async function loadURL(url, {frameCount}) {
|
||||
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;
|
||||
|
||||
|
@ -14,11 +14,10 @@ const gfxFrameScript = {
|
||||
|
||||
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) {
|
||||
|
@ -100,7 +100,12 @@ var ReaderMode = {
|
||||
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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -65,15 +65,7 @@ RemoteWebNavigation.prototype = {
|
||||
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
|
||||
@ -81,8 +73,8 @@ RemoteWebNavigation.prototype = {
|
||||
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) {
|
||||
@ -101,14 +93,14 @@ RemoteWebNavigation.prototype = {
|
||||
|
||||
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(),
|
||||
});
|
||||
},
|
||||
@ -138,8 +130,10 @@ RemoteWebNavigation.prototype = {
|
||||
},
|
||||
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,
|
||||
|
@ -2,6 +2,7 @@ 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);
|
||||
@ -15,11 +16,11 @@ function waitForPageShow(browser = gBrowser.selectedBrowser) {
|
||||
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]) {
|
||||
@ -42,16 +43,10 @@ add_task(async function test_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]) {
|
||||
@ -100,23 +95,20 @@ add_task(async function test_flags() {
|
||||
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 });
|
||||
|
||||
@ -132,20 +124,22 @@ add_task(async function test_badarguments() {
|
||||
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");
|
||||
|
@ -208,9 +208,11 @@ const BackgroundPageThumbs = {
|
||||
}
|
||||
};
|
||||
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;
|
||||
|
@ -101,10 +101,11 @@ const backgroundPageThumbsContent = {
|
||||
|
||||
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");
|
||||
}
|
||||
@ -224,10 +225,11 @@ const backgroundPageThumbsContent = {
|
||||
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([
|
||||
|
@ -281,7 +281,11 @@ var ViewSourceContent = {
|
||||
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);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -601,11 +605,13 @@ var ViewSourceContent = {
|
||||
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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -798,11 +798,15 @@ class MozBrowser extends MozElementMixin(XULFrameElement) {
|
||||
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) {
|
||||
|
@ -108,6 +108,9 @@ HiddenFrame.prototype = {
|
||||
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);
|
||||
},
|
||||
};
|
||||
|
@ -20,7 +20,10 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user