Bug 1495944: Add a test for context menu in about:devtools-toolbox. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 18 Jan 2019 16:25:13 +0000
changeset 511585 bffac1c44562c7e035666fedde46a3f12841be9f
parent 511584 1f135369b9f9b8f1127d62aecbffa30fd05c09d1
child 511586 e3d901befdc1ee6acc2e176ce192fd1cfc6258e3
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [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 for context menu in about:devtools-toolbox. r=jdescottes Depends on D16686 Differential Revision: https://phabricator.services.mozilla.com/D16687
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu.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_contextmenu.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]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu.js
@@ -0,0 +1,68 @@
+/* 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 context menu on about:devtools-toolbox page.
+ */
+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 item which opens devtools is disabled");
+  const rootDocument = devtoolsTab.ownerDocument;
+  await assertContextMenu(rootDocument, gBrowser.selectedBrowser,
+                          ".debug-target-info", false);
+
+  info("Force to select about:debugging page");
+  gBrowser.selectedTab = tab;
+  info("Check whether the menu item which opens devtools is enabled");
+  await assertContextMenu(rootDocument, gBrowser.selectedBrowser, "#mount", true);
+
+  await removeTab(devtoolsTab);
+  await Promise.all([
+    waitForRequestsToSettle(window.AboutDebugging.store),
+    gDevTools.once("toolbox-destroyed"),
+  ]);
+  await removeTab(tab);
+});
+
+async function assertContextMenu(rootDocument, browser, targetSelector, shouldBeEnabled) {
+  // Show content context menu.
+  const contextMenu = rootDocument.getElementById("contentAreaContextMenu");
+  const popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
+  BrowserTestUtils.synthesizeMouseAtCenter(targetSelector,
+                                           { type: "contextmenu" }, browser);
+  await popupShownPromise;
+
+  // Check hidden attribute of #context-inspect.
+  const inspectMenuItem = rootDocument.getElementById("context-inspect");
+  is(inspectMenuItem.hidden, !shouldBeEnabled,
+     '"hidden" attribute of #context-inspect should be correct');
+
+  // Hide content context menu.
+  const popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
+  contextMenu.hidePopup();
+  await popupHiddenPromise;
+}