Bug 1251071 - "New bookmark" popup disappears if I reopen it after creating bookmark. r=mak
authorJared Wein <jwein@mozilla.com>
Wed, 06 Jul 2016 07:27:00 +0200
changeset 304060 88038ba05ff1a60014bb490ee7849d3b24cbdbfc
parent 304059 3468f546b0858d798b57d2bb020fcd309c154c48
child 304061 c8e993f36248d1f0ae66a6fd40af33786723796e
push id30411
push userkwierso@gmail.com
push dateFri, 08 Jul 2016 00:26:45 +0000
treeherdermozilla-central@23dc78b7b57e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1251071
milestone50.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 1251071 - "New bookmark" popup disappears if I reopen it after creating bookmark. r=mak MozReview-Commit-ID: DNqcu5vxrBG * * * MozReview-Commit-ID: 3KoNVklCK8d
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
@@ -20,17 +20,17 @@ var StarUI = {
   get panel() {
     delete this.panel;
     var element = this._element("editBookmarkPanel");
     // initially the panel is hidden
     // to avoid impacting startup / new window performance
     element.hidden = false;
     element.addEventListener("keypress", this, false);
     element.addEventListener("mouseout", this, false);
-    element.addEventListener("mouseover", this, false);
+    element.addEventListener("mousemove", this, false);
     element.addEventListener("popuphidden", this, false);
     element.addEventListener("popupshown", this, false);
     return this.panel = element;
   },
 
   // Array of command elements to disable when the panel is opened.
   get _blockedCommands() {
     delete this._blockedCommands;
@@ -58,17 +58,17 @@ var StarUI = {
         elt.removeAttribute("disabled");
       elt.removeAttribute("wasDisabled");
     });
   },
 
   // nsIDOMEventListener
   handleEvent(aEvent) {
     switch (aEvent.type) {
-      case "mouseover":
+      case "mousemove":
         clearTimeout(this._autoCloseTimer);
         break;
       case "popuphidden":
         clearTimeout(this._autoCloseTimer);
         if (aEvent.originalTarget == this.panel) {
           if (!this._element("editBookmarkPanelContent").hidden)
             this.quitEditMode();
 
@@ -125,33 +125,34 @@ var StarUI = {
               //XXX Why is this necessary? The defaultPrevented check should
               //    be enough.
               break;
             }
             this.panel.hidePopup();
             break;
         }
         break;
-      case "mouseout": {
+      case "mouseout":
+        // Explicit fall-through
+      case "popupshown":
         // Don't handle events for descendent elements.
         if (aEvent.target != aEvent.currentTarget) {
           break;
         }
-        // Explicit fall-through
-      }
-      case "popupshown":
         // auto-close if new and not interacted with
         if (this._isNewBookmark) {
           // 3500ms matches the timeout that Pocket uses in
           // browser/extensions/pocket/content/panels/js/saved.js
           let delay = 3500;
           if (this._closePanelQuickForTesting) {
             delay /= 10;
           }
-          this._autoCloseTimer = setTimeout(() => this.panel.hidePopup(), delay, this);
+          this._autoCloseTimer = setTimeout(() => {
+            this.panel.hidePopup();
+          }, delay);
         }
         break;
     }
   },
 
   _overlayLoaded: false,
   _overlayLoading: false,
   showEditBookmarkPopup: Task.async(function* (aNode, aAnchorElement, aPosition, aIsNewBookmark) {
--- a/browser/base/content/test/general/browser_bookmark_popup.js
+++ b/browser/base/content/test/general/browser_bookmark_popup.js
@@ -8,17 +8,16 @@
  * Test opening and closing the bookmarks panel.
  */
 
 let bookmarkPanel = document.getElementById("editBookmarkPanel");
 let bookmarkStar = document.getElementById("bookmarks-menu-button");
 let bookmarkPanelTitle = document.getElementById("editBookmarkPanelTitle");
 
 StarUI._closePanelQuickForTesting = true;
-Services.prefs.setBoolPref("browser.bookmarks.closePanelQuickForTesting", true);
 
 function* test_bookmarks_popup({isNewBookmark, popupShowFn, popupEditFn,
                                 shouldAutoClose, popupHideFn, isBookmarkRemoved}) {
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home");
   try {
     if (!isNewBookmark) {
       yield PlacesUtils.bookmarks.insert({
         parentGuid: PlacesUtils.bookmarks.unfiledGuid,
@@ -117,49 +116,36 @@ add_task(function* panel_shown_for_keybo
     popupShowFn() {
       EventUtils.synthesizeKey("D", {accelKey: true}, window);
     },
     shouldAutoClose: true,
     isBookmarkRemoved: false,
   });
 });
 
-add_task(function* panel_shown_for_new_bookmarks_mouseover_mouseout() {
+add_task(function* panel_shown_for_new_bookmarks_mousemove_mouseout() {
   yield test_bookmarks_popup({
     isNewBookmark: true,
     popupShowFn() {
       bookmarkStar.click();
     },
     *popupEditFn() {
-      let mouseOverPromise = new Promise(resolve => {
-        bookmarkPanel.addEventListener("mouseover", function onmouseover() {
-          bookmarkPanel.removeEventListener("mouseover", onmouseover);
-          resolve();
-        });
-      });
-      yield new Promise(resolve => {
-        EventUtils.synthesizeNativeMouseMove(bookmarkPanel, 0, 0, resolve, window);
-      });
-      info("Waiting for mouseover event");
-      yield mouseOverPromise;
-      info("Got mouseover event");
+      let mouseMovePromise = BrowserTestUtils.waitForEvent(bookmarkPanel, "mousemove");
+      EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {type: "mousemove"});
+      info("Waiting for mousemove event");
+      yield mouseMovePromise;
+      info("Got mousemove event");
 
       yield new Promise(resolve => setTimeout(resolve, 400));
-      is(bookmarkPanel.state, "open", "Panel should still be open on mouseover");
+      is(bookmarkPanel.state, "open", "Panel should still be open on mousemove");
     },
     *popupHideFn() {
-      let mouseOutPromise = new Promise(resolve => {
-        bookmarkPanel.addEventListener("mouseout", function onmouseout() {
-          bookmarkPanel.removeEventListener("mouseout", onmouseout);
-          resolve();
-        });
-      });
-      yield new Promise(resolve => {
-        EventUtils.synthesizeNativeMouseMove(bookmarkStar, 0, 0, resolve, window);
-      });
+      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;
       info("Got mouseout event, should autoclose now");
     },
     shouldAutoClose: false,
     isBookmarkRemoved: false,
   });
 });
@@ -262,11 +248,10 @@ add_task(function* ctrl_d_edit_bookmark_
     popupHideFn() {
       document.getElementById("editBookmarkPanelRemoveButton").click();
     },
     isBookmarkRemoved: true,
   });
 });
 
 registerCleanupFunction(function() {
-  Services.prefs.clearUserPref("browser.bookmarks.closePanelQuickForTesting");
   delete StarUI._closePanelQuickForTesting;
 })