Bug 1262310 - Fix opening synced tabs from the sidebar. r=markh
authorKit Cambridge <kcambridge@mozilla.com>
Tue, 05 Apr 2016 17:06:00 -0700
changeset 291858 7f54e6fc8add68c07c781e788182c4f9427aaa86
parent 291857 061165ac1ff9e076ec51ea268878efa751173511
child 291859 43f067177f2d15a3e3788b98cc18bd35441eb59e
push id74700
push usercbook@mozilla.com
push dateWed, 06 Apr 2016 10:06:38 +0000
treeherdermozilla-inbound@49d808d13f4f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1262310
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1262310 - Fix opening synced tabs from the sidebar. r=markh MozReview-Commit-ID: 8VHbEqsyuF2
browser/components/syncedtabs/TabListComponent.js
browser/components/syncedtabs/TabListView.js
browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js
--- a/browser/components/syncedtabs/TabListComponent.js
+++ b/browser/components/syncedtabs/TabListComponent.js
@@ -102,17 +102,17 @@ TabListComponent.prototype = {
 
   onBookmarkTab(uri, title) {
     this._window.top.PlacesCommandHook
       .bookmarkLink(this._window.top.PlacesUtils.bookmarksMenuFolderId, uri, title)
       .catch(Cu.reportError);
   },
 
   onOpenTab(url, where, params) {
-    this._window.openLinkIn(url, where, params);
+    this._window.openUILinkIn(url, where, params);
   },
 
   onCopyTabLocation(url) {
     this._clipboardHelper.copyString(url);
   },
 
   onSyncRefresh() {
     this._SyncedTabs.syncTabs(true);
--- a/browser/components/syncedtabs/TabListView.js
+++ b/browser/components/syncedtabs/TabListView.js
@@ -250,17 +250,17 @@ TabListView.prototype = {
     let itemNode = this._findParentItemNode(event.target);
     if (!itemNode) {
       return;
     }
 
     if (itemNode.classList.contains("tab")) {
       let url = itemNode.dataset.url;
       if (url) {
-        this.props.onOpenTab(url, event);
+        this.onOpenSelected(url, event);
       }
     }
 
     if (event.target.classList.contains("item-twisty-container")) {
       this.props.onToggleBranch(itemNode.dataset.id);
       return;
     }
 
@@ -280,17 +280,17 @@ TabListView.prototype = {
       event.preventDefault();
       this.props.onMoveSelectionDown();
     } else if (event.keyCode == this._window.KeyEvent.DOM_VK_UP) {
       event.preventDefault();
       this.props.onMoveSelectionUp();
     } else if (event.keyCode == this._window.KeyEvent.DOM_VK_RETURN) {
       let selectedNode = this.container.querySelector('.item.selected');
       if (selectedNode.dataset.url) {
-        this.props.onOpenTab(selectedNode.dataset.url, event);
+        this.onOpenSelected(selectedNode.dataset.url, event);
       } else if (selectedNode) {
         this.props.onToggleBranch(selectedNode.dataset.id);
       }
     }
   },
 
   onBookmarkTab() {
     let item = this._getSelectedTabNode();
@@ -302,17 +302,22 @@ TabListView.prototype = {
 
   onCopyTabLocation() {
     let item = this._getSelectedTabNode();
     if (item) {
       this.props.onCopyTabLocation(item.dataset.url);
     }
   },
 
-  onOpenSelected(event) {
+  onOpenSelected(url, event) {
+    let where = getChromeWindow(this._window).whereToOpenLink(event);
+    this.props.onOpenTab(url, where, {});
+  },
+
+  onOpenSelectedFromContextMenu(event) {
     let item = this._getSelectedTabNode();
     if (item) {
       let where = event.target.getAttribute("where");
       let params = {
         private: event.target.hasAttribute("private"),
       };
       this.props.onOpenTab(item.dataset.url, where, params);
     }
@@ -417,17 +422,17 @@ TabListView.prototype = {
 
   handleContentContextMenuCommand(event) {
     let id = event.target.getAttribute("id");
     switch (id) {
       case "syncedTabsOpenSelected":
       case "syncedTabsOpenSelectedInTab":
       case "syncedTabsOpenSelectedInWindow":
       case "syncedTabsOpenSelectedInPrivateWindow":
-        this.onOpenSelected(event);
+        this.onOpenSelectedFromContextMenu(event);
         break;
       case "syncedTabsBookmarkSelected":
         this.onBookmarkTab();
         break;
       case "syncedTabsCopySelected":
         this.onCopyTabLocation();
         break;
       case "syncedTabsRefresh":
--- a/browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js
+++ b/browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js
@@ -72,17 +72,17 @@ add_task(function* testActions() {
   };
   let windowMock = {
     top: {
       PlacesCommandHook: {
         bookmarkLink() { return Promise.resolve(); }
       },
       PlacesUtils: { bookmarksMenuFolderId: "id" }
     },
-    openLinkIn() {}
+    openUILinkIn() {}
   };
   let component = new TabListComponent({
     window: windowMock, store, View: null, SyncedTabs,
     clipboardHelper: clipboardHelperMock});
 
   sinon.stub(store, "getData");
   component.onFilter("query");
   Assert.ok(store.getData.calledWith("query"));
@@ -116,19 +116,19 @@ add_task(function* testActions() {
   component.onToggleBranch("foo-id");
   Assert.ok(store.toggleBranch.secondCall.calledWith("foo-id"));
 
   sinon.spy(windowMock.top.PlacesCommandHook, "bookmarkLink");
   component.onBookmarkTab("uri", "title");
   Assert.equal(windowMock.top.PlacesCommandHook.bookmarkLink.args[0][1], "uri");
   Assert.equal(windowMock.top.PlacesCommandHook.bookmarkLink.args[0][2], "title");
 
-  sinon.spy(windowMock, "openLinkIn");
+  sinon.spy(windowMock, "openUILinkIn");
   component.onOpenTab("uri", "where", "params");
-  Assert.ok(windowMock.openLinkIn.calledWith("uri", "where", "params"));
+  Assert.ok(windowMock.openUILinkIn.calledWith("uri", "where", "params"));
 
   sinon.spy(clipboardHelperMock, "copyString");
   component.onCopyTabLocation("uri");
   Assert.ok(clipboardHelperMock.copyString.calledWith("uri"));
 
   sinon.stub(SyncedTabs, "syncTabs");
   component.onSyncRefresh();
   Assert.ok(SyncedTabs.syncTabs.calledWith(true));