Bug 1515810 - Fix intermittent issue in bookmark menu tests r=mixedpuppy
☠☠ backed out by 65b6d0b670b4 ☠ ☠
authorRob Wu <rob@robwu.nl>
Tue, 15 Jan 2019 14:05:31 +0000
changeset 453930 437003de9fffafd6656b79ea4bcbeab0aa652eef
parent 453929 c04c2376a2133c875df0e71749572688abe562a0
child 453931 23e161fc26d6ace03b87351d02a297710b4f578f
push id35380
push userdluca@mozilla.com
push dateTue, 15 Jan 2019 22:13:12 +0000
treeherdermozilla-central@a51d26029042 [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);
 
@@ -673,18 +672,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",
@@ -701,10 +699,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;