Bug 1444599 - Fix opening bookmark folders from the sidebar by middle/ctrl/cmd clicking. r=mak
authorMark Banner <standard8@mozilla.com>
Mon, 12 Mar 2018 12:33:32 +0000
changeset 407622 6b3a36becdd85d5ad0e28b8a4cbcbace18803b19
parent 407621 cae941bc9803114f7fe69bdc6b79577e1db568bc
child 407623 32f5111c989123f3c28a581b3c6e7cabd2eb48ec
push id60982
push usermbanner@mozilla.com
push dateMon, 12 Mar 2018 15:59:19 +0000
treeherderautoland@6b3a36becdd8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1444599
milestone60.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 1444599 - Fix opening bookmark folders from the sidebar by middle/ctrl/cmd clicking. r=mak 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
@@ -98,16 +98,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);
+    }
+  });
+});