--- a/devtools/client/framework/test/shared-head.js
+++ b/devtools/client/framework/test/shared-head.js
@@ -3,17 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// This shared-head.js file is used for multiple mochitest test directories in
// devtools.
// It contains various common helper functions.
-var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr, Constructor: CC} = Components;
function scopedCuImport(path) {
const scope = {};
Cu.import(path, scope);
return scope;
}
const {Services} = scopedCuImport("resource://gre/modules/Services.jsm");
@@ -193,18 +193,20 @@ var openToolboxForTab = Task.async(funct
info("Opening the toolbox");
let toolbox;
let target = TargetFactory.forTab(tab);
// Check if the toolbox is already loaded.
toolbox = gDevTools.getToolbox(target);
if (toolbox) {
- info("Toolbox is already opened");
- return toolbox;
+ if (!toolId || (toolId && toolbox.getPanel(toolId))) {
+ info("Toolbox is already opened");
+ return toolbox;
+ }
}
// If not, load it now.
toolbox = yield gDevTools.showToolbox(target, toolId, hostType);
// Make sure that the toolbox frame is focused.
yield new Promise(resolve => waitForFocus(resolve, toolbox.frame.contentWindow));
--- a/devtools/client/inspector/test/browser_inspector_breadcrumbs.js
+++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs.js
@@ -1,16 +1,16 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the breadcrumbs widget content is correct.
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_breadcrumbs.html";
+const TEST_URI = URL_ROOT + "doc_inspector_breadcrumbs.html";
const NODES = [
{selector: "#i1111", result: "i1 i11 i111 i1111"},
{selector: "#i22", result: "i2 i22 i221"},
{selector: "#i2111", result: "i2 i21 i211 i2111"},
{selector: "#i21", result: "i2 i21 i211 i2111"},
{selector: "#i22211", result: "i2 i22 i222 i2221 i22211"},
{selector: "#i22", result: "i2 i22 i222 i2221 i22211"},
{selector: "#i3", result: "i3 i31"},
--- a/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js
+++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js
@@ -1,16 +1,16 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the breadcrumbs keybindings work.
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_breadcrumbs.html";
+const TEST_URI = URL_ROOT + "doc_inspector_breadcrumbs.html";
const TEST_DATA = [{
desc: "Pressing left should select the parent <body>",
key: "VK_LEFT",
newSelection: "body"
}, {
desc: "Pressing left again should select the parent <html>",
key: "VK_LEFT",
newSelection: "html"
--- a/devtools/client/inspector/test/browser_inspector_breadcrumbs_menu.js
+++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs_menu.js
@@ -2,17 +2,17 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the inspector node context menu appears when right-clicking on the
// breadcrumbs nodes.
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_breadcrumbs.html";
+const TEST_URI = URL_ROOT + "doc_inspector_breadcrumbs.html";
add_task(function*() {
let {inspector} = yield openInspectorForURL(TEST_URI);
let container = inspector.panelDoc.getElementById("inspector-breadcrumbs");
info("Select a test node and try to right-click on the selected breadcrumb");
yield selectNode("#i1", inspector);
let button = container.querySelector("button[checked]");
--- a/devtools/client/inspector/test/browser_inspector_breadcrumbs_mutations.js
+++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs_mutations.js
@@ -2,17 +2,17 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the breadcrumbs widget refreshes correctly when there are markup
// mutations (and that it doesn't refresh when those mutations don't change its
// output).
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_breadcrumbs.html";
+const TEST_URI = URL_ROOT + "doc_inspector_breadcrumbs.html";
// Each item in the TEST_DATA array is a test case that should contain the
// following properties:
// - desc {String} A description of this test case (will be logged).
// - setup {Function*} A generator function (can yield promises) that sets up
// the test case. Useful for selecting a node before starting the test.
// - run {Function*} A generator function (can yield promises) that runs the
// actual test case, i.e, mutates the content DOM to cause the breadcrumbs
--- a/devtools/client/inspector/test/browser_inspector_delete-selected-node-01.js
+++ b/devtools/client/inspector/test/browser_inspector_delete-selected-node-01.js
@@ -1,16 +1,16 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test to ensure inspector handles deletion of selected node correctly.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_delete-selected-node-01.html";
+const TEST_URL = URL_ROOT + "doc_inspector_delete-selected-node-01.html";
add_task(function* () {
let {inspector} = yield openInspectorForURL(TEST_URL);
let span = yield getNodeFrontInFrame("span", "iframe", inspector);
yield selectNode(span, inspector);
info("Removing selected <span> element.");
--- a/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js
+++ b/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js
@@ -4,17 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that when nodes are being deleted in the page, the current selection
// and therefore the markup view, css rule view, computed view, font view,
// box model view, and breadcrumbs, reset accordingly to show the right node
-const TEST_PAGE = TEST_URL_ROOT +
+const TEST_PAGE = URL_ROOT +
"doc_inspector_delete-selected-node-02.html";
add_task(function* () {
let { inspector } = yield openInspectorForURL(TEST_PAGE);
yield testManuallyDeleteSelectedNode();
yield testAutomaticallyDeleteSelectedNode();
yield testDeleteSelectedNodeContainerFrame();
--- a/devtools/client/inspector/test/browser_inspector_delete-selected-node-03.js
+++ b/devtools/client/inspector/test/browser_inspector_delete-selected-node-03.js
@@ -1,17 +1,17 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test to ensure inspector can handle destruction of selected node inside an
// iframe.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_delete-selected-node-01.html";
+const TEST_URL = URL_ROOT + "doc_inspector_delete-selected-node-01.html";
add_task(function* () {
let { inspector } = yield openInspectorForURL(TEST_URL);
let iframe = yield getNodeFront("iframe", inspector);
let node = yield getNodeFrontInFrame("span", iframe, inspector);
yield selectNode(node, inspector);
--- a/devtools/client/inspector/test/browser_inspector_gcli-inspect-command.js
+++ b/devtools/client/inspector/test/browser_inspector_gcli-inspect-command.js
@@ -1,16 +1,16 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing that the gcli 'inspect' command works as it should.
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_gcli-inspect-command.html";
+const TEST_URI = URL_ROOT + "doc_inspector_gcli-inspect-command.html";
add_task(function* () {
return helpers.addTabWithToolbar(TEST_URI, function(options) {
return helpers.audit(options, [
{
setup: "inspect",
check: {
input: 'inspect',
--- a/devtools/client/inspector/test/browser_inspector_highlighter-02.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-02.js
@@ -3,17 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the highlighter is correctly displayed over a variety of elements
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_highlighter.html";
+const TEST_URI = URL_ROOT + "doc_inspector_highlighter.html";
add_task(function*() {
let {toolbox, inspector, testActor} = yield openInspectorForURL(TEST_URI);
info("Selecting the simple, non-transformed DIV");
yield selectAndHighlightNode("#simple-div", inspector);
let isVisible = yield testActor.isHighlighting();
--- a/devtools/client/inspector/test/browser_inspector_highlighter-comments.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-comments.js
@@ -10,17 +10,17 @@
// Whitelisting this test.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
//
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("false");
// Test that hovering over the markup-view's containers doesn't always show the
// highlighter, depending on the type of node hovered over.
-const TEST_PAGE = TEST_URL_ROOT +
+const TEST_PAGE = URL_ROOT +
"doc_inspector_highlighter-comments.html";
add_task(function* () {
let {toolbox, inspector, testActor} = yield openInspectorForURL(TEST_PAGE);
let markupView = inspector.markup;
yield selectNode("p", inspector);
info("Hovering over #id1 and waiting for highlighter to appear.");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-csstransform_02.js
@@ -13,17 +13,17 @@ comparing with the result of getAdjusted
There's a separate test for checking that getAdjustedQuads actually returns
sensible values
(devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js),
so the present test doesn't care about that, it just verifies that the css
transform highlighter applies those values correctly to the SVG elements
*/
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_csstransform.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_csstransform.html";
add_task(function*() {
let {inspector, toolbox, testActor} = yield openInspectorForURL(TEST_URL);
let front = inspector.inspector;
let highlighter = yield front.getHighlighterByType("CssTransformHighlighter");
let nodeFront = yield getNodeFront("#test-node", inspector);
--- a/devtools/client/inspector/test/browser_inspector_highlighter-geometry_03.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-geometry_03.js
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the right arrows/labels are shown even when the css properties are
// in several different css rules.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter-geometry_01.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter-geometry_01.html";
const ID = "geometry-editor-";
const PROPS = ["left", "right", "top", "bottom"];
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
let front = inspector.inspector;
let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-geometry_04.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-geometry_04.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the arrows are positioned correctly and have the right size.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter-geometry_01.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter-geometry_01.html";
const ID = "geometry-editor-";
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
let front = inspector.inspector;
let highlighter = yield front.getHighlighterByType("GeometryEditorHighlighter");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-geometry_05.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-geometry_05.js
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the arrows and offsetparent and currentnode elements of the
// geometry highlighter only appear when needed.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter-geometry_02.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter-geometry_02.html";
const ID = "geometry-editor-";
const TEST_DATA = [{
selector: "body",
isOffsetParentVisible: false,
isCurrentNodeVisible: false,
hasVisibleArrows: false,
isSizeVisible: false
--- a/devtools/client/inspector/test/browser_inspector_highlighter-inline.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-inline.js
@@ -4,17 +4,17 @@
"use strict";
requestLongerTimeout(2);
// Test that highlighting various inline boxes displays the right number of
// polygons in the page.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_inline.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_inline.html";
const TEST_DATA = [
"body",
"h1",
"h2",
"h2 em",
"p",
"p span",
// The following test case used to fail. See bug 1139925.
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_01.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_01.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the keybindings for Picker work alright
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_dom.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_dom.html";
add_task(function*() {
let {inspector, toolbox, testActor} = yield openInspectorForURL(TEST_URL);
info("Starting element picker");
yield toolbox.highlighterUtils.startPicker();
info("Selecting the simple-div1 DIV");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_02.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_02.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the keybindings for Picker work alright
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_dom.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_dom.html";
add_task(function*() {
let {inspector, toolbox, testActor} = yield openInspectorForURL(TEST_URL);
info("Starting element picker");
yield toolbox.highlighterUtils.startPicker();
// Previously chosen child memory
--- a/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_03.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-keybinding_03.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the keybindings for Picker work alright
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_dom.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_dom.html";
add_task(function*() {
let {inspector, toolbox, testActor} = yield openInspectorForURL(TEST_URL);
info("Starting element picker");
yield toolbox.highlighterUtils.startPicker();
info("Selecting the #another DIV");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-rect_02.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-rect_02.js
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Test that the custom rect highlighter positions the rectangle relative to the
// viewport of the context node we pass to it.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_rect.html";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_rect.html";
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URL);
let front = inspector.inspector;
let highlighter = yield front.getHighlighterByType("RectHighlighter");
info("Showing the rect highlighter in the context of the iframe");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-xbl.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-xbl.js
@@ -1,16 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the picker works correctly with XBL anonymous nodes
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_highlighter_xbl.xul";
+const TEST_URL = URL_ROOT + "doc_inspector_highlighter_xbl.xul";
add_task(function*() {
let {inspector, toolbox, testActor} = yield openInspectorForURL(TEST_URL);
info("Starting element picker");
yield toolbox.highlighterUtils.startPicker();
info("Selecting the scale");
--- a/devtools/client/inspector/test/browser_inspector_infobar_01.js
+++ b/devtools/client/inspector/test/browser_inspector_infobar_01.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Check the position and text content of the highlighter nodeinfo bar.
-const TEST_URI = TEST_URL_ROOT + "doc_inspector_infobar_01.html";
+const TEST_URI = URL_ROOT + "doc_inspector_infobar_01.html";
add_task(function*() {
let {inspector, testActor} = yield openInspectorForURL(TEST_URI);
let testData = [
{
selector: "#top",
position: "bottom",
--- a/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts-copy-outerhtml.js
+++ b/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts-copy-outerhtml.js
@@ -1,16 +1,16 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test copy outer HTML from the keyboard/copy event
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_outerhtml.html";
+const TEST_URL = URL_ROOT + "doc_inspector_outerhtml.html";
add_task(function *() {
let { inspector } = yield openInspectorForURL(TEST_URL);
let root = inspector.markup._elt;
info("Test copy outerHTML for COMMENT node");
let comment = getElementByType(inspector, Ci.nsIDOMNode.COMMENT_NODE);
yield setSelectionNodeFront(comment, inspector);
--- a/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-01-sensitivity.js
@@ -1,16 +1,16 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that context menu items are enabled / disabled correctly.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
+const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
const PASTE_MENU_ITEMS = [
"node-menu-pasteinnerhtml",
"node-menu-pasteouterhtml",
"node-menu-pastebefore",
"node-menu-pasteafter",
"node-menu-pastefirstchild",
"node-menu-pastelastchild",
--- a/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-02-copy-items.js
@@ -1,16 +1,16 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the various copy items in the context menu works correctly.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
+const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
const COPY_ITEMS_TEST_DATA = [
{
desc: "copy inner html",
id: "node-menu-copyinner",
selector: "[data-id=\"copy\"]",
text: "Paragraph for testing copy",
},
{
--- a/devtools/client/inspector/test/browser_inspector_menu-03-paste-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-03-paste-items.js
@@ -1,17 +1,17 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that different paste items work in the context menu
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
+const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
const PASTE_ADJACENT_HTML_DATA = [
{
desc: "As First Child",
clipboardData: "2",
menuId: "node-menu-pastefirstchild",
},
{
desc: "As Last Child",
--- a/devtools/client/inspector/test/browser_inspector_menu-04-use-in-console.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-04-use-in-console.js
@@ -1,16 +1,16 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests "Use in Console" menu item
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
+const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.toolbox.splitconsoleEnabled");
});
add_task(function* () {
let { inspector, toolbox } = yield openInspectorForURL(TEST_URL);
--- a/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js
@@ -1,16 +1,16 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that attribute items work in the context menu
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
+const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
add_task(function* () {
let { inspector, toolbox, testActor } = yield openInspectorForURL(TEST_URL);
yield selectNode("#attributes", inspector);
yield testAddAttribute();
yield testEditAttribute();
yield testRemoveAttribute();
--- a/devtools/client/inspector/test/browser_inspector_menu-06-other.js
+++ b/devtools/client/inspector/test/browser_inspector_menu-06-other.js
@@ -1,15 +1,15 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests for menuitem functionality that doesn't fit into any specific category
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
+const TEST_URL = URL_ROOT + "doc_inspector_menu.html";
add_task(function* () {
let { inspector, toolbox, testActor } = yield openInspectorForURL(TEST_URL);
yield testShowDOMProperties();
yield testDuplicateNode();
yield testDeleteNode();
yield testDeleteRootNode();
yield testScrollIntoView();
function* testShowDOMProperties() {
--- a/devtools/client/inspector/test/browser_inspector_remove-iframe-during-load.js
+++ b/devtools/client/inspector/test/browser_inspector_remove-iframe-during-load.js
@@ -1,17 +1,17 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing that the inspector doesn't go blank when navigating to a page that
// deletes an iframe while loading.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_remove-iframe-during-load.html";
+const TEST_URL = URL_ROOT + "doc_inspector_remove-iframe-during-load.html";
add_task(function* () {
let {inspector, toolbox, testActor} = yield openInspectorForURL("about:blank");
yield selectNode("body", inspector);
// We do not want to wait for the inspector to be fully ready before testing
// so we load TEST_URL and just wait for the content window to be done loading.
yield testActor.loadAndWaitForCustomEvent(TEST_URL);
--- a/devtools/client/inspector/test/browser_inspector_search-01.js
+++ b/devtools/client/inspector/test/browser_inspector_search-01.js
@@ -1,17 +1,17 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that searching for nodes in the search field actually selects those
// nodes.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_search.html";
+const TEST_URL = URL_ROOT + "doc_inspector_search.html";
// The various states of the inspector: [key, id, isValid]
// [
// what key to press,
// what id should be selected after the keypress,
// is the searched text valid selector
// ]
const KEY_STATES = [
--- a/devtools/client/inspector/test/browser_inspector_search-02.js
+++ b/devtools/client/inspector/test/browser_inspector_search-02.js
@@ -1,17 +1,17 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing that searching for combining selectors using the inspector search
// field produces correct suggestions.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_search-suggestions.html";
+const TEST_URL = URL_ROOT + "doc_inspector_search-suggestions.html";
// An array of (key, suggestions) pairs where key is a key to press and
// suggestions is an array of suggestions that should be shown in the popup.
// Suggestion is an object with label of the entry and optional count
// (defaults to 1)
const TEST_DATA = [
{
key: "d",
--- a/devtools/client/inspector/test/browser_inspector_search-03.js
+++ b/devtools/client/inspector/test/browser_inspector_search-03.js
@@ -1,17 +1,17 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing that searching for elements using the inspector search field
// produces correct suggestions.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_search.html";
+const TEST_URL = URL_ROOT + "doc_inspector_search.html";
// An array of (key, suggestions) pairs where key is a key to press and
// suggestions is an array of suggestions that should be shown in the popup.
// Suggestion is an object with label of the entry and optional count
// (defaults to 1)
var TEST_DATA = [
{
key: "d",
--- a/devtools/client/inspector/test/browser_inspector_search-04.js
+++ b/devtools/client/inspector/test/browser_inspector_search-04.js
@@ -3,18 +3,18 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing that searching for elements inside iframes does work.
const IFRAME_SRC = "doc_inspector_search.html";
const TEST_URL = "data:text/html;charset=utf-8," +
"<div class=\"c1 c2\">" +
- "<iframe src=\"" + TEST_URL_ROOT + IFRAME_SRC + "\"></iframe>" +
- "<iframe src=\"" + TEST_URL_ROOT + IFRAME_SRC + "\"></iframe>";
+ "<iframe src=\"" + URL_ROOT + IFRAME_SRC + "\"></iframe>" +
+ "<iframe src=\"" + URL_ROOT + IFRAME_SRC + "\"></iframe>";
// An array of (key, suggestions) pairs where key is a key to press and
// suggestions is an array of suggestions that should be shown in the popup.
// Suggestion is an object with label of the entry and optional count
// (defaults to 1)
var TEST_DATA = [
{
key: "d",
--- a/devtools/client/inspector/test/browser_inspector_search-05.js
+++ b/devtools/client/inspector/test/browser_inspector_search-05.js
@@ -4,22 +4,22 @@
"use strict";
// Testing that when search results contain suggestions for nodes in other
// frames, selecting these suggestions actually selects the right nodes.
const IFRAME_SRC = "doc_inspector_search.html";
const TEST_URL = "data:text/html;charset=utf-8," +
"<iframe id=\"iframe-1\" src=\"" +
- TEST_URL_ROOT + IFRAME_SRC + "\"></iframe>" +
+ URL_ROOT + IFRAME_SRC + "\"></iframe>" +
"<iframe id=\"iframe-2\" src=\"" +
- TEST_URL_ROOT + IFRAME_SRC + "\"></iframe>" +
+ URL_ROOT + IFRAME_SRC + "\"></iframe>" +
"<iframe id='iframe-3' src='data:text/html," +
"<button id=\"b1\">Nested button</button>" +
- "<iframe id=\"iframe-4\" src=" + TEST_URL_ROOT + IFRAME_SRC + "></iframe>'>" +
+ "<iframe id=\"iframe-4\" src=" + URL_ROOT + IFRAME_SRC + "></iframe>'>" +
"</iframe>";
add_task(function* () {
let {inspector} = yield openInspectorForURL(TEST_URL);
let searchBox = inspector.searchBox;
let popup = inspector.searchSuggestions.searchPopup;
--- a/devtools/client/inspector/test/browser_inspector_search-06.js
+++ b/devtools/client/inspector/test/browser_inspector_search-06.js
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Check that searching again for nodes after they are removed or added from the
// DOM works correctly.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_search.html";
+const TEST_URL = URL_ROOT + "doc_inspector_search.html";
add_task(function* () {
let { inspector, testActor } = yield openInspectorForURL(TEST_URL);
info("Searching for test node #d1");
yield focusSearchBoxUsingShortcut(inspector.panelWin);
yield synthesizeKeys(["#", "d", "1", "VK_RETURN"], inspector);
--- a/devtools/client/inspector/test/browser_inspector_search-07.js
+++ b/devtools/client/inspector/test/browser_inspector_search-07.js
@@ -1,16 +1,16 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that searching for classes on SVG elements does work (see bug 1219920).
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_search-svg.html";
+const TEST_URL = URL_ROOT + "doc_inspector_search-svg.html";
// An array of (key, suggestions) pairs where key is a key to press and
// suggestions is an array of suggestions that should be shown in the popup.
const TEST_DATA = [{
key: "c",
suggestions: ["circle", ".class1", ".class2"]
}, {
key: "VK_BACK_SPACE",
--- a/devtools/client/inspector/test/browser_inspector_search-navigation.js
+++ b/devtools/client/inspector/test/browser_inspector_search-navigation.js
@@ -49,17 +49,17 @@ const KEY_STATES = [
["VK_BACK_SPACE", "div.l"],
["VK_BACK_SPACE", "div."],
["VK_BACK_SPACE", "div"],
["VK_BACK_SPACE", "di"],
["VK_BACK_SPACE", "d"],
["VK_BACK_SPACE", ""],
];
-const TEST_URL = TEST_URL_ROOT +
+const TEST_URL = URL_ROOT +
"doc_inspector_search-suggestions.html";
add_task(function* () {
let { inspector } = yield openInspectorForURL(TEST_URL);
yield focusSearchBoxUsingShortcut(inspector.panelWin);
for (let [key, query] of KEY_STATES) {
info("Pressing key " + key + " to get searchbox value as " + query);
--- a/devtools/client/inspector/test/browser_inspector_search-reserved.js
+++ b/devtools/client/inspector/test/browser_inspector_search-reserved.js
@@ -1,15 +1,15 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Testing searching for ids and classes that contain reserved characters.
-const TEST_URL = TEST_URL_ROOT + "doc_inspector_search-reserved.html";
+const TEST_URL = URL_ROOT + "doc_inspector_search-reserved.html";
// An array of (key, suggestions) pairs where key is a key to press and
// suggestions is an array of suggestions that should be shown in the popup.
// Suggestion is an object with label of the entry and optional count
// (defaults to 1)
const TEST_DATA = [
{
key: "#",
@@ -30,26 +30,26 @@ const TEST_DATA = [
{
key: ".",
suggestions: [{label: ".c1\\.c2"}]
},
{
key: "c",
suggestions: [{label: ".c1\\.c2"}]
},
- {
- key: "VK_BACK_SPACE",
+ {
+ key: "VK_BACK_SPACE",
suggestions: [{label: ".c1\\.c2"}]
},
{
key: "VK_BACK_SPACE",
suggestions: []
},
{
- key: "d",
+ key: "d",
suggestions: [{label: "div"},
{label: "#d1\\.d2"}]
},
{
key: "VK_BACK_SPACE",
suggestions: []
},
{
@@ -58,29 +58,29 @@ const TEST_DATA = [
},
{
key: "VK_BACK_SPACE",
suggestions: []
},
{
key: "b",
suggestions: [{label: "body"}]
- },
+ },
{
key: "o",
suggestions: [{label: "body"}]
},
{
key: "d",
suggestions: [{label: "body"}]
},
- {
+ {
key: "y",
suggestions: []
- },
+ },
{
key: " ",
suggestions: [{label: "body div"}]
},
{
key: ".",
suggestions: [{label: "body .c1\\.c2"}]
},
--- a/devtools/client/inspector/test/browser_inspector_search-suggests-ids-and-classes.js
+++ b/devtools/client/inspector/test/browser_inspector_search-suggests-ids-and-classes.js
@@ -61,17 +61,17 @@ function test()
function $(id) {
if (id == null) return null;
return content.document.getElementById(id);
}
function setupTest()
{
- openInspector(startTest);
+ openInspector().then(startTest);
}
function startTest(aInspector)
{
inspector = aInspector;
searchBox =
inspector.panelWin.document.getElementById("inspector-searchbox");
--- a/devtools/client/inspector/test/browser_inspector_select-last-selected.js
+++ b/devtools/client/inspector/test/browser_inspector_select-last-selected.js
@@ -1,18 +1,18 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Checks that the expected default node is selected after a page navigation or
// a reload.
-var PAGE_1 = TEST_URL_ROOT + "doc_inspector_select-last-selected-01.html";
-var PAGE_2 = TEST_URL_ROOT + "doc_inspector_select-last-selected-02.html";
+var PAGE_1 = URL_ROOT + "doc_inspector_select-last-selected-01.html";
+var PAGE_2 = URL_ROOT + "doc_inspector_select-last-selected-02.html";
// An array of test cases with following properties:
// - url: URL to navigate to. If URL == content.location, reload instead.
// - nodeToSelect: a selector for a node to select before navigation. If null,
// whatever is selected stays selected.
// - selectedNode: a selector for a node that is selected after navigation.
var TEST_DATA = [
{
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -1,45 +1,36 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
-var Cu = Components.utils;
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var CC = Components.Constructor;
+// Load the shared-head file first.
+Services.scriptloader.loadSubScript(
+ "chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js", this);
// Services.prefs.setBoolPref("devtools.debugger.log", true);
// SimpleTest.registerCleanupFunction(() => {
// Services.prefs.clearUserPref("devtools.debugger.log");
// });
// Uncomment this pref to dump all devtools emitted events to the console.
// Services.prefs.setBoolPref("devtools.dump.emit", true);
-var TEST_URL_ROOT = "http://example.com/browser/devtools/client/inspector/test/";
var ROOT_TEST_DIR = getRootDirectory(gTestPath);
-// All test are asynchronous
-waitForExplicitFinish();
-
-var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
-var {TargetFactory} = require("devtools/client/framework/target");
-var {console} = Cu.import("resource://gre/modules/Console.jsm", {});
-var DevToolsUtils = require("devtools/shared/DevToolsUtils");
-var promise = require("promise");
-
// Import the GCLI test helper
var testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
-Services.scriptloader.loadSubScript(testDir + "../../../commandline/test/helpers.js", this);
+Services.scriptloader.loadSubScript(
+ testDir + "../../../commandline/test/helpers.js", this);
// Import helpers registering the test-actor in remote targets
-Services.scriptloader.loadSubScript(testDir + "../../../shared/test/test-actor-registry.js", this);
+Services.scriptloader.loadSubScript(
+ testDir + "../../../shared/test/test-actor-registry.js", this);
DevToolsUtils.testing = true;
registerCleanupFunction(() => {
DevToolsUtils.testing = false;
});
registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.dump.emit");
@@ -56,35 +47,16 @@ registerCleanupFunction(function*() {
// another test moves the mouse.
EventUtils.synthesizeMouseAtPoint(1, 1, {type: "mousemove"}, window);
while (gBrowser.tabs.length > 1) {
gBrowser.removeCurrentTab();
}
});
-/**
- * Add a new test tab in the browser and load the given url.
- * @param {String} url The url to be loaded in the new tab
- * @return a promise that resolves to the tab object when the url is loaded
- */
-var addTab = Task.async(function* (url) {
- info("Adding a new tab with URL: '" + url + "'");
-
- window.focus();
-
- let tab = gBrowser.selectedTab = gBrowser.addTab(url);
- let browser = tab.linkedBrowser;
-
- yield once(browser, "load", true);
- info("URL '" + url + "' loading complete");
-
- return tab;
-});
-
var navigateTo = function (toolbox, url) {
let activeTab = toolbox.target.activeTab;
return activeTab.navigateTo(url);
};
/**
* Simple DOM node accesor function that takes either a node or a string css
* selector as argument and returns the corresponding node
@@ -157,71 +129,40 @@ var selectNode = Task.async(function*(se
* Open the inspector in a tab with given URL.
* @param {string} url The URL to open.
* @param {String} hostType Optional hostType, as defined in Toolbox.HostType
* @return A promise that is resolved once the tab and inspector have loaded
* with an object: { tab, toolbox, inspector }.
*/
var openInspectorForURL = Task.async(function*(url, hostType) {
let tab = yield addTab(url);
- let { inspector, toolbox, testActor } = yield openInspector(null, hostType);
+ let { inspector, toolbox, testActor } = yield openInspector(hostType);
return { tab, inspector, toolbox, testActor };
});
-
/**
* Open the toolbox, with the inspector tool visible.
- * @param {Function} cb Optional callback, if you don't want to use the returned
- * promise
* @param {String} hostType Optional hostType, as defined in Toolbox.HostType
* @return a promise that resolves when the inspector is ready
*/
-var openInspector = Task.async(function*(cb, hostType) {
+var openInspector = Task.async(function*(hostType) {
info("Opening the inspector");
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- let toolbox = gDevTools.getToolbox(target);
- if (toolbox) {
- if (toolbox.getPanel("inspector")) {
- info("Toolbox and inspector already open");
- throw new Error("Inspector is already opened, please use getActiveInspector");
- }
- }
-
- info("Opening the toolbox");
- toolbox = yield gDevTools.showToolbox(target, "inspector", hostType);
- yield waitForToolboxFrameFocus(toolbox);
+ let toolbox = yield openToolboxForTab(gBrowser.selectedTab, "inspector", hostType);
let inspector = toolbox.getPanel("inspector");
info("Waiting for the inspector to update");
yield inspector.once("inspector-updated");
yield registerTestActor(toolbox.target.client);
let testActor = yield getTestActor(toolbox);
- return {
- toolbox: toolbox,
- inspector: inspector,
- testActor: testActor
- };
+ return {toolbox, inspector, testActor};
});
-/**
- * Wait for the toolbox frame to receive focus after it loads
- * @param {Toolbox} toolbox
- * @return a promise that resolves when focus has been received
- */
-function waitForToolboxFrameFocus(toolbox) {
- info("Making sure that the toolbox's frame is focused");
- let def = promise.defer();
- let win = toolbox.frame.contentWindow;
- waitForFocus(def.resolve, win);
- return def.promise;
-}
-
function getActiveInspector() {
let target = TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.getToolbox(target).getPanel("inspector");
}
/**
* Get the NodeFront for a node that matches a given css selector, via the
* protocol.
@@ -251,50 +192,23 @@ function getNodeFront(selector, {walker}
*/
var getNodeFrontInFrame = Task.async(function*(selector, frameSelector,
inspector, reason="test") {
let iframe = yield getNodeFront(frameSelector, inspector);
let {nodes} = yield inspector.walker.children(iframe);
return inspector.walker.querySelector(nodes[0], selector);
});
-function synthesizeKeyFromKeyTag(aKeyId, aDocument = null) {
- let document = aDocument || document;
- let key = document.getElementById(aKeyId);
- isnot(key, null, "Successfully retrieved the <key> node");
-
- let modifiersAttr = key.getAttribute("modifiers");
-
- let name = null;
-
- if (key.getAttribute("keycode"))
- name = key.getAttribute("keycode");
- else if (key.getAttribute("key"))
- name = key.getAttribute("key");
-
- isnot(name, null, "Successfully retrieved keycode/key");
-
- let modifiers = {
- shiftKey: modifiersAttr.match("shift"),
- ctrlKey: modifiersAttr.match("ctrl"),
- altKey: modifiersAttr.match("alt"),
- metaKey: modifiersAttr.match("meta"),
- accelKey: modifiersAttr.match("accel")
- }
-
- EventUtils.synthesizeKey(name, modifiers);
-}
-
var focusSearchBoxUsingShortcut = Task.async(function* (panelWin, callback) {
info("Focusing search box");
let searchBox = panelWin.document.getElementById("inspector-searchbox");
let focused = once(searchBox, "focus");
panelWin.focus();
- synthesizeKeyFromKeyTag("nodeSearchKey", panelWin.document);
+ synthesizeKeyFromKeyTag(panelWin.document.getElementById("nodeSearchKey"));
yield focused;
if (callback) {
callback();
}
});
@@ -384,48 +298,16 @@ function mouseLeaveMarkupView(inspector)
EventUtils.synthesizeMouseAtCenter(btn, {type: "mousemove"},
inspector.toolbox.doc.defaultView);
executeSoon(def.resolve);
return def.promise;
}
/**
- * Wait for eventName on target.
- * @param {Object} target An observable object that either supports on/off or
- * addEventListener/removeEventListener
- * @param {String} eventName
- * @param {Boolean} useCapture Optional, for addEventListener/removeEventListener
- * @return A promise that resolves when the event has been handled
- */
-function once(target, eventName, useCapture=false) {
- info("Waiting for event: '" + eventName + "' on " + target + ".");
-
- let deferred = promise.defer();
-
- for (let [add, remove] of [
- ["addEventListener", "removeEventListener"],
- ["addListener", "removeListener"],
- ["on", "off"]
- ]) {
- if ((add in target) && (remove in target)) {
- target[add](eventName, function onEvent(...aArgs) {
- info("Got event: '" + eventName + "' on " + target + ".");
- target[remove](eventName, onEvent, useCapture);
- deferred.resolve.apply(deferred, aArgs);
- }, useCapture);
- break;
- }
- }
-
- return deferred.promise;
-}
-
-
-/**
* Dispatch the copy event on the given element
*/
function fireCopyEvent(element) {
let evt = element.ownerDocument.createEvent("Event");
evt.initEvent("copy", true, true);
element.dispatchEvent(evt);
}