Bug 1515810 - Fix intermittent issue in bookmark menu tests r=mixedpuppy
☠☠ backed out by 6573f476d87a ☠ ☠
authorRob Wu <rob@robwu.nl>
Mon, 14 Jan 2019 15:44:32 +0000
changeset 513728 5f9ccc7b603903a2af362bc990e52bf6f059d398
parent 513727 732184f122e33f786637a338308efa5564d34a4e
child 513729 128c907bb39130afa5bdc4ee498ec4944d28d231
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1515810
milestone66.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 1515810 - Fix intermittent issue in bookmark menu tests r=mixedpuppy Depends on D16414 Differential Revision: https://phabricator.services.mozilla.com/D16425
browser/components/extensions/test/browser/browser_ext_contextMenus.js
browser/components/extensions/test/browser/browser_ext_menus.js
browser/components/extensions/test/browser/head.js
--- a/browser/components/extensions/test/browser/browser_ext_contextMenus.js
+++ b/browser/components/extensions/test/browser/browser_ext_contextMenus.js
@@ -558,33 +558,32 @@ function bookmarkContextMenuExtension() 
       });
     },
   });
 }
 
 add_task(async function test_bookmark_contextmenu() {
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PAGE);
 
-  const bookmarksToolbar = document.getElementById("PersonalToolbar");
-  setToolbarVisibility(bookmarksToolbar, true);
+  await toggleBookmarksToolbar(true);
 
   const extension = bookmarkContextMenuExtension();
 
   await extension.startup();
   await extension.awaitMessage("bookmark-created");
   let menu = await openChromeContextMenu(
     "placesContext",
     "#PersonalToolbar .bookmark-item:last-child");
 
   let menuItem = menu.getElementsByAttribute("label", "Get bookmark")[0];
   closeChromeContextMenu("placesContext", menuItem);
 
   await extension.awaitMessage("test-finish");
   await extension.unload();
-  setToolbarVisibility(bookmarksToolbar, false);
+  await toggleBookmarksToolbar(false);
 
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function test_bookmark_sidebar_contextmenu() {
   await withSidebarTree("bookmarks", async (tree) => {
     let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PAGE);
 
@@ -668,18 +667,17 @@ add_task(async function test_organizer_c
     await extension.unload();
   }
 
   await promiseLibraryClosed(library);
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function test_bookmark_context_requires_permission() {
-  const bookmarksToolbar = document.getElementById("PersonalToolbar");
-  setToolbarVisibility(bookmarksToolbar, true);
+  await toggleBookmarksToolbar(true);
 
   const extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["contextMenus"],
     },
     background() {
       browser.contextMenus.create({
         title: "Get bookmark",
@@ -696,10 +694,10 @@ add_task(async function test_bookmark_co
     "#PersonalToolbar .bookmark-item:last-child");
 
   Assert.equal(menu.getElementsByAttribute("label", "Get bookmark").length, 0,
                "bookmark context menu not created with `bookmarks` permission.");
 
   closeChromeContextMenu("placesContext");
 
   await extension.unload();
-  setToolbarVisibility(bookmarksToolbar, false);
+  await toggleBookmarksToolbar(false);
 });
--- a/browser/components/extensions/test/browser/browser_ext_menus.js
+++ b/browser/components/extensions/test/browser/browser_ext_menus.js
@@ -160,53 +160,44 @@ add_task(async function test_hiddenPageA
   await closeChromeContextMenu(menu.id);
   await closeChromeContextMenu(BrowserPageActions.panelNode.id);
 
   BrowserTestUtils.removeTab(tab);
   await extension.unload();
 });
 
 add_task(async function test_bookmarkContextMenu() {
-  async function showBookmarksToolbar(visible = true) {
-    let bt = document.getElementById("PersonalToolbar");
-    let transitionPromise =
-      BrowserTestUtils.waitForEvent(bt, "transitionend",
-                                    e => e.propertyName == "max-height");
-    setToolbarVisibility(bt, visible);
-    await transitionPromise;
-  }
-
   const ext = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["menus", "bookmarks"],
     },
     background() {
       browser.menus.onShown.addListener(() => {
         browser.test.sendMessage("hello");
       });
       browser.menus.create({title: "blarg", contexts: ["bookmark"]}, () => {
         browser.test.sendMessage("ready");
       });
     },
   });
 
-  await showBookmarksToolbar();
+  await toggleBookmarksToolbar(true);
   await ext.startup();
   await ext.awaitMessage("ready");
 
   let menu = await openChromeContextMenu("placesContext",
                                          "#PlacesToolbarItems .bookmark-item");
   let children = Array.from(menu.children);
   let item = children[children.length - 1];
   is(item.label, "blarg", "Menu item label is correct");
   await ext.awaitMessage("hello"); // onShown listener fired
 
   closeChromeContextMenu("placesContext", item);
   await ext.unload();
-  await showBookmarksToolbar(false);
+  await toggleBookmarksToolbar(false);
 });
 
 add_task(async function test_tabContextMenu() {
   const first = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["menus"],
     },
     async background() {
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -3,16 +3,17 @@
 "use strict";
 
 /* exported CustomizableUI makeWidgetId focusWindow forceGC
  *          getBrowserActionWidget
  *          clickBrowserAction clickPageAction
  *          getBrowserActionPopup getPageActionPopup getPageActionButton
  *          closeBrowserAction closePageAction
  *          promisePopupShown promisePopupHidden
+ *          toggleBookmarksToolbar
  *          openContextMenu closeContextMenu
  *          openContextMenuInSidebar openContextMenuInPopup
  *          openExtensionContextMenu closeExtensionContextMenu
  *          openActionContextMenu openSubmenu closeActionContextMenu
  *          openTabContextMenu closeTabContextMenu
  *          openToolsMenu closeToolsMenu
  *          imageBuffer imageBufferFromDataURI
  *          getListStyleImage getPanelForNode
@@ -282,16 +283,26 @@ function closeBrowserAction(extension, w
   let group = getBrowserActionWidget(extension);
 
   let node = win.document.getElementById(group.viewId);
   CustomizableUI.hidePanelForNode(node);
 
   return Promise.resolve();
 }
 
+async function toggleBookmarksToolbar(visible = true) {
+  let bookmarksToolbar = document.getElementById("PersonalToolbar");
+  let transitionPromise =
+    BrowserTestUtils.waitForEvent(bookmarksToolbar, "transitionend",
+                                  e => e.propertyName == "max-height");
+
+  setToolbarVisibility(bookmarksToolbar, visible);
+  await transitionPromise;
+}
+
 async function openContextMenuInPopup(extension, selector = "body") {
   let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
   let browser = await awaitExtensionPanel(extension);
   let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
   await BrowserTestUtils.synthesizeMouseAtCenter(selector, {type: "mousedown", button: 2}, browser);
   await BrowserTestUtils.synthesizeMouseAtCenter(selector, {type: "contextmenu"}, browser);
   await popupShownPromise;
   return contentAreaContextMenu;