Bug 1335043 - Prevent the bookmark panel from closing automatically if the mouse is hovering over it. r=mak a=lizzard
☠☠ backed out by 6f254d491d00 ☠ ☠
authorJared Wein <jwein@mozilla.com>
Mon, 30 Jan 2017 10:34:53 -0500
changeset 379028 fe89c5aec076db809af03c3d0aa2ca7de52f3b6d
parent 379027 97967b1668830f6e88ce9bc086607494a3ba2c31
child 379029 43555a2b5ac65bccd47905689fbd1a916c0ef424
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,
@@ -358,16 +362,42 @@ 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,
+  });
+});
+
 add_task(function* ctrl_d_new_bookmark_mousedown_mouseout_no_autoclose() {
   yield test_bookmarks_popup({
     isNewBookmark: true,
     popupShowFn(browser) {
       EventUtils.synthesizeKey("D", {accelKey: true}, window);
     },
     *popupEditFn() {
       let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove");
@@ -381,20 +411,14 @@ add_task(function* ctrl_d_new_bookmark_m
 
       EventUtils.synthesizeMouseAtCenter(bookmarkPanelTitle, {button: 1, type: "mousedown"});
 
       let mouseOutPromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mouseout");
       EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, {type: "mouseout"});
       EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
       info("Waiting for mouseout event");
       yield mouseOutPromise;
-    },
-    shouldAutoClose: false,
-    popupHideFn() {
-      document.getElementById("editBookmarkPanelRemoveButton").click();
-    },
-    isBookmarkRemoved: true,
+    });
   });
-});
 
 registerCleanupFunction(function() {
   delete StarUI._closePanelQuickForTesting;
 });