Bug 1495944: Add a test whether the menu items that open inspector was hidden. r=jdescottes
☠☠ backed out by f93fc53741db ☠ ☠
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 18 Jan 2019 11:54:26 +0000
changeset 514414 df656c9d03b1e141adc6d5a8a467baaea409b355
parent 514413 be64b571b600b15ab290ab162b66318048b5b3df
child 514415 025ffd6f441f637c739be150a462db49607c26ce
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
@@ -32,16 +32,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,67 @@
+/* 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 waitForRequestsToSettle(window.AboutDebugging.store);
+  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`);
+}