Bug 1262310 - Fix opening synced tabs from the sidebar. r=markh draft
authorKit Cambridge <kcambridge@mozilla.com>
Tue, 05 Apr 2016 17:06:00 -0700
changeset 348299 e7218494e54d7b0eeb2ef36cc2189bec7b002ee1
parent 348298 17ec8fc8b561c6fcf844d1efd8c56b7a9ca4e43d
child 348300 5032f25e295bfb76ffead99d0e2d468f63a13b74
push id14805
push userbmo:jacheng@mozilla.com
push dateThu, 07 Apr 2016 07:37:41 +0000
reviewersmarkh
bugs1262310
milestone48.0a1
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));