Bug 1444599 - Fix opening bookmark folders from the sidebar by middle/ctrl/cmd clicking. r=mak a=jcristau
authorMark Banner <standard8@mozilla.com>
Mon, 12 Mar 2018 12:33:32 +0000
changeset 462684 944ddfae2be0d98c8e63765b8acf00948b9516e9
parent 462683 b9bc94d03e329e155ee38195a608f32182ab5ee9
child 462685 fb798a901a729b9dec35e07e4df140c3456b1ca0
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, jcristau
bugs1444599
milestone60.0
Bug 1444599 - Fix opening bookmark folders from the sidebar by middle/ctrl/cmd clicking. r=mak a=jcristau MozReview-Commit-ID: 4B611oRaCOH
browser/components/places/content/sidebarUtils.js
browser/components/places/tests/browser/browser.ini
browser/components/places/tests/browser/browser_sidebar_open_bookmarks.js
--- a/browser/components/places/content/sidebarUtils.js
+++ b/browser/components/places/content/sidebarUtils.js
@@ -38,17 +38,17 @@ var SidebarUtils = {
 
     var metaKey = AppConstants.platform === "macosx" ? aEvent.metaKey
                                                      : aEvent.ctrlKey;
     var modifKey = metaKey || aEvent.shiftKey;
     var isContainer = tbo.view.isContainer(cell.row);
     var openInTabs = isContainer &&
                      (aEvent.button == 1 ||
                       (aEvent.button == 0 && modifKey)) &&
-                     PlacesUtils.hasChildURIs(tbo.view.nodeForTreeIndex(cell.row));
+                     PlacesUtils.hasChildURIs(aTree.view.nodeForTreeIndex(cell.row));
 
     if (aEvent.button == 0 && isContainer && !openInTabs) {
       tbo.view.toggleOpenState(cell.row);
     } else if (!mouseInGutter && openInTabs &&
             aEvent.originalTarget.localName == "treechildren") {
       tbo.view.selection.select(cell.row);
       PlacesUIUtils.openContainerNodeInTabs(aTree.selectedNode, aEvent, aTree);
     } else if (!mouseInGutter && !isContainer &&
--- a/browser/components/places/tests/browser/browser.ini
+++ b/browser/components/places/tests/browser/browser.ini
@@ -99,16 +99,18 @@ skip-if = (os == 'win' && ccov) # Bug 14
 [browser_paste_bookmarks.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 subsuite = clipboard
 [browser_paste_into_tags.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_remove_bookmarks.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 subsuite = clipboard
+[browser_sidebar_open_bookmarks.js]
+skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_sidebarpanels_click.js]
 skip-if = (os == 'win' && ccov) || (os == "mac" && debug) # Bug 1423667
 [browser_sort_in_library.js]
 skip-if = (os == 'win' && ccov) # Bug 1423667
 [browser_stayopenmenu.js]
 skip-if = os == "mac" && debug # bug 1400323
 [browser_toolbar_drop_text.js]
 [browser_toolbar_overflow.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/places/tests/browser/browser_sidebar_open_bookmarks.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+var gBms;
+
+add_task(async function setup() {
+  gBms = await PlacesUtils.bookmarks.insertTree({
+    guid: PlacesUtils.bookmarks.unfiledGuid,
+    children: [{
+      title: "bm1",
+      url: "about:buildconfig"
+    }, {
+      title: "bm2",
+      url: "about:mozilla",
+    }]
+  });
+
+  registerCleanupFunction(async () => {
+    await PlacesUtils.bookmarks.eraseEverything();
+  });
+});
+
+add_task(async function test_open_bookmark_from_sidebar() {
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
+
+  await withSidebarTree("bookmarks", async (tree) => {
+    tree.selectItems([gBms[0].guid]);
+
+    let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser,
+      false, gBms[0].url
+    );
+
+    tree.controller.doCommand("placesCmd_open");
+
+    await loadedPromise;
+
+    // An assert to make the test happy.
+    Assert.ok(true, "The bookmark was loaded successfully.");
+  });
+
+  await BrowserTestUtils.removeTab(tab);
+});
+
+add_task(async function test_open_bookmark_folder_from_sidebar() {
+  await withSidebarTree("bookmarks", async (tree) => {
+    tree.selectItems([PlacesUtils.bookmarks.virtualUnfiledGuid]);
+
+    Assert.equal(tree.view.selection.getRangeCount(), 1,
+      "Should only have one range selected");
+
+    let loadedPromises = [];
+
+    for (let bm of gBms) {
+      loadedPromises.push(BrowserTestUtils.waitForNewTab(gBrowser,
+        bm.url, false, true));
+    }
+
+    synthesizeClickOnSelectedTreeCell(tree, {button: 1});
+
+   let tabs = await Promise.all(loadedPromises);
+
+    for (let tab of tabs) {
+      await BrowserTestUtils.removeTab(tab);
+    }
+  });
+});