Bug 1455462 - Part 6. Add test of confirming the position of 'all menu' popup. r=jdescottes, a=RyanVM
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Mon, 14 May 2018 17:19:00 -0400
changeset 473347 ea0bb21de30467e052dbc8913e6571aae86d241e
parent 473346 abd62e896138d08e0fcf69542a0b3dec1b2cf11a
child 473348 f13fb5d37547d5e9d870bf92557f18354446883f
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, RyanVM
bugs1455462
milestone61.0
Bug 1455462 - Part 6. Add test of confirming the position of 'all menu' popup. r=jdescottes, a=RyanVM The accessing all menu button will be shown to the inspector, so this test will use inspector's this button. This button didn't have an id, so this patch will add id for testing. MozReview-Commit-ID: 2xFXYKwpQoe
devtools/client/framework/test/browser_toolbox_zoom_popup.js
--- a/devtools/client/framework/test/browser_toolbox_zoom_popup.js
+++ b/devtools/client/framework/test/browser_toolbox_zoom_popup.js
@@ -18,84 +18,90 @@ add_task(async function() {
   Services.prefs.setCharPref("devtools.toolbox.zoomValue", zoom.toString(10));
 
   info("Load iframe page for checking the frame menu with x1.5 zoom.");
   await addTab(TEST_URL);
   let target = TargetFactory.forTab(gBrowser.selectedTab);
   let toolbox = await gDevTools.showToolbox(target,
                                             "inspector",
                                             Toolbox.HostType.WINDOW);
+  let inspector = toolbox.getCurrentPanel();
   let hostWindow = toolbox.win.parent;
   let originWidth = hostWindow.outerWidth;
   let originHeight = hostWindow.outerHeight;
   let windowUtils = toolbox.win.QueryInterface(Ci.nsIInterfaceRequestor)
       .getInterface(Ci.nsIDOMWindowUtils);
 
   info("Waiting for the toolbox window will to be rendered with zoom x1.5");
   await waitUntil(() => {
     return parseFloat(windowUtils.fullZoom.toFixed(1)) === parseFloat(zoom);
   });
 
   info("Resizing and moving the toolbox window in order to display the chevron menu.");
   // If window is displayed bottom of screen, menu might be displayed above of button.
   hostWindow.moveTo(0, 0);
 
   // This size will display inspector's tabs menu button and chevron menu button of toolbox.
+  let prevTabs = toolbox.doc.querySelectorAll(".devtools-tab").length;
   hostWindow.resizeTo(400, hostWindow.outerHeight);
   await waitUntil(() => {
     return hostWindow.screen.top === 0 &&
       hostWindow.screen.left === 0 &&
       hostWindow.outerWidth === 400 &&
-      toolbox.doc.getElementById("tools-chevron-menu-button");
+      toolbox.doc.getElementById("tools-chevron-menu-button") &&
+      inspector.panelDoc.querySelector(".all-tabs-menu") &&
+      prevTabs != toolbox.doc.querySelectorAll(".devtools-tab").length;
   });
 
-  let menuList = ["toolbox-meatball-menu-button",
-                  "command-button-frames",
-                  "tools-chevron-menu-button"];
+  let menuList =
+    [toolbox.win.document.getElementById("toolbox-meatball-menu-button"),
+     toolbox.win.document.getElementById("command-button-frames"),
+     toolbox.win.document.getElementById("tools-chevron-menu-button"),
+     inspector.panelDoc.querySelector(".all-tabs-menu")];
 
   for (const menu of menuList) {
     let [btnRect, menuRect] = await getButtonAndMenuRects(toolbox, menu);
 
     // Allow rounded error and platform offset value.
     // horizontal : eIntID_ContextMenuOffsetHorizontal of GTK and Windows uses 2.
     // vertical: eIntID_ContextMenuOffsetVertical of macOS uses -6.
     let xDelta = Math.abs(menuRect.left - btnRect.left);
     let yDelta = Math.abs(menuRect.top - btnRect.bottom);
-    ok(xDelta < 2, "xDelta is lower than 2: " + xDelta + ". #" + menu);
-    ok(yDelta < 6, "yDelta is lower than 6: " + yDelta + ". #" + menu);
+    ok(xDelta < 2, "xDelta is lower than 2: " + xDelta + ". #" + menu.id);
+    ok(yDelta < 6, "yDelta is lower than 6: " + yDelta + ". #" + menu.id);
   }
 
   let onResize = once(hostWindow, "resize");
   hostWindow.resizeTo(originWidth, originHeight);
   await onResize;
 
   await toolbox.destroy();
   gBrowser.removeCurrentTab();
 });
 
 /**
  * Getting the rectangle of the menu button and popup menu.
- *  - The menu button rectangle will be calculated from specified button id.
+ *  - The menu button rectangle will be calculated from specified button.
  *  - The popup menu rectangle will be calculated from displayed popup menu
- *    which clicking the button of specified button id.
+ *    which clicking the specified button.
  */
-async function getButtonAndMenuRects(toolbox, btnId) {
-  let doc = toolbox.doc;
-  let menuButton = doc.getElementById(btnId);
+async function getButtonAndMenuRects(toolbox, menuButton) {
+  info("Show popup menu with click event.");
   menuButton.click();
 
-  let popupset = doc.querySelector("popupset");
+  let popupset = toolbox.doc.querySelector("popupset");
   let menuPopup;
   await waitUntil(() => {
     menuPopup = popupset.querySelector("menupopup[menu-api=\"true\"]");
     return !!menuPopup && menuPopup.state === "open";
   });
   ok(menuPopup, "Menu popup is displayed.");
 
   let btnRect = menuButton.getBoxQuads({relativeTo: toolbox.doc})[0].bounds;
   let menuRect = menuPopup.getBoxQuads({relativeTo: toolbox.doc})[0].bounds;
 
+  info("Hide popup menu.");
   let onPopupHidden = once(menuPopup, "popuphidden");
   menuPopup.hidePopup();
   await onPopupHidden;
 
   return [btnRect, menuRect];
 }