Bug 1335043 - Prevent the bookmark panel from closing automatically if the mouse is hovering over it. r=mak a=lizzard FENNEC_53_0b2_BUILD1 FENNEC_53_0b2_RELEASE FIREFOX_53_0b2_BUILD1 FIREFOX_53_0b2_RELEASE
authorJared Wein <jwein@mozilla.com>
Mon, 30 Jan 2017 10:34:53 -0500
changeset 379038 a5ccc32310c9a424ccb4f5106f5155ca20dd360a
parent 379037 6f254d491d00b67c0effe24fbe0b87cbc6f812b0
child 379039 2f9fc3b858d76c82088eef7604e6cb577483de64
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, lizzard
bugs1335043
milestone53.0
Bug 1335043 - Prevent the bookmark panel from closing automatically if the mouse is hovering over it. r=mak a=lizzard 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
@@ -184,17 +184,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);
           this._autoCloseTimerEnabled = true;
         }
         break;
     }
   },
 
   _overlayLoaded: 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) {
@@ -34,16 +35,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,
@@ -390,11 +394,37 @@ add_task(function* ctrl_d_new_bookmark_m
     shouldAutoClose: false,
     popupHideFn() {
       document.getElementById("editBookmarkPanelRemoveButton").click();
     },
     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;
 });