Bug 1451700 - Fix opening a bookmark by pressing return in the sidebar. r=mak
authorMark Banner <standard8@mozilla.com>
Thu, 05 Apr 2018 12:37:23 +0100
changeset 411949 57e84edefa69c2c0cec3d5324434142650440cc7
parent 411948 6419ebd66757aabdf72c64fe1a52e2474f4abed7
child 411950 b3a05d5d62168ff0f927139c7bd916f8b4f380ae
push id33778
push userapavel@mozilla.com
push dateFri, 06 Apr 2018 09:57:38 +0000
treeherdermozilla-central@46a5fc19bd7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1451700
milestone61.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 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 = [];