diff --git a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js index cf99563b0c78..b055bb24340d 100644 --- a/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js +++ b/browser/devtools/inspector/test/browser_inspector_breadcrumbs.js @@ -1,100 +1,54 @@ +/* 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"; -function test() -{ - ignoreAllUncaughtExceptions(); +// Test that the breadcrumbs widget content is correct. - let nodes = [ - {nodeId: "i1111", result: "i1 i11 i111 i1111"}, - {nodeId: "i22", result: "i2 i22 i221"}, - {nodeId: "i2111", result: "i2 i21 i211 i2111"}, - {nodeId: "i21", result: "i2 i21 i211 i2111"}, - {nodeId: "i22211", result: "i2 i22 i222 i2221 i22211"}, - {nodeId: "i22", result: "i2 i22 i222 i2221 i22211"}, - ]; +const TEST_URI = TEST_URL_ROOT + "browser_inspector_breadcrumbs.html"; +const NODES = [ + {nodeId: "#i1111", result: "i1 i11 i111 i1111"}, + {nodeId: "#i22", result: "i2 i22 i221"}, + {nodeId: "#i2111", result: "i2 i21 i211 i2111"}, + {nodeId: "#i21", result: "i2 i21 i211 i2111"}, + {nodeId: "#i22211", result: "i2 i22 i222 i2221 i22211"}, + {nodeId: "#i22", result: "i2 i22 i222 i2221 i22211"}, +]; - let doc; - let nodes; - let cursor; - let inspector; - let target; - let panel; - let container; +let test = asyncTest(function*() { + let { inspector } = yield openInspectorForURL(TEST_URI); + let container = inspector.panelDoc.getElementById("inspector-breadcrumbs"); - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(setupTest, content); - }, true); + for (let node of NODES) { + info("Testing node " + node.nodeId); - content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_breadcrumbs.html"; + let documentNode = getNode(node.nodeId); - function setupTest() - { - for (let i = 0; i < nodes.length; i++) { - let node = doc.getElementById(nodes[i].nodeId); - nodes[i].node = node; - ok(nodes[i].node, "node " + nodes[i].nodeId + " found"); - } + info("Selecting node and waiting for breadcrumbs to update"); + let breadcrumbsUpdated = inspector.once("breadcrumbs-updated"); + let nodeSelected = selectNode(documentNode, inspector); - openInspector(runTests); - } + yield Promise.all([breadcrumbsUpdated, nodeSelected]); - function runTests(aInspector) - { - inspector = aInspector; - target = TargetFactory.forTab(gBrowser.selectedTab); - panel = gDevTools.getToolbox(target).getPanel("inspector"); - container = panel.panelDoc.getElementById("inspector-breadcrumbs"); - cursor = 0; - inspector.on("breadcrumbs-updated", nodeSelected); - executeSoon(function() { - inspector.selection.setNode(nodes[0].node); - }); - } - - function nodeSelected() - { - performTest(); - cursor++; - - if (cursor >= nodes.length) { - inspector.off("breadcrumbs-updated", nodeSelected); - // breadcrumbs-updated is an event that is fired before the rest of the - // inspector is updated, so there'll be hanging connections if we finish - // up before waiting for everything to end. - inspector.once("inspector-updated", finishUp); - } else { - let node = nodes[cursor].node; - inspector.selection.setNode(node); - } - } - - function performTest() - { - let buttonsLabelIds = nodes[cursor].result.split(" "); + info("Performing checks for node " + node.nodeId); + let buttonsLabelIds = node.result.split(" "); // html > body > … - is(container.childNodes.length, buttonsLabelIds.length + 2, "Node " + cursor + ": Items count"); + is(container.childNodes.length, buttonsLabelIds.length + 2, + "Node " + node.nodeId + ": Items count"); for (let i = 2; i < container.childNodes.length; i++) { let expectedId = "#" + buttonsLabelIds[i - 2]; let button = container.childNodes[i]; let labelId = button.querySelector(".breadcrumbs-widget-item-id"); - is(labelId.textContent, expectedId, "Node " + cursor + ": button " + i + " matches"); + is(labelId.textContent, expectedId, + "Node #" + node.nodeId + ": button " + i + " matches"); } let checkedButton = container.querySelector("button[checked]"); let labelId = checkedButton.querySelector(".breadcrumbs-widget-item-id"); let id = inspector.selection.node.id; - is(labelId.textContent, "#" + id, "Node " + cursor + ": selection matches"); + is(labelId.textContent, "#" + id, + "Node #" + node.nodeId + ": selection matches"); } - - function finishUp() { - doc = nodes = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - } -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_650804_search.js b/browser/devtools/inspector/test/browser_inspector_bug_650804_search.js index e2225722d03c..12aa741ebeb8 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_650804_search.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_650804_search.js @@ -1,118 +1,82 @@ +/* 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"; -function test() -{ - let inspector, searchBox, state; - let keypressStates = [3,4,8,18,19,20,21,22]; +// Test that searching for nodes in the search field actually selects those +// nodes. - // 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 - // ] - let keyStates = [ - ["d", "b1", false], - ["i", "b1", false], - ["v", "d1", true], - ["VK_DOWN", "d2", true], - ["VK_RETURN", "d1", true], - [".", "d1", false], - ["c", "d1", false], - ["1", "d2", true], - ["VK_DOWN", "d2", true], - ["VK_BACK_SPACE", "d2", false], - ["VK_BACK_SPACE", "d2", false], - ["VK_BACK_SPACE", "d1", true], - ["VK_BACK_SPACE", "d1", false], - ["VK_BACK_SPACE", "d1", false], - ["VK_BACK_SPACE", "d1", true], - [".", "d1", false], - ["c", "d1", false], - ["1", "d2", true], - ["VK_DOWN", "s2", true], - ["VK_DOWN", "p1", true], - ["VK_UP", "s2", true], - ["VK_UP", "d2", true], - ["VK_UP", "p1", true], - ["VK_BACK_SPACE", "p1", false], - ["2", "p3", true], - ["VK_BACK_SPACE", "p3", false], - ["VK_BACK_SPACE", "p3", false], - ["VK_BACK_SPACE", "p3", true], - ["r", "p3", false], - ]; +const TEST_URL = TEST_URL_ROOT + "browser_inspector_bug_650804_search.html"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(setupTest, content); - }, true); +// Indexes of the keys in the KEY_STATES array that should listen to "keypress" +// event instead of "command". These are keys that don't change the content of +// the search field and thus don't trigger command event. +const LISTEN_KEYPRESS = [3,4,8,18,19,20,21,22]; - content.location = "http://mochi.test:8888/browser/browser/devtools/" + - "inspector/test/browser_inspector_bug_650804_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 = [ + ["d", "b1", false], + ["i", "b1", false], + ["v", "d1", true], + ["VK_DOWN", "d2", true], // keypress + ["VK_RETURN", "d1", true], //keypress + [".", "d1", false], + ["c", "d1", false], + ["1", "d2", true], + ["VK_DOWN", "d2", true], // keypress + ["VK_BACK_SPACE", "d2", false], + ["VK_BACK_SPACE", "d2", false], + ["VK_BACK_SPACE", "d1", true], + ["VK_BACK_SPACE", "d1", false], + ["VK_BACK_SPACE", "d1", false], + ["VK_BACK_SPACE", "d1", true], + [".", "d1", false], + ["c", "d1", false], + ["1", "d2", true], + ["VK_DOWN", "s2", true], // keypress + ["VK_DOWN", "p1", true], // kepress + ["VK_UP", "s2", true], // keypress + ["VK_UP", "d2", true], // keypress + ["VK_UP", "p1", true], + ["VK_BACK_SPACE", "p1", false], + ["2", "p3", true], + ["VK_BACK_SPACE", "p3", false], + ["VK_BACK_SPACE", "p3", false], + ["VK_BACK_SPACE", "p3", true], + ["r", "p3", false], +]; - function $(id) { - if (id == null) return null; - return content.document.getElementById(id); - } +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URL); + let { searchBox } = inspector; - function setupTest() - { - openInspector(startTest); - } + yield selectNode("#b1", inspector); + yield focusSearchBoxUsingShortcut(inspector.panelWin); - function startTest(aInspector) - { - inspector = aInspector; - inspector.selection.setNode($("b1")); + let index = 0; + for (let [ key, id, isValid ] of KEY_STATES) { + let event = (LISTEN_KEYPRESS.indexOf(index) !== -1) ? "keypress" : "command"; + let eventHandled = once(searchBox, event, true); - searchBox = - inspector.panelWin.document.getElementById("inspector-searchbox"); - - focusSearchBoxUsingShortcut(inspector.panelWin, function() { - searchBox.addEventListener("command", checkState, true); - searchBox.addEventListener("keypress", checkState, true); - checkStateAndMoveOn(0); - }); - } - - function checkStateAndMoveOn(index) { - if (index == keyStates.length) { - finishUp(); - return; - } - - let [key, id, isValid] = keyStates[index]; - state = index; - - info("pressing key " + key + " to get id " + id); + info(index + ": Pressing key " + key + " to get id " + id); EventUtils.synthesizeKey(key, {}, inspector.panelWin); - } + yield eventHandled; - function checkState(event) { - if (event.type == "keypress" && keypressStates.indexOf(state) == -1) { - return; - } + info("Got " + event + " event. Waiting for search query to complete"); + yield inspector.searchSuggestions._lastQuery; - inspector.searchSuggestions._lastQuery.then(() => { - executeSoon(() => { - let [key, id, isValid] = keyStates[state]; - info(inspector.selection.node.id + " is selected with text " + - inspector.searchBox.value); - is(inspector.selection.node, $(id), - "Correct node is selected for state " + state); - is(!searchBox.classList.contains("devtools-no-search-result"), isValid, - "Correct searchbox result state for state " + state); - checkStateAndMoveOn(state + 1); - }); - }); - } + info(inspector.selection.node.id + " is selected with text " + + searchBox.value); + is(inspector.selection.node, content.document.getElementById(id), + "Correct node is selected for state " + index); + is(!searchBox.classList.contains("devtools-no-search-result"), isValid, + "Correct searchbox result state for state " + index); - function finishUp() { - searchBox = null; - gBrowser.removeCurrentTab(); - finish(); + index++; } -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_665880.js b/browser/devtools/inspector/test/browser_inspector_bug_665880.js index c811f42aa8a8..d7002086b526 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_665880.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_665880.js @@ -1,44 +1,18 @@ +/* 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"; -function test() { - ignoreAllUncaughtExceptions(); +// A regression test for bug 665880 to make sure elements inside can +// be inspected without exceptions. - let doc; - let objectNode; +const TEST_URI = "data:text/html;charset=utf-8," + + "

browser_inspector_inspect-object-element.js

"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function() { - gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); - doc = content.document; - waitForFocus(setupObjectInspectionTest, content); - }, true); +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URI); + let objectNode = getNode("object"); + ok(objectNode, "We have the object node"); - content.location = "data:text/html,

foobar

"; - - function setupObjectInspectionTest() { - objectNode = doc.querySelector("object"); - ok(objectNode, "we have the object node"); - openInspector(runObjectInspectionTest); - } - - function runObjectInspectionTest(inspector) { - inspector.once("inspector-updated", performTestComparison); - inspector.selection.setNode(objectNode, ""); - } - - function performTestComparison() { - is(getActiveInspector().selection.node, objectNode, "selection matches node"); - let target = TargetFactory.forTab(gBrowser.selectedTab); - executeSoon(function() { - gDevTools.closeToolbox(target); - finishUp(); - }); - } - - function finishUp() { - doc = objectNode = null; - gBrowser.removeCurrentTab(); - finish(); - } -} + yield selectNode(objectNode, inspector); +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js b/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js index 9c7a9cc8fed9..c1f4f6ee726e 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js @@ -1,92 +1,40 @@ +/* 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"; // Tests that the keybindings for highlighting different elements work as // intended. -function test() -{ - let doc; - let node; - let inspector; +const TEST_URI = "data:text/html;charset=utf-8," + + "Test for the highlighter keybindings" + + "

Hello

Greetings, earthlings!" + + " I come in peace.

"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(setupKeyBindingsTest, content); - }, true); +const TEST_DATA = [ + { key: "VK_RIGHT", selectedNode: "h1" }, + { key: "VK_DOWN", selectedNode: "p" }, + { key: "VK_UP", selectedNode: "h1" }, + { key: "VK_LEFT", selectedNode: "body" }, +]; - content.location = "data:text/html,Test for the " + - "highlighter keybindings

Hello" + - "

Greetings, earthlings! I come" + - " in peace."; +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URI); + is(inspector.selection.node, getNode("body"), + "Body should be selected initially."); - function setupKeyBindingsTest() - { - openInspector(findAndHighlightNode); + info("Focusing the currently active breadcrumb button"); + let bc = inspector.breadcrumbs; + bc.nodeHierarchy[bc.currentIndex].button.focus(); + + for (let { key, selectedNode } of TEST_DATA) { + info("Pressing " + key + " to select " + selectedNode); + + let updated = inspector.once("inspector-updated"); + EventUtils.synthesizeKey(key, {}); + yield updated; + + is(inspector.selection.node, getNode(selectedNode), + selectedNode + " is selected."); } - - function findAndHighlightNode(aInspector, aToolbox) - { - inspector = aInspector; - - // Make sure the body element is selected initially. - node = doc.querySelector("body"); - is(inspector.selection.node, node, "Body should be selected initially."); - node = doc.querySelector("h1") - inspector.once("inspector-updated", highlightHeaderNode); - let bc = inspector.breadcrumbs; - bc.nodeHierarchy[bc.currentIndex].button.focus(); - EventUtils.synthesizeKey("VK_RIGHT", {}); - } - - function highlightHeaderNode() - { - is(inspector.selection.node, node, "selected h1 element"); - - executeSoon(function() { - inspector.once("inspector-updated", highlightParagraphNode); - // Test that moving to the next sibling works. - node = doc.querySelector("p"); - EventUtils.synthesizeKey("VK_DOWN", { }); - }); - } - - function highlightParagraphNode() - { - is(inspector.selection.node, node, "selected p element"); - - executeSoon(function() { - inspector.once("inspector-updated", highlightHeaderNodeAgain); - // Test that moving to the previous sibling works. - node = doc.querySelector("h1"); - EventUtils.synthesizeKey("VK_UP", { }); - }); - } - - function highlightHeaderNodeAgain() - { - is(inspector.selection.node, node, "selected h1 element"); - - executeSoon(function() { - inspector.once("inspector-updated", highlightParentNode); - // Test that moving to the parent works. - node = doc.querySelector("body"); - EventUtils.synthesizeKey("VK_LEFT", { }); - }); - } - - function highlightParentNode() - { - is(inspector.selection.node, node, "selected body element"); - finishUp(); - } - - function finishUp() { - doc = node = null; - gBrowser.removeCurrentTab(); - finish(); - } -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_674871.js b/browser/devtools/inspector/test/browser_inspector_bug_674871.js index d6296a3f57f5..6bba5bc5cfb1 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_674871.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_674871.js @@ -1,110 +1,70 @@ +/* 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"; -function test() -{ - let doc; - let iframeNode, iframeBodyNode; - let inspector; +// Test that iframes are correctly highlighted. - let iframeSrc = "" + - ""; - let docSrc = "" + - "" + - "" + - ""; +const IFRAME_SRC = "hello from iframe"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(setupTest, content); - }, true); +const DOCUMENT_SRC = "" + + "" + + "" + + ""; - content.location = "data:text/html," + docSrc; +const TEST_URI = "data:text/html;charset=utf-8," + DOCUMENT_SRC; - function setupTest() - { - iframeNode = doc.querySelector("iframe"); - iframeBodyNode = iframeNode.contentDocument.querySelector("body"); - ok(iframeNode, "we have the iframe node"); - ok(iframeBodyNode, "we have the body node"); - openInspector(aInspector => { - inspector = aInspector; - // Make sure the highlighter is shown so we can disable transitions - inspector.toolbox.highlighter.showBoxModel(getNodeFront(doc.body)).then(() => { - runTests(); - }); - }); - } +let test = asyncTest(function* () { + let { inspector, toolbox } = yield openInspectorForURL(TEST_URI); + let outerDocument = content.document; - function runTests() - { - inspector.toolbox.highlighterUtils.startPicker().then(() => { - moveMouseOver(iframeNode, 1, 1, isTheIframeHighlighted); - }); - } + let iframeNode = getNode("iframe"); + let iframeBodyNode = getNode("body", { document: iframeNode.contentDocument }); - function isTheIframeHighlighted() - { - let {p1, p2, p3, p4} = getBoxModelStatus().border.points; - let {top, right, bottom, left} = iframeNode.getBoundingClientRect(); + info("Waiting for box mode to show."); + yield toolbox.highlighter.showBoxModel(getNodeFront(outerDocument.body)); - is(top, p1.y, "iframeRect.top === boxModelStatus.p1.y"); - is(top, p2.y, "iframeRect.top === boxModelStatus.p2.y"); - is(right, p2.x, "iframeRect.right === boxModelStatus.p2.x"); - is(right, p3.x, "iframeRect.right === boxModelStatus.p3.x"); - is(bottom, p3.y, "iframeRect.bottom === boxModelStatus.p3.y"); - is(bottom, p4.y, "iframeRect.bottom === boxModelStatus.p4.y"); - is(left, p1.x, "iframeRect.left === boxModelStatus.p1.x"); - is(left, p4.x, "iframeRect.left === boxModelStatus.p4.x"); + info("Waiting for element picker to become active."); + yield toolbox.highlighterUtils.startPicker(); - iframeNode.style.marginBottom = doc.defaultView.innerHeight + "px"; - doc.defaultView.scrollBy(0, 40); + info("Moving mouse over iframe padding."); + yield moveMouseOver(iframeNode, 1, 1); - moveMouseOver(iframeNode, 40, 40, isTheIframeContentHighlighted); - } + info("Performing checks"); + isNodeCorrectlyHighlighted(iframeNode); - function isTheIframeContentHighlighted() - { - is(getHighlitNode(), iframeBodyNode, "highlighter shows the right node"); + info("Scrolling the document"); + iframeNode.style.marginBottom = outerDocument.defaultView.innerHeight + "px"; + outerDocument.defaultView.scrollBy(0, 40); - let outlineRect = getSimpleBorderRect(); - is(outlineRect.height, 200, "highlighter height"); + info("Moving mouse over iframe body"); + yield moveMouseOver(iframeNode, 40, 40); - inspector.toolbox.highlighterUtils.stopPicker().then(() => { - let target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.closeToolbox(target); - finishUp(); - }); - } + is(getHighlitNode(), iframeBodyNode, "highlighter shows the right node"); + isNodeCorrectlyHighlighted(iframeBodyNode); - function finishUp() - { - doc = inspector = iframeNode = iframeBodyNode = null; - gBrowser.removeCurrentTab(); - finish(); - } + info("Waiting for the element picker to deactivate."); + yield inspector.toolbox.highlighterUtils.stopPicker(); - function moveMouseOver(aElement, x, y, cb) - { - inspector.toolbox.once("picker-node-hovered", cb); + function moveMouseOver(aElement, x, y) { + info("Waiting for element " + aElement + " to be highlighted"); EventUtils.synthesizeMouse(aElement, x, y, {type: "mousemove"}, aElement.ownerDocument.defaultView); + return inspector.toolbox.once("picker-node-hovered"); } -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_699308_iframe_navigation.js b/browser/devtools/inspector/test/browser_inspector_bug_699308_iframe_navigation.js index 86465ef47fdb..27fe047bf4cb 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_699308_iframe_navigation.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_699308_iframe_navigation.js @@ -1,77 +1,45 @@ +/* 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"; -function test() { - let iframe; - let iframeLoads = 0; - let checksAfterLoads = false; - let inspector; +// Test that the highlighter element picker still works through iframe +// navigations. - function startTest() { - openInspector(aInspector => { - inspector = aInspector; - runInspectorTests(); - }); +const TEST_URI = "data:text/html;charset=utf-8," + + "

bug 699308 - test iframe navigation

" + + ""; + +let test = asyncTest(function* () { + let { inspector, toolbox } = yield openInspectorForURL(TEST_URI); + let iframe = getNode("iframe"); + + info("Starting element picker."); + yield toolbox.highlighterUtils.startPicker(); + + info("Waiting for highlighter to activate."); + let highlighterShowing = toolbox.once("highlighter-ready"); + EventUtils.synthesizeMouse(content.document.body, 1, 1, + {type: "mousemove"}, content); + yield highlighterShowing; + + ok(isHighlighting(), "Inspector is highlighting."); + + yield reloadFrame(); + info("Frame reloaded. Reloading again."); + + yield reloadFrame(); + info("Frame reloaded twice."); + + ok(isHighlighting(), "Inspector is highlighting after iframe nav."); + + info("Stopping element picker."); + yield toolbox.highlighterUtils.stopPicker(); + + function reloadFrame() { + info("Reloading frame."); + let frameLoaded = once(iframe, "load"); + iframe.contentWindow.location.reload(); + return frameLoaded; } - - function showHighlighter(cb) { - inspector.toolbox.highlighterUtils.startPicker().then(() => { - EventUtils.synthesizeMouse(content.document.body, 1, 1, - {type: "mousemove"}, content); - inspector.toolbox.once("highlighter-ready", cb); - }); - } - - function runInspectorTests() { - iframe = content.document.querySelector("iframe"); - ok(iframe, "found the iframe element"); - - showHighlighter(() => { - ok(isHighlighting(), "Inspector is highlighting"); - - iframe.addEventListener("load", onIframeLoad, false); - executeSoon(() => { - iframe.contentWindow.location = "javascript:location.reload()"; - }); - }); - } - - function onIframeLoad() { - if (++iframeLoads != 2) { - executeSoon(function() { - iframe.contentWindow.location = "javascript:location.reload()"; - }); - return; - } - - iframe.removeEventListener("load", onIframeLoad, false); - info("Finished reloading iframe and inspector updated"); - - ok(isHighlighting(), "Inspector is highlighting after iframe nav"); - - checksAfterLoads = true; - - finishTest(); - } - - function finishTest() { - is(iframeLoads, 2, "iframe loads"); - ok(checksAfterLoads, "the Inspector tests got the chance to run after iframe reloads"); - - inspector.toolbox.highlighterUtils.stopPicker().then(() => { - iframe = null; - gBrowser.removeCurrentTab(); - executeSoon(finish); - }); - } - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onBrowserLoad() { - gBrowser.selectedBrowser.removeEventListener("load", onBrowserLoad, true); - waitForFocus(startTest, content); - }, true); - - content.location = "data:text/html;charset=utf-8," + - "

bug 699308 - test iframe navigation

" + - ""; -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js b/browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js index dc43c86e7d54..1a87c77a7d50 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_817558_delete_node.js @@ -1,52 +1,28 @@ +/* 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"; -function test() -{ - //ignoreAllUncaughtExceptions(); +// Test to ensure inspector handles deletion of selected node correctly. - let node, iframe, inspector; +const TEST_URL = TEST_URL_ROOT + "browser_inspector_destroyselection.html"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(setupTest, content); - }, true); +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URL); + let iframe = getNode("iframe"); + let span = getNode("span", { document: iframe.contentDocument }); - content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_destroyselection.html"; + yield selectNode(span, inspector); - function setupTest() - { - iframe = content.document.querySelector("iframe"); - node = iframe.contentDocument.querySelector("span"); - openInspector(runTests); - } + info("Removing selected element."); + let parentNode = span.parentNode; + span.remove(); - function runTests(aInspector) - { - inspector = aInspector; - inspector.selection.setNode(node); - inspector.once("inspector-updated", () => { - let parentNode = node.parentNode; - parentNode.removeChild(node); - - let tmp = {}; - Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", tmp); - let lh = new tmp.LayoutHelpers(window.content); - ok(!lh.isNodeConnected(node), "Node considered as disconnected."); - - // Wait for the inspector to process the mutation - inspector.once("inspector-updated", () => { - is(inspector.selection.node, parentNode, "parent of selection got selected"); - finishUp(); - }); - }); - }; - - function finishUp() { - node = null; - gBrowser.removeCurrentTab(); - finish(); - } -} + let lh = new LayoutHelpers(window.content); + ok(!lh.isNodeConnected(span), "Node considered as disconnected."); + // Wait for the inspector to process the mutation + yield inspector.once("inspector-updated"); + is(inspector.selection.node, parentNode, + "Parent node of selected got selected."); +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js b/browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js index 71a24461fdf1..dc4f15c18d79 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_831693_combinator_suggestions.js @@ -1,111 +1,157 @@ +/* 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"; -function test() -{ - let inspector, searchBox, state, popup; +// Testing that searching for combining selectors using the inspector search +// field produces correct suggestions. - // The various states of the inspector: [key, suggestions array] - // [ - // what key to press, - // suggestions array with count [ - // [suggestion1, count1], [suggestion2] ... - // ] count can be left to represent 1 - // ] - let keyStates = [ - ["d", [["div", 4]]], - ["i", [["div", 4]]], - ["v", []], - [" ", [["div div", 2], ["div span", 2]]], - [">", [["div >div", 2], ["div >span", 2]]], - ["VK_BACK_SPACE", [["div div", 2], ["div span", 2]]], - ["+", [["div +span"]]], - ["VK_BACK_SPACE", [["div div", 2], ["div span", 2]]], - ["VK_BACK_SPACE", []], - ["VK_BACK_SPACE", [["div", 4]]], - ["VK_BACK_SPACE", [["div", 4]]], - ["VK_BACK_SPACE", []], - ["p", []], - [" ", [["p strong"]]], - ["+", [["p +button"], ["p +p"]]], - ["b", [["p +button"]]], - ["u", [["p +button"]]], - ["t", [["p +button"]]], - ["t", [["p +button"]]], - ["o", [["p +button"]]], - ["n", []], - ["+", [["p +button+p"]]], - ]; +const TEST_URL = TEST_URL_ROOT + "browser_inspector_bug_831693_search_suggestions.html"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(setupTest, content); - }, true); - - content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_bug_831693_search_suggestions.html"; - - function $(id) { - if (id == null) return null; - return content.document.getElementById(id); - } - - function setupTest() +// 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 = [ { - openInspector(startTest); - } - - function startTest(aInspector) + key: "d", + suggestions: [{label: "div", count: 4}] + }, { - inspector = aInspector; - - searchBox = - inspector.panelWin.document.getElementById("inspector-searchbox"); - popup = inspector.searchSuggestions.searchPopup; - - focusSearchBoxUsingShortcut(inspector.panelWin, function() { - searchBox.addEventListener("command", checkState, true); - checkStateAndMoveOn(0); - }); + key: "i", + suggestions: [{label: "div", count: 4}] + }, + { + key: "v", + suggestions: [] + }, + { + key: " ", + suggestions: [ + {label: "div div", count: 2}, + {label: "div span", count: 2} + ] + }, + { + key: ">", + suggestions: [ + {label: "div >div", count: 2}, + {label: "div >span", count: 2} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [ + {label: "div div", count: 2 }, + {label: "div span", count: 2} + ] + }, + { + key: "+", + suggestions: [{label: "div +span"}] + }, + { + key: "VK_BACK_SPACE", + suggestions: [ + {label: "div div", count: 2 }, + {label: "div span", count: 2} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: "VK_BACK_SPACE", + suggestions: [{label: "div", count: 4}] + }, + { + key: "VK_BACK_SPACE", + suggestions: [{label: "div", count: 4}] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: "p", + suggestions: [] + }, + { + key: " ", + suggestions: [{label: "p strong"}] + }, + { + key: "+", + suggestions: [ + {label: "p +button" }, + {label: "p +p"} + ] + }, + { + key: "b", + suggestions: [{label: "p +button"}] + }, + { + key: "u", + suggestions: [{label: "p +button"}] + }, + { + key: "t", + suggestions: [{label: "p +button"}] + }, + { + key: "t", + suggestions: [{label: "p +button"}] + }, + { + key: "o", + suggestions: [{label: "p +button"}] + }, + { + key: "n", + suggestions: [] + }, + { + key: "+", + suggestions: [{label: "p +button+p"}] } +]; - function checkStateAndMoveOn(index) { - if (index == keyStates.length) { - finishUp(); - return; - } +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URL); + let searchBox = inspector.searchBox; + let popup = inspector.searchSuggestions.searchPopup; - let [key, suggestions] = keyStates[index]; - state = index; + yield focusSearchBoxUsingShortcut(inspector.panelWin); - info("pressing key " + key + " to get suggestions " + - JSON.stringify(suggestions)); + for (let { key, suggestions } of TEST_DATA) { + info("Pressing " + key + " to get " + formatSuggestions(suggestions)); + + let command = once(searchBox, "command"); EventUtils.synthesizeKey(key, {}, inspector.panelWin); - } + yield command; - function checkState(event) { - inspector.searchSuggestions._lastQuery.then(() => { - let [key, suggestions] = keyStates[state]; - let actualSuggestions = popup.getItems(); - is(popup.isOpen ? actualSuggestions.length: 0, suggestions.length, - "There are expected number of suggestions at " + state + "th step."); - actualSuggestions = actualSuggestions.reverse(); - for (let i = 0; i < suggestions.length; i++) { - is(suggestions[i][0], actualSuggestions[i].label, - "The suggestion at " + i + "th index for " + state + - "th step is correct.") - is(suggestions[i][1] || 1, actualSuggestions[i].count, - "The count for suggestion at " + i + "th index for " + state + - "th step is correct.") - } - checkStateAndMoveOn(state + 1); - }); - } + info("Waiting for search query to complete"); + yield inspector.searchSuggestions._lastQuery; - function finishUp() { - searchBox = null; - popup = null; - gBrowser.removeCurrentTab(); - finish(); + info("Query completed. Performing checks for input '" + searchBox.value + "'"); + let actualSuggestions = popup.getItems().reverse(); + + is(popup.isOpen ? actualSuggestions.length: 0, suggestions.length, + "There are expected number of suggestions."); + + for (let i = 0; i < suggestions.length; i++) { + is(suggestions[i].label, actualSuggestions[i].label, + "The suggestion at " + i + "th index is correct."); + is(suggestions[i].count || 1, actualSuggestions[i].count, + "The count for suggestion at " + i + "th index is correct."); + } } +}); + +function formatSuggestions(suggestions) { + return "[" + suggestions + .map(s => "'" + s.label + "' (" + s.count || 1 + ")") + .join(", ") + "]"; } diff --git a/browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js b/browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js index 593b0cc3d0d8..e949d322fdc8 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_831693_input_suggestion.js @@ -1,112 +1,194 @@ +/* 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"; -function test() -{ - let inspector, searchBox, state, popup; +// Testing that searching for elements using the inspector search field +// produces correct suggestions. - // The various states of the inspector: [key, suggestions array] - // [ - // what key to press, - // suggestions array with count [ - // [suggestion1, count1], [suggestion2] ... - // ] count can be left to represent 1 - // ] - let keyStates = [ - ["d", [["div", 2]]], - ["i", [["div", 2]]], - ["v", []], - [".", [["div.c1"]]], - ["VK_BACK_SPACE", []], - ["#", [["div#d1"], ["div#d2"]]], - ["VK_BACK_SPACE", []], - ["VK_BACK_SPACE", [["div", 2]]], - ["VK_BACK_SPACE", [["div", 2]]], - ["VK_BACK_SPACE", []], - [".", [[".c1", 3], [".c2"]]], - ["c", [[".c1", 3], [".c2"]]], - ["2", []], - ["VK_BACK_SPACE", [[".c1", 3], [".c2"]]], - ["1", []], - ["#", [["#d2"], ["#p1"], ["#s2"]]], - ["VK_BACK_SPACE", []], - ["VK_BACK_SPACE", [[".c1", 3], [".c2"]]], - ["VK_BACK_SPACE", [[".c1", 3], [".c2"]]], - ["VK_BACK_SPACE", []], - ["#", [["#b1"], ["#d1"], ["#d2"], ["#p1"], ["#p2"], ["#p3"], ["#s1"], ["#s2"]]], - ["p", [["#p1"], ["#p2"], ["#p3"]]], - ["VK_BACK_SPACE", [["#b1"], ["#d1"], ["#d2"], ["#p1"], ["#p2"], ["#p3"], ["#s1"], ["#s2"]]], - ["VK_BACK_SPACE", []], - ]; +const TEST_URL = TEST_URL_ROOT + "browser_inspector_bug_650804_search.html"; - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(setupTest, content); - }, true); - - content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_bug_650804_search.html"; - - function $(id) { - if (id == null) return null; - return content.document.getElementById(id); - } - - function setupTest() +// 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) +let TEST_DATA = [ { - openInspector(startTest); - } - - function startTest(aInspector) + key: "d", + suggestions: [{label: "div", count: 2}] + }, { - inspector = aInspector; - searchBox = - inspector.panelWin.document.getElementById("inspector-searchbox"); - popup = inspector.searchSuggestions.searchPopup; - - focusSearchBoxUsingShortcut(inspector.panelWin, function() { - searchBox.addEventListener("command", checkState, true); - checkStateAndMoveOn(0); - }); + key: "i", + suggestions: [{label: "div", count: 2}] + }, + { + key: "v", + suggestions: [] + }, + { + key: ".", + suggestions: [{label: "div.c1"}] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: "#", + suggestions: [ + {label: "div#d1"}, + {label: "div#d2"} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: "VK_BACK_SPACE", + suggestions: [{label: "div", count: 2}] + }, + { + key: "VK_BACK_SPACE", + suggestions: [{label: "div", count: 2}] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: ".", + suggestions: [ + {label: ".c1", count: 3}, + {label: ".c2"} + ] + }, + { + key: "c", + suggestions: [ + {label: ".c1", count: 3}, + {label: ".c2"} + ] + }, + { + key: "2", + suggestions: [] + }, + { + key: "VK_BACK_SPACE", + suggestions: [ + {label: ".c1", count: 3}, + {label: ".c2"} + ] + }, + { + key: "1", + suggestions: [] + }, + { + key: "#", + suggestions: [ + {label: "#d2"}, + {label: "#p1"}, + {label: "#s2"} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: "VK_BACK_SPACE", + suggestions: [ + {label: ".c1", count: 3}, + {label: ".c2"} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [ + {label: ".c1", count: 3}, + {label: ".c2"} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] + }, + { + key: "#", + suggestions: [ + {label: "#b1"}, + {label: "#d1"}, + {label: "#d2"}, + {label: "#p1"}, + {label: "#p2"}, + {label: "#p3"}, + {label: "#s1"}, + {label: "#s2"} + ] + }, + { + key: "p", + suggestions: [ + {label: "#p1"}, + {label: "#p2"}, + {label: "#p3"} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [ + {label: "#b1"}, + {label: "#d1"}, + {label: "#d2"}, + {label: "#p1"}, + {label: "#p2"}, + {label: "#p3"}, + {label: "#s1"}, + {label: "#s2"} + ] + }, + { + key: "VK_BACK_SPACE", + suggestions: [] } +]; - function checkStateAndMoveOn(index) { - if (index == keyStates.length) { - finishUp(); - return; - } +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URL); + let searchBox = inspector.searchBox; + let popup = inspector.searchSuggestions.searchPopup; - let [key, suggestions] = keyStates[index]; - state = index; + yield focusSearchBoxUsingShortcut(inspector.panelWin); - info("pressing key " + key + " to get suggestions " + - JSON.stringify(suggestions)); + for (let { key, suggestions } of TEST_DATA) { + info("Pressing " + key + " to get " + formatSuggestions(suggestions)); + + let command = once(searchBox, "command"); EventUtils.synthesizeKey(key, {}, inspector.panelWin); - } + yield command; - function checkState(event) { - inspector.searchSuggestions._lastQuery.then(() => { - let [key, suggestions] = keyStates[state]; - let actualSuggestions = popup.getItems(); - is(popup.isOpen ? actualSuggestions.length: 0, suggestions.length, - "There are expected number of suggestions at " + state + "th step."); - actualSuggestions = actualSuggestions.reverse(); - for (let i = 0; i < suggestions.length; i++) { - is(suggestions[i][0], actualSuggestions[i].label, - "The suggestion at " + i + "th index for " + state + - "th step is correct.") - is(suggestions[i][1] || 1, actualSuggestions[i].count, - "The count for suggestion at " + i + "th index for " + state + - "th step is correct.") - } - checkStateAndMoveOn(state + 1); - }); - } + info("Waiting for search query to complete"); + yield inspector.searchSuggestions._lastQuery; - function finishUp() { - searchBox = null; - popup = null; - gBrowser.removeCurrentTab(); - finish(); + info("Query completed. Performing checks for input '" + searchBox.value + "'"); + let actualSuggestions = popup.getItems().reverse(); + + is(popup.isOpen ? actualSuggestions.length: 0, suggestions.length, + "There are expected number of suggestions."); + + for (let i = 0; i < suggestions.length; i++) { + is(suggestions[i].label, actualSuggestions[i].label, + "The suggestion at " + i + "th index is correct."); + is(suggestions[i].count || 1, actualSuggestions[i].count, + "The count for suggestion at " + i + "th index is correct."); + } } +}); + +function formatSuggestions(suggestions) { + return "[" + suggestions + .map(s => "'" + s.label + "' (" + s.count || 1 + ")") + .join(", ") + "]"; } diff --git a/browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js b/browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js index 079d46e64042..b3415f34a521 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_840156_destroy_after_navigation.js @@ -1,59 +1,29 @@ +/* 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/ */ + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; -let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); -let Toolbox = devtools.Toolbox; -let TargetFactory = devtools.TargetFactory; +// Testing that closing the inspector after navigating to a page doesn't fail. -function test() { - const URL_1 = "data:text/plain;charset=UTF-8,abcde"; - const URL_2 = "data:text/plain;charset=UTF-8,12345"; +const URL_1 = "data:text/plain;charset=UTF-8,abcde"; +const URL_2 = "data:text/plain;charset=UTF-8,12345"; - let target, toolbox; +let test = asyncTest(function* () { + let { toolbox } = yield openInspectorForURL(URL_1); - // open tab, load URL_1, and wait for load to finish - let tab = gBrowser.selectedTab = gBrowser.addTab(); - let target = TargetFactory.forTab(gBrowser.selectedTab); - let deferred = promise.defer(); - let browser = gBrowser.getBrowserForTab(tab); - function onTabLoad() { - browser.removeEventListener("load", onTabLoad, true); - deferred.resolve(null); + info("Navigating to different URL."); + let navigated = toolbox.target.once("navigate"); + content.location = URL_2; + + info("Waiting for 'navigate' event from toolbox target."); + yield navigated; + + info("Destroying toolbox"); + try { + yield toolbox.destroy(); + ok(true, "Toolbox destroyed"); + } catch (e) { + ok(false, "An exception occured while destroying toolbox"); + console.error(e); } - browser.addEventListener("load", onTabLoad, true); - browser.loadURI(URL_1); - - // open devtools panel - deferred.promise - .then(function () gDevTools.showToolbox(target, null, Toolbox.HostType.BOTTOM)) - .then(function (aToolbox) { toolbox = aToolbox; }) - - // select the inspector - .then(function () toolbox.selectTool("inspector")) - - // wait until inspector ready - .then(function () { - let deferred = promise.defer(); - toolbox.getPanel("inspector").once("inspector-updated", deferred.resolve); - return deferred.promise; - }) - - // navigate to URL_2 - .then(function () { - let deferred = promise.defer(); - target.once("navigate", function () deferred.resolve()); - browser.loadURI(URL_2); - return deferred.promise; - }) - - // destroy the toolbox (and hence the inspector) before the load completes - .then(function () toolbox.destroy()) - - // this (or any other) exception should not occur: - // [JavaScript Error: "TypeError: self.selection is null" {file: "resource:///modules/devtools/InspectorPanel.jsm" line: 250}] - - .then(function cleanUp() { - gBrowser.removeCurrentTab(); - finish(); - }); -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js b/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js index 0543570c1956..48e8e99f7d4b 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js @@ -3,139 +3,94 @@ /* 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 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 = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html"; +const TEST_PAGE = TEST_URL_ROOT + + "browser_inspector_bug_848731_reset_selection_on_delete.html"; -function test() { - let inspector, toolbox; +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_PAGE); - // Create a tab, load test HTML, wait for load and start the tests - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(function() { - openInspector((aInspector, aToolbox) => { - inspector = aInspector; - toolbox = aToolbox; - startTests(); - }); - }, content); - }, true); - content.location = TEST_PAGE; + yield testManuallyDeleteSelectedNode(); + yield testAutomaticallyDeleteSelectedNode(); + yield testDeleteSelectedNodeContainerFrame(); - function startTests() { - testManuallyDeleteSelectedNode(); + function* testManuallyDeleteSelectedNode() { + info("Selecting a node, deleting it via context menu and checking that " + + "its parent node is selected and breadcrumbs are updated."); + + let div = getNode("#deleteManually"); + yield selectNode(div, inspector); + + info("Getting the node container in the markup view."); + let container = getContainerForRawNode(inspector.markup, div); + + info("Simulating right-click on the markup view container."); + EventUtils.synthesizeMouse(container.tagLine, 2, 2, + {type: "contextmenu", button: 2}, inspector.panelWin); + + info("Waiting for the context menu to open."); + yield once(inspector.panelDoc.getElementById("inspectorPopupSet"), "popupshown"); + + info("Clicking 'Delete Node' in the context menu."); + inspector.panelDoc.getElementById("node-menu-delete").click(); + + info("Waiting for inspector to update."); + yield inspector.once("inspector-updated"); + + info("Inspector updated, performing checks."); + let parent = getNode("#deleteChildren"); + assertNodeSelectedAndPanelsUpdated(parent, "ul#deleteChildren"); } - function getContainerForRawNode(rawNode) { - let front = inspector.markup.walker.frontForRawNode(rawNode); - let container = inspector.markup.getContainer(front); - return container; + function* testAutomaticallyDeleteSelectedNode() { + info("Selecting a node, deleting it via javascript and checking that " + + "its parent node is selected and breadcrumbs are updated."); + + let div = getNode("#deleteAutomatically"); + yield selectNode(div, inspector); + + info("Deleting selected node via javascript."); + div.remove(); + + info("Waiting for inspector to update."); + yield inspector.once("inspector-updated"); + + info("Inspector updated, performing checks."); + let parent = getNode("#deleteChildren"); + assertNodeSelectedAndPanelsUpdated(parent, "ul#deleteChildren"); } - // 1 - select a node, right click, hit delete, verify that its parent is selected - // and that all other tools are fine - function testManuallyDeleteSelectedNode() { - info("Deleting a node via the devtools contextual menu"); + function* testDeleteSelectedNodeContainerFrame() { + info("Selecting a node inside iframe, deleting the iframe via javascript " + + "and checking the parent node of the iframe is selected and " + + "breadcrumbs are updated."); - // Select our div - let div = content.document.getElementById("deleteManually"); - inspector.selection.setNode(div); - inspector.once("inspector-updated", () => { - is(inspector.selection.node, div, "Test node is selected"); - - // Get the node container in the markup view - let container = getContainerForRawNode(div); - - // Simulate right-click - EventUtils.synthesizeMouse(container.tagLine, 2, 2, - {type: "contextmenu", button: 2}, inspector.panelWin); - - // And react to the popup shown event - let contextMenu = inspector.panelDoc.getElementById("inspectorPopupSet"); - contextMenu.addEventListener("popupshown", function contextShown() { - contextMenu.removeEventListener("popupshown", contextShown, false); - - // Click on the delete sub-menu item - inspector.panelDoc.getElementById("node-menu-delete").click(); - - // Once updated, make sure eveything is in place, and move on - inspector.once("inspector-updated", () => { - let parent = content.document.getElementById("deleteChildren"); - assertNodeSelectedAndPanelsUpdated(parent, "ul#deleteChildren"); - testAutomaticallyDeleteSelectedNode(); - }); - }, false); - }); - } - - // 2 - select a node, delete it via javascript, verify the same things as 1 - function testAutomaticallyDeleteSelectedNode() { - info("Deleting a node via javascript"); - - // Select our second div - let div = content.document.getElementById("deleteAutomatically"); - inspector.selection.setNode(div); - inspector.once("inspector-updated", () => { - is(inspector.selection.node, div, "Test node is selected"); - - // Now remove that div via javascript - let parent = content.document.getElementById("deleteChildren"); - parent.removeChild(div); - - // Once updated, make sure eveything is in place, and move on - inspector.once("inspector-updated", () => { - assertNodeSelectedAndPanelsUpdated(parent, "ul#deleteChildren"); - testDeleteSelectedNodeContainerFrame(); - }); - }); - } - - // 3 - select a node inside an iframe, delete the iframe via javascript, verify that the default node is selected - // and that all other tools are fine - function testDeleteSelectedNodeContainerFrame() { - info("Deleting an iframe via javascript"); - - // Select our third test element, inside the iframe - let iframe = content.document.getElementById("deleteIframe"); + info("Selecting an element inside iframe."); + let iframe = getNode("#deleteIframe"); let div = iframe.contentDocument.getElementById("deleteInIframe"); - inspector.selection.setNode(div); - inspector.once("inspector-updated", () => { - is(inspector.selection.node, div, "Test node is selected"); + yield selectNode(div, inspector); - // Now remove that parent iframe via javascript - let parent = content.document.body; - parent.removeChild(iframe); + info("Deleting selected node via javascript."); + iframe.remove(); - // Once updated, make sure eveything is in place, and move on - inspector.once("inspector-updated", () => { - assertNodeSelectedAndPanelsUpdated(parent, "body"); - endTests(); - }); - }); - } + info("Waiting for inspector to update."); + yield inspector.once("inspector-updated"); - function endTests() { - executeSoon(() => { - toolbox.destroy(); - toolbox = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - }); + info("Inspector updated, performing checks."); + assertNodeSelectedAndPanelsUpdated(getNode("body"), "body"); } function assertNodeSelectedAndPanelsUpdated(node, crumbLabel) { - // Right node selected? is(inspector.selection.nodeFront, getNodeFront(node), "The right node is selected"); - // breadcrumbs updated? let breadcrumbs = inspector.panelDoc.getElementById("inspector-breadcrumbs"); is(breadcrumbs.querySelector("button[checked=true]").textContent, crumbLabel, "The right breadcrumb is selected"); } -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_922125_destroy_on_navigate.js b/browser/devtools/inspector/test/browser_inspector_bug_922125_destroy_on_navigate.js index df2a7de97070..725f1219811c 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_922125_destroy_on_navigate.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_922125_destroy_on_navigate.js @@ -1,77 +1,41 @@ +/* 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"; -let Toolbox = devtools.Toolbox; -let TargetFactory = devtools.TargetFactory; +// Test that markup view handles page navigation correctly. -function test() { - const URL_1 = "data:text/html;charset=UTF-8,
ONE
"; - const URL_2 = "data:text/html;charset=UTF-8,
TWO
"; +const SCHEMA = "data:text/html;charset=UTF-8,"; +const URL_1 = SCHEMA + "
ONE
"; +const URL_2 = SCHEMA + "
TWO
"; - let toolbox, inspector; +let test = asyncTest(function* () { + let { inspector, toolbox } = yield openInspectorForURL(URL_1); - // open tab, load URL_1, and wait for load to finish - let tab = gBrowser.selectedTab = gBrowser.addTab(); - let target = TargetFactory.forTab(gBrowser.selectedTab); - let deferred = promise.defer(); - let browser = gBrowser.getBrowserForTab(tab); + let firstNode = getNode("#one"); - function onTabLoad() { - browser.removeEventListener("load", onTabLoad, true); - deferred.resolve(null); - } - browser.addEventListener("load", onTabLoad, true); - browser.loadURI(URL_1); + assertMarkupViewIsLoaded(); + yield selectNode(firstNode, inspector); - // open devtools panel - deferred.promise.then(() => { - return gDevTools.showToolbox(target, null, Toolbox.HostType.BOTTOM); - }).then(aToolbox => { - toolbox = aToolbox; - }).then(() => { - // select the inspector - return toolbox.selectTool("inspector").then(i => { - inspector = i; - // Verify we are on page one - let testNode = content.document.querySelector("#one"); - ok(testNode, "We have the test node on page 1"); + let willNavigate = toolbox.target.once("will-navigate"); + content.location = URL_2; - assertMarkupViewIsLoaded(); - }); - }).then(() => { - // navigate to URL_2 - let deferred = promise.defer(); + info("Waiting for will-navigate"); + yield willNavigate; - // Listen to will-navigate to check if the view is empty - target.on("will-navigate", () => { - info("Navigation to page 2 has started, the inspector should be empty"); - assertMarkupViewIsEmpty(); - }); - inspector.once("new-root", () => { - info("Navigation to page 2 was done, the inspector should be back up"); + info("Navigation to page 2 has started, the inspector should be empty"); + assertMarkupViewIsEmpty(); - // Verify we are on page one - let testNode = content.document.querySelector("#two"); - ok(testNode, "We have the test node on page 2"); + info("Waiting for new-root"); + yield inspector.once("new-root"); - // On page 2 load, verify we have the right content - assertMarkupViewIsLoaded(); + info("Checking that the page has node #two."); + let secondNode = getNode("#two"); - inspector.selection.setNode(content.document.querySelector("#two")); - inspector.once("inspector-updated", () => { - deferred.resolve(); - }); - }); + info("Navigation to page 2 was done, the inspector should be back up"); + assertMarkupViewIsLoaded(); - inspector.selection.setNode(content.document.querySelector("#one")); - inspector.once("inspector-updated", () => { - browser.loadURI(URL_2); - }); - - return deferred.promise; - }).then(() => { - endTests(); - }); + yield selectNode(secondNode, inspector); function assertMarkupViewIsLoaded() { let markupViewBox = inspector.panelDoc.getElementById("markup-box"); @@ -82,10 +46,4 @@ function test() { let markupViewBox = inspector.panelDoc.getElementById("markup-box"); is(markupViewBox.childNodes.length, 0, "The markup-view is unloaded"); } - - function endTests() { - target = browser = tab = inspector = TargetFactory = Toolbox = null; - gBrowser.removeCurrentTab(); - finish(); - } -} +}); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_958169_switch_to_inspector_on_pick.js b/browser/devtools/inspector/test/browser_inspector_bug_958169_switch_to_inspector_on_pick.js index 090c2e132531..5924f40314fc 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_958169_switch_to_inspector_on_pick.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_958169_switch_to_inspector_on_pick.js @@ -1,55 +1,39 @@ /* 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"; -let doc; -let toolbox; +// Testing that clicking the pick button switches the toolbox to the inspector +// panel. -function test() { - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload(evt) { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(startTests, content); - }, true); +const TEST_URI = "data:text/html;charset=UTF-8," + + "

