Bug 1515265: Add a test for context menu of the markup view in about:devtools-toolbox. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 25 Jan 2019 08:08:35 +0000
changeset 455433 319ae34add89185fc5cc96e3a8b6ac71592f9b10
parent 455432 635099091943c0ff81849ec224ac3e1ecc4a768e
child 455434 bec3fe861b0652f81ba635eee4155b8063430d5a
push id76789
push userdakatsuka@mozilla.com
push dateFri, 25 Jan 2019 13:59:44 +0000
treeherderautoland@319ae34add89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1515265
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 1515265: Add a test for context menu of the markup view in about:devtools-toolbox. r=jdescottes Depends on D17458 Differential Revision: https://phabricator.services.mozilla.com/D17597
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu_markupview.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -36,16 +36,17 @@ skip-if = (os == 'linux' && bits == 32) 
 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_contextmenu_markupview.js]
 [browser_aboutdebugging_devtoolstoolbox_menubar.js]
 [browser_aboutdebugging_devtoolstoolbox_shortcuts.js]
 skip-if = (os == "win" && ccov) # Bug 1521349
 [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]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu_markupview.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 of markup view 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("Select inspector tool");
+  const devtoolsBrowser = gBrowser.selectedBrowser;
+  const devtoolsDocument = devtoolsBrowser.contentDocument;
+  const devtoolsWindow = devtoolsBrowser.contentWindow;
+  const toolbox = getToolbox(devtoolsWindow);
+  await toolbox.selectTool("inspector");
+
+  info("Show context menu of markup view");
+  const markupFrame = getMarkupViewFrame(devtoolsDocument);
+  const markupDocument = markupFrame.contentDocument;
+  const markupWindow = markupFrame.contentWindow;
+  EventUtils.synthesizeMouseAtCenter(markupDocument.body,
+                                     { type: "contextmenu" },
+                                     markupWindow);
+
+  info("Check whether proper context menu of markup view will be shown");
+  await waitUntil(() => devtoolsDocument.querySelector("#node-menu-edithtml"));
+  ok(true, "Context menu of markup view should be shown");
+
+  await removeTab(devtoolsTab);
+  await Promise.all([
+    waitForRequestsToSettle(window.AboutDebugging.store),
+    gDevTools.once("toolbox-destroyed"),
+  ]);
+  await removeTab(tab);
+});
+
+function getMarkupViewFrame(rootDocument) {
+  const inspectorFrame = rootDocument.querySelector("#toolbox-panel-iframe-inspector");
+  return inspectorFrame.contentDocument.querySelector("#markup-box iframe");
+}
+
+function getToolbox(win) {
+  return gDevTools.getToolboxes().find(toolbox => toolbox.win === win);
+}