Bug 1251107 - Move the mouseout code to popupHideFn(). r?gijs draft
authorJared Wein <jwein@mozilla.com>
Thu, 25 Feb 2016 00:30:37 -0500
changeset 334409 a6589a40fd7c5cf26743b11b76cff4d5b726717e
parent 334408 e86f91dd77be96bc473c02acf581a4a19d3073ef
child 514904 0a63a706355b117b25617029f717c01d68b93683
push id11540
push userjwein@mozilla.com
push dateThu, 25 Feb 2016 05:30:56 +0000
reviewersgijs
bugs1251107
milestone47.0a1
Bug 1251107 - Move the mouseout code to popupHideFn(). r?gijs The mouseout code triggers the hiding of the popup, but it was previously in the popupEditFn meaning that it ran before we expected the popup to close, which caused this race condition. I also had to tweak the contextmenu test because it was depending on a mousedown/click which we are no longer listening for (we replaced that with mouseover/mouseout). MozReview-Commit-ID: 5mZujGuto5g
browser/base/content/test/general/browser_bookmark_popup.js
--- a/browser/base/content/test/general/browser_bookmark_popup.js
+++ b/browser/base/content/test/general/browser_bookmark_popup.js
@@ -46,16 +46,17 @@ function* test_bookmarks_popup({isNewBoo
     is(bookmarkPanelTitle.value,
       isNewBookmark ?
         gNavigatorBundle.getString("editBookmarkPanel.pageBookmarkedTitle") :
         gNavigatorBundle.getString("editBookmarkPanel.editBookmarkTitle"),
       "title should match isEditingBookmark state");
 
     if (!shouldAutoClose) {
       yield new Promise(resolve => setTimeout(resolve, 400));
+      is(bookmarkPanel.state, "open", "Panel should still be 'open' for non-autoclose");
     }
 
     let hiddenPromise = promisePopupHidden(bookmarkPanel);
     if (popupHideFn) {
       yield popupHideFn();
     }
     yield hiddenPromise;
     is(bookmarkStar.hasAttribute("starred"), !isBookmarkRemoved,
@@ -139,31 +140,32 @@ add_task(function* panel_shown_for_new_b
         EventUtils.synthesizeNativeMouseMove(bookmarkPanel, 0, 0, resolve, window);
       });
       info("Waiting for mouseover event");
       yield mouseOverPromise;
       info("Got mouseover event");
 
       yield new Promise(resolve => setTimeout(resolve, 400));
       is(bookmarkPanel.state, "open", "Panel should still be open on mouseover");
-
+    },
+    *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);
       });
       info("Waiting for mouseout event");
       yield mouseOutPromise;
       info("Got mouseout event, should autoclose now");
     },
-    shouldAutoClose: true,
+    shouldAutoClose: false,
     isBookmarkRemoved: false,
   });
 });
 
 add_task(function* panel_shown_for_new_bookmark_no_autoclose_close_with_ESC() {
   yield test_bookmarks_popup({
     isNewBookmark: false,
     popupShowFn() {
@@ -203,17 +205,17 @@ add_task(function* panel_shown_for_new_b
     shouldAutoClose: false,
     popupHideFn() {
       bookmarkPanel.hidePopup();
     },
     isBookmarkRemoved: false,
   });
 });
 
-add_task(function* contextmenu_new_bookmark_click_no_autoclose() {
+add_task(function* contextmenu_new_bookmark_keypress_no_autoclose() {
   yield test_bookmarks_popup({
     isNewBookmark: true,
     *popupShowFn(browser) {
       let contextMenu = document.getElementById("contentAreaContextMenu");
       let awaitPopupShown = BrowserTestUtils.waitForEvent(contextMenu,
                                                           "popupshown");
       let awaitPopupHidden = BrowserTestUtils.waitForEvent(contextMenu,
                                                            "popuphidden");
@@ -222,17 +224,17 @@ add_task(function* contextmenu_new_bookm
         button: 2
       }, browser);
       yield awaitPopupShown;
       document.getElementById("context-bookmarkpage").click();
       contextMenu.hidePopup();
       yield awaitPopupHidden;
     },
     popupEditFn() {
-      bookmarkPanelTitle.click();
+      EventUtils.sendChar("VK_TAB", window);
     },
     shouldAutoClose: false,
     popupHideFn() {
       bookmarkPanel.hidePopup();
     },
     isBookmarkRemoved: false,
   });
 });