From 896bcb6f7dd31bdac0b731f4d004c168df9e02c2 Mon Sep 17 00:00:00 2001 From: Daisuke Akatsuka Date: Fri, 25 Jan 2019 08:08:35 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- .../test/browser/browser.ini | 1 + ..._devtoolstoolbox_contextmenu_markupview.js | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu_markupview.js diff --git a/devtools/client/aboutdebugging-new/test/browser/browser.ini b/devtools/client/aboutdebugging-new/test/browser/browser.ini index 8dd0fa9d15fb..aaeb6d66e5a5 100644 --- a/devtools/client/aboutdebugging-new/test/browser/browser.ini +++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini @@ -41,6 +41,7 @@ skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug [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 diff --git a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu_markupview.js b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtoolstoolbox_contextmenu_markupview.js new file mode 100644 index 000000000000..d6e09c71c513 --- /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); +}