Bug 1364392 - Provide correct triggeringPrincipal to openLinkIn r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D3873

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kingston 2018-08-21 14:15:40 +00:00
parent 3fbc856a30
commit 3d93e94550
4 changed files with 21 additions and 3 deletions

View File

@ -847,6 +847,7 @@ nsContextMenu.prototype = {
let referrer = gContextMenuContentData.referrer;
openLinkIn(gContextMenuContentData.docLocation, "window",
{ charset: gContextMenuContentData.charSet,
triggeringPrincipal: this.browser.contentPrincipal,
referrerURI: referrer ? makeURI(referrer) : null });
},

View File

@ -300,6 +300,10 @@ function openLinkIn(url, where, params) {
params.forceAboutBlankViewerInCurrent;
var aResolveOnNewTabCreated = params.resolveOnNewTabCreated;
if (!aTriggeringPrincipal) {
throw new Error("Must load with a triggering Principal");
}
if (where == "save") {
// TODO(1073187): propagate referrerPolicy.

View File

@ -602,10 +602,19 @@ class _ASRouter {
target.browser.ownerGlobal.OpenBrowserWindow({private: true});
break;
case ra.OPEN_URL:
this.openLinkIn(action.data.url, target, {isPrivate: false, where: "tabshifted"});
this.openLinkIn(action.data.url, target, {
isPrivate: false,
where: "tabshifted",
triggeringPrincipal: Services.scriptSecurityManager.getNullPrincipal({})
});
break;
case ra.OPEN_ABOUT_PAGE:
this.openLinkIn(`about:${action.data.page}`, target, {isPrivate: false, trusted: true, where: "tab"});
this.openLinkIn(`about:${action.data.page}`, target, {
isPrivate: false,
trusted: true,
where: "tab",
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
break;
case ra.OPEN_APPLICATIONS_MENU:
UITour.showMenu(target.browser.ownerGlobal, action.data.target);

View File

@ -1364,7 +1364,11 @@ var UITour = {
},
showNewTab(aWindow, aBrowser) {
aWindow.openLinkIn("about:newtab", "current", {targetBrowser: aBrowser});
let url = "about:newtab";
aWindow.openLinkIn(url, "current", {
targetBrowser: aBrowser,
triggeringPrincipal: Services.scriptSecurityManager.createCodebasePrincipal(Services.io.newURI(url), {}),
});
aWindow.gURLBar.focus();
},