Bug 1444599 - Fix opening bookmark folders from the sidebar by middle/ctrl/cmd clicking. r?mak
MozReview-Commit-ID: 4B611oRaCOH
--- 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);
+ }
+ });
+});