Bug 1451700 - Fix opening a bookmark by pressing return in the sidebar. r?mak
MozReview-Commit-ID: 9hoyc9OXpUF
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -1022,17 +1022,17 @@ var PlacesUIUtils = {
tbo.view.selection.select(cell.row);
this.openNodeWithEvent(tree.selectedNode, event);
}
},
onSidebarTreeKeyPress(event) {
let node = event.target.selectedNode;
if (node) {
- if (event.keyCode == KeyEvent.DOM_VK_RETURN)
+ if (event.keyCode == event.DOM_VK_RETURN)
this.openNodeWithEvent(node, event);
}
},
/**
* The following function displays the URL of a node that is being
* hovered over.
*/
--- a/browser/components/places/tests/browser/browser_sidebar_open_bookmarks.js
+++ b/browser/components/places/tests/browser/browser_sidebar_open_bookmarks.js
@@ -38,16 +38,38 @@ add_task(async function test_open_bookma
// 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_from_sidebar_keypress() {
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
+
+ await withSidebarTree("bookmarks", async (tree) => {
+ tree.selectItems([gBms[1].guid]);
+
+ let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser,
+ false, gBms[1].url
+ );
+
+ tree.focus();
+ EventUtils.sendKey("return");
+
+ 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 = [];