Bug 1495944: Add a test whether the menu items that open inspector was hidden. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 18 Jan 2019 16:24:29 +0000
changeset 514466 1f135369b9f9b8f1127d62aecbffa30fd05c09d1
parent 514465 4674df9d14e3126a0ab6644e29b666823426bb9c
child 514467 bffac1c44562c7e035666fedde46a3f12841be9f
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)
reviewersjdescottes
bugs1495944
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 1495944: Add a test whether the menu items that open inspector was hidden. r=jdescottes Depends on D16685 Differential Revision: https://phabricator.services.mozilla.com/D16686
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_menubar.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -35,16 +35,17 @@ skip-if = (os == 'linux' && bits == 32) 
 [browser_aboutdebugging_connect_toggle_usb_devices.js]
 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
 [browser_aboutdebugging_connection_prompt_setting.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_preference.js]
 [browser_aboutdebugging_debug-target-pane_empty.js]
 [browser_aboutdebugging_debug-target-pane_usb_runtime.js]
 [browser_aboutdebugging_devtools.js]
+[browser_aboutdebugging_devtoolstoolbox_menubar.js]
 [browser_aboutdebugging_navigate.js]
 [browser_aboutdebugging_persist_connection.js]
 [browser_aboutdebugging_routes.js]
 [browser_aboutdebugging_runtime_connection-prompt.js]
 [browser_aboutdebugging_runtime_usbclient_closed.js]
 [browser_aboutdebugging_select_network_runtime.js]
 [browser_aboutdebugging_select_page_with_serviceworker.js]
 [browser_aboutdebugging_serviceworker_multie10s.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_menubar.js
@@ -0,0 +1,70 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/* import-globals-from helper-collapsibilities.js */
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
+
+/**
+ * Test the status of menu items when open about:devtools-toolbox.
+ */
+add_task(async function() {
+  info("Force all debug target panes to be expanded");
+  prepareCollapsibilitiesTest();
+
+  const { document, tab, window } = await openAboutDebugging();
+
+  info("Show about:devtools-toolbox page");
+  const target = findDebugTargetByText("about:debugging", document);
+  ok(target, "about:debugging tab target appeared");
+  const inspectButton = target.querySelector(".js-debug-target-inspect-button");
+  ok(inspectButton, "Inspect button for about:debugging appeared");
+  inspectButton.click();
+  await Promise.all([
+    waitUntil(() => tab.nextElementSibling),
+    waitForRequestsToSettle(window.AboutDebugging.store),
+    gDevTools.once("toolbox-ready"),
+  ]);
+
+  info("Wait for about:devtools-toolbox tab will be selected");
+  const devtoolsTab = tab.nextElementSibling;
+  await waitUntil(() => gBrowser.selectedTab === devtoolsTab);
+  info("Check whether the menu items are disabled");
+  const rootDocument = devtoolsTab.ownerDocument;
+  await assertMenusItems(rootDocument, false);
+
+  info("Force to select about:debugging page");
+  gBrowser.selectedTab = tab;
+  info("Check whether the menu items are enabled");
+  await assertMenusItems(rootDocument, true);
+
+  await removeTab(devtoolsTab);
+  await Promise.all([
+    waitForRequestsToSettle(window.AboutDebugging.store),
+    gDevTools.once("toolbox-destroyed"),
+  ]);
+  await removeTab(tab);
+});
+
+async function assertMenusItems(rootDocument, shouldBeEnabled) {
+  const menuItem = rootDocument.getElementById("menu_devToolbox");
+  // Wait for hidden attribute changed since the menu items will update asynchronously.
+  await waitUntil(() => menuItem.hidden === !shouldBeEnabled);
+
+  assertMenuItem(rootDocument, "menu_devToolbox", shouldBeEnabled);
+
+  for (const toolDefinition of gDevTools.getToolDefinitionArray()) {
+    if (!toolDefinition.inMenu) {
+      continue;
+    }
+
+    assertMenuItem(rootDocument, "menuitem_" + toolDefinition.id, shouldBeEnabled);
+  }
+}
+
+function assertMenuItem(rootDocument, menuItemId, shouldBeEnabled) {
+  const menuItem = rootDocument.getElementById(menuItemId);
+  is(menuItem.hidden, !shouldBeEnabled,
+     `"hidden" attribute of menu item(${ menuItemId }) should be correct`);
+}