Bug 1451700 - Fix opening a bookmark by pressing return in the sidebar. r?mak draft
authorMark Banner <standard8@mozilla.com>
Thu, 05 Apr 2018 12:37:23 +0100
changeset 777844 bbec09fa6e937e951e93e9458abcdfdd13475f0a
parent 777823 1b258f938525fda65ef80ffa0408bc665d5d8948
push id105303
push userbmo:standard8@mozilla.com
push dateThu, 05 Apr 2018 11:37:42 +0000
reviewersmak
bugs1451700
milestone61.0a1
Bug 1451700 - Fix opening a bookmark by pressing return in the sidebar. r?mak MozReview-Commit-ID: 9hoyc9OXpUF
browser/components/places/PlacesUIUtils.jsm
browser/components/places/tests/browser/browser_sidebar_open_bookmarks.js
--- 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 = [];