Switch to inspector on pick

"; - content.location = "data:text/html,

Switch to inspector on pick

"; +let test = asyncTest(function* () { + let tab = yield addTab(TEST_URI); + let toolbox = yield openToolbox(tab); + + yield startPickerAndAssertSwitchToInspector(toolbox); + + info("Stoppping element picker."); + yield toolbox.highlighterUtils.stopPicker(); +}); + +function openToolbox(tab) { + info("Opening webconsole."); + let target = TargetFactory.forTab(tab); + return gDevTools.showToolbox(target, "webconsole"); } -function startTests() { - Task.spawn(function() { - yield openToolbox(); - yield startPickerAndAssertSwitchToInspector(); - yield toolbox.highlighterUtils.stopPicker(); - - finishTests(); - }).then(null, Cu.reportError); -} - -function openToolbox() { - let target = TargetFactory.forTab(gBrowser.selectedTab); - return gDevTools.showToolbox(target, "webconsole").then(aToolbox => { - toolbox = aToolbox; - }); -} - -function startPickerAndAssertSwitchToInspector() { - let deferred = promise.defer(); - +function* startPickerAndAssertSwitchToInspector(toolbox) { + info("Clicking element picker button."); let pickButton = toolbox.doc.querySelector("#command-button-pick"); pickButton.click(); - toolbox.once("inspector-selected", () => { - is(toolbox.currentToolId, "inspector", "Switched to the inspector"); - toolbox.getCurrentPanel().once("inspector-updated", deferred.resolve); - }); - return deferred.promise; -} + info("Waiting for inspector to be selected."); + yield toolbox.once("inspector-selected"); + is(toolbox.currentToolId, "inspector", "Switched to the inspector"); -function finishTests() { - doc = toolbox = null; - gBrowser.removeCurrentTab(); - finish(); + info("Waiting for inspector to update."); + yield toolbox.getCurrentPanel().once("inspector-updated"); } diff --git a/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js b/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js index 6c542acdbd41..88c8ea0644a4 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.js @@ -3,113 +3,77 @@ /* 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 hovering over the markup-view's containers doesn't always show the // highlighter, depending on the type of node hovered over. -let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); -let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); -let {Task} = Cu.import("resource://gre/modules/Task.jsm", {}); +const TEST_PAGE = TEST_URL_ROOT + + "browser_inspector_bug_958456_highlight_comments.html"; -const TEST_PAGE = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_bug_958456_highlight_comments.html"; -let inspector, markupView, doc; +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_PAGE); + let markupView = inspector.markup; + yield selectNode("p", inspector); -function test() { - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; + info("Hovering over #id1 and waiting for highlighter to appear."); + yield hoverElement("#id1"); + assertHighlighterShownOn("#id1"); - waitForFocus(function() { - openInspector((aInspector, aToolbox) => { - inspector = aInspector; - markupView = inspector.markup; - startTests(); - }); - }, content); - }, true); - content.location = TEST_PAGE; -} + info("Hovering over comment node and ensuring highlighter doesn't appear."); + yield hoverComment(); + assertHighlighterHidden(); -function startTests() { - Task.spawn(function() { - yield prepareHighlighter(); + info("Hovering over #id1 again and waiting for highlighter to appear."); + yield hoverElement("#id1"); + assertHighlighterShownOn("#id1"); - // Highlighter should be shown on this element - yield hoverElement("#id1"); - assertHighlighterShownOn("#id1"); + info("Hovering over #id2 and waiting for highlighter to appear."); + yield hoverElement("#id2"); + assertHighlighterShownOn("#id2"); - // But not over a comment - yield hoverComment(); - assertHighlighterHidden(); + info("Hovering over - \ No newline at end of file + diff --git a/browser/devtools/inspector/test/browser_inspector_dead_node_exception.js b/browser/devtools/inspector/test/browser_inspector_dead_node_exception.js index cb0e905e702f..06874c3a80f2 100644 --- a/browser/devtools/inspector/test/browser_inspector_dead_node_exception.js +++ b/browser/devtools/inspector/test/browser_inspector_dead_node_exception.js @@ -1,54 +1,40 @@ -/* Any copyright", " is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ +/* 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"; -function test() { - let contentTab, contentDoc, inspector; +// Testing that the inspector doesn't go blank when navigating to a page that +// deletes an iframe while loading. - // Create a tab - contentTab = gBrowser.selectedTab = gBrowser.addTab(); +const TEST_URL = TEST_URL_ROOT + "browser_inspector_dead_node_exception.html"; - // Open the toolbox's inspector first - let target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - inspector = toolbox.getCurrentPanel(); +let test = asyncTest(function* () { + let { inspector, toolbox } = yield openInspectorForURL("about:blank"); - inspector.selection.setNode(content.document.querySelector("body")); - inspector.once("inspector-updated", () => { - is(inspector.selection.node.tagName, "BODY", "Inspector displayed"); + yield selectNode("body", inspector); - // Then load our test page - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - contentDoc = content.document; + let loaded = once(gBrowser.selectedBrowser, "load", true); + content.location = TEST_URL; - // The content doc contains a script that creates an iframe and deletes - // it immediately after. This is what used to make the inspector go - // blank when navigating to that page. + info("Waiting for test page to load."); + yield loaded; - var iframe = contentDoc.createElement("iframe"); - contentDoc.body.appendChild(iframe); - iframe.parentNode.removeChild(iframe); + // The content doc contains a script that creates an iframe and deletes + // it immediately after. This is what used to make the inspector go + // blank when navigating to that page. + info("Creating and removing an iframe."); + var iframe = content.document.createElement("iframe"); + content.document.body.appendChild(iframe); + iframe.remove(); - is(contentDoc.querySelector("iframe"), null, "Iframe has been removed"); + ok(!getNode("iframe", {expectNoMatch: true}), "Iframe has been removed."); - inspector.once("markuploaded", () => { - // Assert that the markup-view is displayed and works - is(contentDoc.querySelector("iframe"), null, "Iframe has been removed"); - is(contentDoc.getElementById("yay").textContent, "load", "Load event fired"); + info("Waiting for markup-view to load."); + yield inspector.once("markuploaded"); - inspector.selection.setNode(contentDoc.getElementById("yay")); - inspector.once("inspector-updated", () => { - ok(inspector.selection.node, "Inspector still displayed"); + // Assert that the markup-view is displayed and works + ok(!getNode("iframe", {expectNoMatch: true}), "Iframe has been removed."); + is(getNode("#yay").textContent, "load", "Load event fired."); - // Clean up and go - contentTab, contentDoc, inspector = null; - gBrowser.removeTab(contentTab); - finish(); - }); - }); - }, true); - content.location = "http://mochi.test:8888/browser/browser/devtools/" + - "inspector/test/browser_inspector_dead_node_exception.html"; - }); - }); -} + yield selectNode("#yay", inspector); +}); diff --git a/browser/devtools/inspector/test/browser_inspector_destroyselection.js b/browser/devtools/inspector/test/browser_inspector_destroyselection.js index 7732dbab43f7..1a8801279008 100644 --- a/browser/devtools/inspector/test/browser_inspector_destroyselection.js +++ b/browser/devtools/inspector/test/browser_inspector_destroyselection.js @@ -1,50 +1,26 @@ +/* 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"; -function test() -{ - let node, iframe, inspector; +// Test to ensure inspector can handle destruction of selected node inside an +// iframe. - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(setupTest, content); - }, true); +const TEST_URL = TEST_URL_ROOT + "browser_inspector_destroyselection.html"; - content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_destroyselection.html"; +let test = asyncTest(function* () { + let { inspector } = yield openInspectorForURL(TEST_URL); - function setupTest() - { - iframe = content.document.querySelector("iframe"); - node = iframe.contentDocument.querySelector("span"); - openInspector(runTests); - } + let iframe = getNode("iframe"); + let node = getNode("span", { document: iframe.contentDocument }); + yield selectNode(node, inspector); - function runTests(aInspector) - { - inspector = aInspector; - inspector.selection.setNode(node); + info("Removing iframe."); + iframe.remove(); - inspector.once("inspector-updated", () => { - iframe.parentNode.removeChild(iframe); - iframe = null; - - let tmp = {}; - Cu.import("resource://gre/modules/devtools/LayoutHelpers.jsm", tmp); - let lh = new tmp.LayoutHelpers(window.content); - ok(!lh.isNodeConnected(node), "Node considered as disconnected."); - ok(!inspector.selection.isConnected(), "Selection considered as disconnected"); - - inspector.once("inspector-updated", () => { - finishUp(); - }); - }); - } - - function finishUp() { - node = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - } -} + let lh = new LayoutHelpers(window.content); + ok(!lh.isNodeConnected(node), "Node considered as disconnected."); + ok(!inspector.selection.isConnected(), "Selection considered as disconnected."); + yield inspector.once("inspector-updated"); +}); diff --git a/browser/devtools/inspector/test/browser_inspector_highlighter.js b/browser/devtools/inspector/test/browser_inspector_highlighter.js index fa444748a210..70e9324fdf28 100644 --- a/browser/devtools/inspector/test/browser_inspector_highlighter.js +++ b/browser/devtools/inspector/test/browser_inspector_highlighter.js @@ -8,15 +8,10 @@ // Test that the highlighter is correctly displayed over a variety of elements +const TEST_URI = TEST_URL_ROOT + "browser_inspector_highlighter.html"; + let test = asyncTest(function*() { - const TEST_URI = "http://example.com/browser/browser/devtools/inspector/" + - "test/browser_inspector_highlighter.html"; - - info("Opening the document"); - yield addTab(TEST_URI); - - info("Opening the inspector"); - let {toolbox, inspector} = yield openInspector(); + let { inspector } = yield openInspectorForURL(TEST_URI); info("Selecting the simple, non-transformed DIV"); let div = getNode("#simple-div"); @@ -43,7 +38,6 @@ let test = asyncTest(function*() { testMouseOverWidthHeightZeroDiv(zeroWidthHeight); - gBrowser.removeCurrentTab(); }); function testSimpleDivHighlighted(div) { diff --git a/browser/devtools/inspector/test/browser_inspector_iframeTest.js b/browser/devtools/inspector/test/browser_inspector_iframeTest.js index 44a9d245607a..c4ca933f4c81 100644 --- a/browser/devtools/inspector/test/browser_inspector_iframeTest.js +++ b/browser/devtools/inspector/test/browser_inspector_iframeTest.js @@ -3,109 +3,55 @@ /* 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"; -let doc; -let div1; -let div2; -let iframe1; -let iframe2; -let inspector; +// Testing that moving the mouse over the document with the element picker +// started highlights nodes -function createDocument() { - doc.title = "Inspector iframe Tests"; +const NESTED_FRAME_SRC = "data:text/html;charset=utf-8," + + "nested iframe
nested div
"; - iframe1 = doc.createElement('iframe'); +const OUTER_FRAME_SRC = "data:text/html;charset=utf-8," + + "little frame
little div
" + + "