Bug 1335043 - Prevent the bookmark panel from closing automatically if the mouse is hovering over it. r=mak
authorJared Wein <jwein@mozilla.com>
Mon, 30 Jan 2017 10:34:53 -0500
changeset 331975 bc22dc0fe9634203b523ee55c8bbae459c8e47bb
parent 331974 5e23905ef624f1661588a4ddb370742ca8696352
child 331976 bfd5466351b0aacb010d203e57a5b97b82d9bccb
push id31293
push userkwierso@gmail.com
push dateThu, 02 Feb 2017 00:07:12 +0000
treeherdermozilla-central@8196774c6b8a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1335043
milestone54.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 1335043 - Prevent the bookmark panel from closing automatically if the mouse is hovering over it. r=mak MozReview-Commit-ID: 2jor6H2cQck
browser/base/content/browser-places.js
browser/base/content/test/general/browser_bookmark_popup.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -170,17 +170,19 @@ var StarUI = {
           // 3500ms matches the timeout that Pocket uses in
           // browser/extensions/pocket/content/panels/js/saved.js
           let delay = 3500;
           if (this._closePanelQuickForTesting) {
             delay /= 10;
           }
           clearTimeout(this._autoCloseTimer);
           this._autoCloseTimer = setTimeout(() => {
-            this.panel.hidePopup();
+            if (!this.panel.mozMatchesSelector(":hover")) {
+              this.panel.hidePopup();
+            }
           }, delay);
         }
         break;
     }
   },
 
   _overlayLoaded: false,
   _overlayLoading: false,
--- a/browser/base/content/test/general/browser_bookmark_popup.js
+++ b/browser/base/content/test/general/browser_bookmark_popup.js
@@ -6,16 +6,17 @@
 
 /**
  * Test opening and closing the bookmarks panel.
  */
 
 let bookmarkPanel = document.getElementById("editBookmarkPanel");
 let bookmarkStar = document.getElementById("bookmarks-menu-button");
 let bookmarkPanelTitle = document.getElementById("editBookmarkPanelTitle");
+let editBookmarkPanelRemoveButtonRect;
 
 StarUI._closePanelQuickForTesting = true;
 
 function* test_bookmarks_popup({isNewBookmark, popupShowFn, popupEditFn,
                                 shouldAutoClose, popupHideFn, isBookmarkRemoved}) {
   yield BrowserTestUtils.withNewTab({gBrowser, url: "about:home"}, function*(browser) {
     try {
       if (!isNewBookmark) {
@@ -29,16 +30,19 @@ function* test_bookmarks_popup({isNewBoo
       is(bookmarkStar.hasAttribute("starred"), !isNewBookmark,
          "Page should only be starred prior to popupshown if editing bookmark");
       is(bookmarkPanel.state, "closed", "Panel should be 'closed' to start test");
       let shownPromise = promisePopupShown(bookmarkPanel);
       yield popupShowFn(browser);
       yield shownPromise;
       is(bookmarkPanel.state, "open", "Panel should be 'open' after shownPromise is resolved");
 
+    editBookmarkPanelRemoveButtonRect =
+      document.getElementById("editBookmarkPanelRemoveButton").getBoundingClientRect();
+
       if (popupEditFn) {
         yield popupEditFn();
       }
       let bookmarks = [];
       yield PlacesUtils.bookmarks.fetch({url: "about:home"}, bm => bookmarks.push(bm));
       is(bookmarks.length, 1, "Only one bookmark should exist");
       is(bookmarkStar.getAttribute("starred"), "true", "Page is starred");
       is(bookmarkPanelTitle.value,
@@ -358,11 +362,37 @@ add_task(function* enter_on_remove_bookm
         EventUtils.sendChar("VK_TAB", window);
       }
       EventUtils.sendChar("VK_RETURN", window);
     },
     isBookmarkRemoved: true,
   });
 });
 
+add_task(function* mouse_hovering_panel_should_prevent_autoclose() {
+  if (AppConstants.platform != "win") {
+    // This test requires synthesizing native mouse movement which is
+    // best supported on Windows.
+    return;
+  }
+  yield test_bookmarks_popup({
+    isNewBookmark: true,
+    *popupShowFn(browser) {
+      yield new Promise(resolve => {
+        EventUtils.synthesizeNativeMouseMove(
+          document.documentElement,
+          editBookmarkPanelRemoveButtonRect.left,
+          editBookmarkPanelRemoveButtonRect.top,
+          resolve);
+      });
+      EventUtils.synthesizeKey("D", {accelKey: true}, window);
+    },
+    shouldAutoClose: false,
+    popupHideFn() {
+      document.getElementById("editBookmarkPanelRemoveButton").click();
+    },
+    isBookmarkRemoved: true,
+  });
+});
+
 registerCleanupFunction(function() {
   delete StarUI._closePanelQuickForTesting;
 })