Backport Bug 1364392 - Provide correct triggeringPrincipal to openLinkIn
This commit is contained in:
Родитель
f78970f857
Коммит
7b5fb2fd2f
|
@ -639,19 +639,6 @@ class _ASRouter {
|
|||
});
|
||||
}
|
||||
|
||||
openLinkIn(url, target, {isPrivate = false, trusted = false, where = ""}) {
|
||||
const win = target.browser.ownerGlobal;
|
||||
const params = {
|
||||
private: isPrivate,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})
|
||||
};
|
||||
if (trusted) {
|
||||
win.openTrustedLinkIn(url, where);
|
||||
} else {
|
||||
win.openLinkIn(url, where, params);
|
||||
}
|
||||
}
|
||||
|
||||
_validPreviewEndpoint(url) {
|
||||
try {
|
||||
const endpoint = new URL(url);
|
||||
|
@ -716,10 +703,13 @@ class _ASRouter {
|
|||
target.browser.ownerGlobal.OpenBrowserWindow({private: true});
|
||||
break;
|
||||
case ra.OPEN_URL:
|
||||
this.openLinkIn(action.data.url, target, {isPrivate: false, where: "tabshifted"});
|
||||
target.browser.ownerGlobal.openLinkIn(action.data.url, "tabshifted", {
|
||||
private: false,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})
|
||||
});
|
||||
break;
|
||||
case ra.OPEN_ABOUT_PAGE:
|
||||
this.openLinkIn(`about:${action.data.page}`, target, {isPrivate: false, trusted: true, where: "tab"});
|
||||
target.browser.ownerGlobal.openTrustedLinkIn(`about:${action.data.page}`, "tab");
|
||||
break;
|
||||
case ra.OPEN_APPLICATIONS_MENU:
|
||||
UITour.showMenu(target.browser.ownerGlobal, action.data.target);
|
||||
|
|
|
@ -657,24 +657,23 @@ describe("ASRouter", () => {
|
|||
assert.calledWith(msg.target.browser.ownerGlobal.OpenBrowserWindow, {private: true});
|
||||
});
|
||||
it("should call openLinkIn with the correct params on OPEN_URL", async () => {
|
||||
sinon.spy(Router, "openLinkIn");
|
||||
let [testMessage] = Router.state.messages;
|
||||
testMessage.button_action = {type: "OPEN_URL", data: {url: "some/url.com"}};
|
||||
const msg = fakeExecuteUserAction(testMessage.button_action);
|
||||
await Router.onMessage(msg);
|
||||
|
||||
assert.calledWith(Router.openLinkIn, "some/url.com", msg.target, {isPrivate: false, where: "tabshifted"});
|
||||
assert.calledOnce(msg.target.browser.ownerGlobal.openLinkIn);
|
||||
assert.calledWith(msg.target.browser.ownerGlobal.openLinkIn,
|
||||
"some/url.com", "tabshifted", {"private": false, "triggeringPrincipal": undefined});
|
||||
});
|
||||
it("should call openLinkIn with the correct params on OPEN_ABOUT_PAGE", async () => {
|
||||
sinon.spy(Router, "openLinkIn");
|
||||
let [testMessage] = Router.state.messages;
|
||||
testMessage.button_action = {type: "OPEN_ABOUT_PAGE", data: {page: "something"}};
|
||||
const msg = fakeExecuteUserAction(testMessage.button_action);
|
||||
await Router.onMessage(msg);
|
||||
|
||||
assert.calledWith(Router.openLinkIn, `about:something`, msg.target, {isPrivate: false, trusted: true, where: "tab"});
|
||||
assert.calledOnce(msg.target.browser.ownerGlobal.openTrustedLinkIn);
|
||||
assert.calledWith(msg.target.browser.ownerGlobal.openTrustedLinkIn, "about:something", "tab");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче