Bug 1322408 - Use gBrowser.loadTabs to open all tabs when middle-clicking a client in Synced Tabs. r=markh

MozReview-Commit-ID: 6phgHjAAXUs

--HG--
extra : rebase_source : 44260c7a8f407c1efa869912e6407e81e68fb2eb
This commit is contained in:
Kit Cambridge 2016-12-07 11:46:36 -10:00
parent 0b983f77d2
commit f97b3eef3b
4 changed files with 24 additions and 13 deletions

View file

@ -52,6 +52,7 @@ function SyncedTabsDeckComponent({
SyncedTabs: SyncedTabs,
clipboardHelper: Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper),
getChromeWindow: this._getChromeWindow,
});
}

View file

@ -29,11 +29,13 @@ this.EXPORTED_SYMBOLS = [
* to state changes so it can rerender.
*/
function TabListComponent({window, store, View, SyncedTabs, clipboardHelper}) {
function TabListComponent({window, store, View, SyncedTabs, clipboardHelper,
getChromeWindow}) {
this._window = window;
this._store = store;
this._View = View;
this._clipboardHelper = clipboardHelper;
this._getChromeWindow = getChromeWindow;
// used to trigger Sync from context menu
this._SyncedTabs = SyncedTabs;
}
@ -116,7 +118,7 @@ TabListComponent.prototype = {
BrowserUITelemetry.countSyncedTabEvent("open", "sidebar");
},
onOpenTabs(urls, where, params) {
onOpenTabs(urls, where) {
if (!PlacesUIUtils.confirmOpenInTabs(urls.length, this._window)) {
return;
}
@ -124,9 +126,8 @@ TabListComponent.prototype = {
this._window.openDialog(this._window.getBrowserURL(), "_blank",
"chrome,dialog=no,all", urls.join("|"));
} else {
for (let url of urls) {
this._window.openUILinkIn(url, where, params);
}
let loadInBackground = where == "tabshifted" ? true : false;
this._getChromeWindow(this._window).gBrowser.loadTabs(urls, loadInBackground, false);
}
BrowserUITelemetry.countSyncedTabEvent("openmultiple", "sidebar");
},

View file

@ -289,7 +289,7 @@ TabListView.prototype = {
if (where != "current") {
const tabs = itemNode.querySelector(".item-tabs-list").childNodes;
const urls = [...tabs].map(tab => tab.dataset.url);
this.props.onOpenTabs(urls, where, {});
this.props.onOpenTabs(urls, where);
}
}

View file

@ -68,6 +68,13 @@ add_task(function* testInitUninit() {
add_task(function* testActions() {
let store = new SyncedTabsListStore();
let chromeWindowMock = {
gBrowser: {
loadTabs() {},
},
};
let getChromeWindowMock = sinon.stub();
getChromeWindowMock.returns(chromeWindowMock);
let clipboardHelperMock = {
copyString() {},
};
@ -84,7 +91,8 @@ add_task(function* testActions() {
};
let component = new TabListComponent({
window: windowMock, store, View: null, SyncedTabs,
clipboardHelper: clipboardHelperMock});
clipboardHelper: clipboardHelperMock,
getChromeWindow: getChromeWindowMock });
sinon.stub(store, "getData");
component.onFilter("query");
@ -127,12 +135,13 @@ add_task(function* testActions() {
component.onOpenTab("uri", "where", "params");
Assert.ok(windowMock.openUILinkIn.calledWith("uri", "where", "params"));
component.onOpenTabs(["uri1", "uri2"], "where", "params");
Assert.ok(windowMock.openUILinkIn.calledWith("uri1", "where", "params"));
Assert.ok(windowMock.openUILinkIn.calledWith("uri2", "where", "params"));
sinon.spy(windowMock, "openDialog");
component.onOpenTabs(["uri1", "uri2"], "window", "params");
Assert.deepEqual(windowMock.openDialog.args[0][3], ["uri1", "uri2"].join("|"));
sinon.spy(chromeWindowMock.gBrowser, "loadTabs");
let tabsToOpen = ["uri1", "uri2"];
component.onOpenTabs(tabsToOpen, "where");
Assert.ok(getChromeWindowMock.calledWith(windowMock));
Assert.ok(chromeWindowMock.gBrowser.loadTabs.calledWith(tabsToOpen, false, false));
component.onOpenTabs(tabsToOpen, "tabshifted");
Assert.ok(chromeWindowMock.gBrowser.loadTabs.calledWith(tabsToOpen, true, false));
sinon.spy(clipboardHelperMock, "copyString");
component.onCopyTabLocation("uri");