Bug 1453528 - Fix opening of synced tabs with correct principal. r?markh
MozReview-Commit-ID: 6MGXjsg3HmV
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -739,17 +739,19 @@ if (Services.prefs.getBoolPref("identity
item.setAttribute("class", "subviewbutton");
item.setAttribute("targetURI", tabInfo.url);
item.setAttribute("label", tabInfo.title != "" ? tabInfo.title : tabInfo.url);
item.setAttribute("image", tabInfo.icon);
item.setAttribute("tooltiptext", tooltipText);
// We need to use "click" instead of "command" here so openUILink
// respects different buttons (eg, to open in a new tab).
item.addEventListener("click", e => {
- doc.defaultView.openWebLinkIn(tabInfo.url, e);
+ doc.defaultView.openUILink(tabInfo.url, e, {
+ triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})
+ });
if (doc.defaultView.whereToOpenLink(e) != "current") {
e.preventDefault();
e.stopPropagation();
} else {
CustomizableUI.hidePanelForNode(item);
}
BrowserUITelemetry.countSyncedTabEvent("open", "toolbarbutton-subview");
});
--- a/browser/components/customizableui/test/browser_synced_tabs_menu.js
+++ b/browser/components/customizableui/test/browser_synced_tabs_menu.js
@@ -14,16 +14,18 @@ ChromeUtils.defineModuleGetter(this, "UI
// These are available on the widget implementation, but it seems impossible
// to grab that impl at runtime.
const DECKINDEX_TABS = 0;
const DECKINDEX_TABSDISABLED = 1;
const DECKINDEX_FETCHING = 2;
const DECKINDEX_NOCLIENTS = 3;
+const SAMPLE_TAB_URL = "https://example.com/";
+
var initialLocation = gBrowser.currentURI.spec;
var newTab = null;
// A helper to notify there are new tabs. Returns a promise that is resolved
// once the UI has been updated.
function updateTabsPanel() {
let promiseTabsUpdated = promiseObserverNotified("synced-tabs-menu:test:tabs-updated");
Services.obs.notifyObservers(null, SyncedTabs.TOPIC_TABS_CHANGED);
@@ -330,24 +332,25 @@ add_task(async function() {
name: "My Desktop",
lastModified: 1492201200,
tabs: function() {
let allTabsDesktop = [];
// We choose 77 tabs, because TABS_PER_PAGE is 25, which means
// on the second to last page we should have 22 items shown
// (because we have to show at least NEXT_PAGE_MIN_TABS=5 tabs on the last page)
for (let i = 1; i <= 77; i++) {
- allTabsDesktop.push({ title: "Tab #" + i });
+ allTabsDesktop.push({ title: "Tab #" + i, url: SAMPLE_TAB_URL });
}
return allTabsDesktop;
}(),
}
]);
};
+
gSync.updateAllUI({ status: UIState.STATUS_SIGNED_IN, lastSync: new Date(),
email: "foo@bar.com" });
await document.getElementById("nav-bar").overflowable.show();
let tabsUpdatedPromise = promiseObserverNotified("synced-tabs-menu:test:tabs-updated");
let syncPanel = document.getElementById("PanelUI-remotetabs");
let viewShownPromise = BrowserTestUtils.waitForEvent(syncPanel, "ViewShown");
let syncButton = document.getElementById("sync-button");
@@ -365,29 +368,38 @@ add_task(async function() {
let tabList = document.getElementById("PanelUI-remotetabs-tabslist");
let node = tabList.firstChild;
is(node.getAttribute("itemtype"), "client", "node is a client entry");
is(node.textContent, "My Desktop", "correct client");
for (let i = 0; i < tabsShownCount; i++) {
node = node.nextSibling;
is(node.getAttribute("itemtype"), "tab", "node is a tab");
is(node.getAttribute("label"), "Tab #" + (i + 1), "the tab is the correct one");
+ is(node.getAttribute("targetURI"), SAMPLE_TAB_URL, "url is the correct one");
}
let showMoreButton;
if (showMoreLabel) {
node = showMoreButton = node.nextSibling;
is(node.getAttribute("itemtype"), "showmorebutton", "node is a show more button");
is(node.getAttribute("label"), showMoreLabel);
}
node = node.nextSibling;
is(node, null, "no more entries");
return showMoreButton;
}
+ async function checkCanOpenURL() {
+ let tabList = document.getElementById("PanelUI-remotetabs-tabslist");
+ let node = tabList.firstChild.nextSibling;
+ let promiseTabOpened = BrowserTestUtils.waitForLocationChange(gBrowser, SAMPLE_TAB_URL);
+ node.click();
+ await promiseTabOpened;
+ }
+
let showMoreButton;
function clickShowMoreButton() {
let promise = promiseObserverNotified("synced-tabs-menu:test:tabs-updated");
showMoreButton.click();
return promise;
}
showMoreButton = checkTabsPage(25, "Show More");
@@ -395,11 +407,11 @@ add_task(async function() {
showMoreButton = checkTabsPage(50, "Show More");
await clickShowMoreButton();
showMoreButton = checkTabsPage(72, "Show All");
await clickShowMoreButton();
checkTabsPage(77, null);
-
- await hideOverflow();
+ /* calling this will close the overflow menu */
+ await checkCanOpenURL();
});