зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1485305 - browser/ Ensure loadURI always passes a triggeringPrincipal() r=Mossop
Differential Revision: https://phabricator.services.mozilla.com/D4551 --HG-- extra : source : b4b9736b30b679bba6b496c4191a17529241f0d7
This commit is contained in:
Родитель
b81ad8c8ab
Коммит
c5b234e0ea
|
@ -8,6 +8,8 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
var EXPORTED_SYMBOLS = ["BlockedSiteChild"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Utils",
|
||||
"resource://gre/modules/sessionstore/Utils.jsm");
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "SafeBrowsing",
|
||||
"resource://gre/modules/SafeBrowsing.jsm");
|
||||
|
@ -29,7 +31,9 @@ function getSiteBlockedErrorDetails(docShell) {
|
|||
.finalize();
|
||||
}
|
||||
|
||||
let triggeringPrincipal = docShell.failedChannel.loadInfo ? Utils.serializePrincipal(docShell.failedChannel.loadInfo.triggeringPrincipal) : null;
|
||||
blockedInfo = { list: classifiedChannel.matchedList,
|
||||
triggeringPrincipal,
|
||||
provider: classifiedChannel.matchedProvider,
|
||||
uri: reportUri.asciiSpec };
|
||||
}
|
||||
|
|
|
@ -1009,6 +1009,18 @@ function handleUriInChrome(aBrowser, aUri) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Creates a null principal using the userContextId
|
||||
from the current selected tab or a passed in tab argument */
|
||||
function _createNullPrincipalFromTabUserContextId(tab = gBrowser.selectedTab) {
|
||||
let userContextId;
|
||||
if (tab.hasAttribute("usercontextid")) {
|
||||
userContextId = tab.getAttribute("usercontextid");
|
||||
}
|
||||
return Services.scriptSecurityManager.createNullPrincipal({
|
||||
userContextId,
|
||||
});
|
||||
}
|
||||
|
||||
// A shared function used by both remote and non-remote browser XBL bindings to
|
||||
// load a URI or redirect it to the correct process.
|
||||
function _loadURI(browser, uri, params = {}) {
|
||||
|
@ -1031,6 +1043,10 @@ function _loadURI(browser, uri, params = {}) {
|
|||
userContextId,
|
||||
} = params || {};
|
||||
|
||||
if (!triggeringPrincipal) {
|
||||
throw new Error("Must load with a triggering Principal");
|
||||
}
|
||||
|
||||
let {
|
||||
uriObject,
|
||||
requiredRemoteType,
|
||||
|
@ -2399,6 +2415,10 @@ function BrowserTryToCloseWindow() {
|
|||
function loadURI(uri, referrer, postData, allowThirdPartyFixup, referrerPolicy,
|
||||
userContextId, originPrincipal, forceAboutBlankViewerInCurrent,
|
||||
triggeringPrincipal, allowInheritPrincipal = false) {
|
||||
if (!triggeringPrincipal) {
|
||||
throw new Error("Must load with a triggering Principal");
|
||||
}
|
||||
|
||||
try {
|
||||
openLinkIn(uri, "current",
|
||||
{ referrerURI: referrer,
|
||||
|
@ -3140,10 +3160,12 @@ var BrowserOnClick = {
|
|||
},
|
||||
|
||||
ignoreWarningLink(reason, blockedInfo) {
|
||||
let triggeringPrincipal = Utils.deserializePrincipal(blockedInfo.triggeringPrincipal) || _createNullPrincipalFromTabUserContextId();
|
||||
// Allow users to override and continue through to the site,
|
||||
// but add a notify bar as a reminder, so that they don't lose
|
||||
// track after, e.g., tab switching.
|
||||
gBrowser.loadURI(gBrowser.currentURI.spec, {
|
||||
triggeringPrincipal,
|
||||
flags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
|
||||
});
|
||||
|
||||
|
@ -3208,7 +3230,9 @@ var BrowserOnClick = {
|
|||
* when their own homepage is infected, we can get them somewhere safe.
|
||||
*/
|
||||
function getMeOutOfHere() {
|
||||
gBrowser.loadURI(getDefaultHomePage());
|
||||
gBrowser.loadURI(getDefaultHomePage(), {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), // Also needs to load homepage
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3224,7 +3248,9 @@ function goBackFromErrorPage() {
|
|||
if (state.index == 1) {
|
||||
// If the unsafe page is the first or the only one in history, go to the
|
||||
// start page.
|
||||
gBrowser.loadURI(getDefaultHomePage());
|
||||
gBrowser.loadURI(getDefaultHomePage(), {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
});
|
||||
} else {
|
||||
BrowserBack();
|
||||
}
|
||||
|
@ -3260,7 +3286,10 @@ function BrowserReloadWithFlags(reloadFlags) {
|
|||
// If the remoteness has changed, the new browser doesn't have any
|
||||
// information of what was loaded before, so we need to load the previous
|
||||
// URL again.
|
||||
gBrowser.loadURI(url, { flags: reloadFlags });
|
||||
gBrowser.loadURI(url, {
|
||||
flags: reloadFlags,
|
||||
triggeringPrincipal: gBrowser.selectedBrowser.contentPrincipal,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7666,7 +7695,9 @@ function switchToTabHavingURI(aURI, aOpenNew, aOpenParams = {}) {
|
|||
}
|
||||
|
||||
if (ignoreFragment == "whenComparingAndReplace" || replaceQueryString) {
|
||||
browser.loadURI(aURI.spec);
|
||||
browser.loadURI(aURI.spec, {
|
||||
triggeringPrincipal: aOpenParams.triggeringPrincipal || _createNullPrincipalFromTabUserContextId(),
|
||||
});
|
||||
}
|
||||
|
||||
if (!doAdopt) {
|
||||
|
|
|
@ -1792,7 +1792,9 @@ window._gBrowser = {
|
|||
browser.webProgress;
|
||||
}
|
||||
|
||||
browser.loadURI(BROWSER_NEW_TAB_URL);
|
||||
browser.loadURI(BROWSER_NEW_TAB_URL, {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
});
|
||||
browser.docShellIsActive = false;
|
||||
browser._urlbarFocused = true;
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ global.replaceUrlInTab = (gBrowser, tab, url) => {
|
|||
let loaded = waitForTabLoaded(tab, url);
|
||||
gBrowser.loadURI(url, {
|
||||
flags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), // This is safe from this functions usage however it would be preferred not to dot his.
|
||||
});
|
||||
return loaded;
|
||||
};
|
||||
|
|
|
@ -190,7 +190,9 @@ this.SnippetsFeed = class SnippetsFeed {
|
|||
async showFirefoxAccounts(browser) {
|
||||
const url = await FxAccounts.config.promiseSignUpURI("snippets");
|
||||
// We want to replace the current tab.
|
||||
browser.loadURI(url);
|
||||
browser.loadURI(url, {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
});
|
||||
}
|
||||
|
||||
async onAction(action) {
|
||||
|
|
|
@ -159,7 +159,9 @@ SubDialog.prototype = {
|
|||
}
|
||||
};
|
||||
this._frame.addEventListener("load", onBlankLoad);
|
||||
this._frame.loadURI("about:blank");
|
||||
this._frame.loadURI("about:blank", {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
});
|
||||
}, 0);
|
||||
},
|
||||
|
||||
|
|
|
@ -358,7 +358,9 @@ var gSyncPane = {
|
|||
// Get the <browser> element hosting us.
|
||||
let browser = window.docShell.chromeEventHandler;
|
||||
// And tell it to load our URL.
|
||||
browser.loadURI(url);
|
||||
browser.loadURI(url, {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
});
|
||||
},
|
||||
|
||||
async signIn() {
|
||||
|
|
|
@ -2960,7 +2960,11 @@ var SessionStoreInternal = {
|
|||
// a flash of the about:tabcrashed page after selecting
|
||||
// the revived tab.
|
||||
aTab.removeAttribute("crashed");
|
||||
browser.loadURI("about:blank");
|
||||
browser.loadURI("about:blank", {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
|
||||
userContextId: aTab.userContextId,
|
||||
}),
|
||||
});
|
||||
|
||||
let data = TabState.collect(aTab, TAB_CUSTOM_VALUES.get(aTab));
|
||||
this.restoreTab(aTab, data, {
|
||||
|
|
|
@ -180,7 +180,9 @@ function restoreSession() {
|
|||
|
||||
function startNewSession() {
|
||||
if (Services.prefs.getIntPref("browser.startup.page") == 0)
|
||||
getBrowserWindow().gBrowser.loadURI("about:blank");
|
||||
getBrowserWindow().gBrowser.loadURI("about:blank", {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
});
|
||||
else
|
||||
getBrowserWindow().BrowserHome();
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
|||
// before they are called.
|
||||
const progressListeners = new Map();
|
||||
|
||||
function loadContentWindow(webNavigation, uri) {
|
||||
function loadContentWindow(webNavigation, uri, principal) {
|
||||
return new Promise((resolve, reject) => {
|
||||
webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
|
||||
webNavigation.loadURI(uri, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null, principal);
|
||||
let docShell = webNavigation.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDocShell);
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
|
@ -50,7 +50,7 @@ async function takeScreenshot(fullWidth, fullHeight, contentWidth, contentHeight
|
|||
try {
|
||||
var windowlessBrowser = Services.appShell.createWindowlessBrowser(false);
|
||||
// nsIWindowlessBrowser inherits from nsIWebNavigation.
|
||||
let contentWindow = await loadContentWindow(windowlessBrowser, url);
|
||||
let contentWindow = await loadContentWindow(windowlessBrowser, url, Services.scriptSecurityManager.getSystemPrincipal());
|
||||
contentWindow.resizeTo(contentWidth, contentHeight);
|
||||
|
||||
let canvas = contentWindow.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas");
|
||||
|
|
|
@ -468,7 +468,9 @@ var UITour = {
|
|||
}
|
||||
|
||||
// We want to replace the current tab.
|
||||
browser.loadURI(url.href);
|
||||
browser.loadURI(url.href, {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -483,7 +485,9 @@ var UITour = {
|
|||
}
|
||||
|
||||
// We want to replace the current tab.
|
||||
browser.loadURI(url.href);
|
||||
browser.loadURI(url.href, {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -247,6 +247,9 @@ var ContentSearch = {
|
|||
this._reply(msg, "Blur");
|
||||
browser.loadURI(submission.uri.spec, {
|
||||
postData: submission.postData,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({
|
||||
userContextId: win.gBrowser.selectedBrowser.getAttribute("userContextId"),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
let params = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче