From 7b5fb2fd2f314a0af4664a329d5dbfc9d57d4061 Mon Sep 17 00:00:00 2001 From: Ricky Rosario Date: Fri, 24 Aug 2018 15:31:22 -0400 Subject: [PATCH] Backport Bug 1364392 - Provide correct triggeringPrincipal to openLinkIn --- lib/ASRouter.jsm | 20 +++++--------------- test/unit/asrouter/ASRouter.test.js | 7 +++---- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/lib/ASRouter.jsm b/lib/ASRouter.jsm index 8a360dda4..ce9ff4b9a 100644 --- a/lib/ASRouter.jsm +++ b/lib/ASRouter.jsm @@ -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); diff --git a/test/unit/asrouter/ASRouter.test.js b/test/unit/asrouter/ASRouter.test.js index 10194c6a1..bec78f0e3 100644 --- a/test/unit/asrouter/ASRouter.test.js +++ b/test/unit/asrouter/ASRouter.test.js @@ -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"); }); });