diff options
Diffstat (limited to 'browser/devtools/markupview/test')
11 files changed, 0 insertions, 1111 deletions
diff --git a/browser/devtools/markupview/test/Makefile.in b/browser/devtools/markupview/test/Makefile.in deleted file mode 100644 index 2c0218d80..000000000 --- a/browser/devtools/markupview/test/Makefile.in +++ /dev/null @@ -1,25 +0,0 @@ -# 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/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ -relativesrcdir = @relativesrcdir@ - -include $(DEPTH)/config/autoconf.mk - -MOCHITEST_BROWSER_FILES := \ - browser_inspector_markup_navigation.html \ - browser_inspector_markup_navigation.js \ - browser_inspector_markup_mutation.html \ - browser_inspector_markup_mutation.js \ - browser_inspector_markup_edit.html \ - browser_inspector_markup_edit.js \ - browser_inspector_markup_subset.html \ - browser_inspector_markup_subset.js \ - head.js \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff --git a/browser/devtools/markupview/test/browser_inspector_markup_edit.html b/browser/devtools/markupview/test/browser_inspector_markup_edit.html deleted file mode 100644 index b48d3535c..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_edit.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> - -<html class="html"> - - <body class="body"> - <div class="node0"> - <div id="node1" class="node1">line1</div> - <div id="node2" class="node2">line2</div> - <p class="node3">line3</p> - <!-- A comment --> - <p id="node4" class="node4">line4 - <span class="node5">line5</span> - <span class="node6">line6</span> - <!-- A comment --> - <a class="node7">line7<span class="node8">line8</span></a> - <span class="node9">line9</span> - <span class="node10">line10</span> - <span class="node11">line11</span> - <a class="node12">line12<span class="node13">line13</span></a> - </p> - <p id="node14">line14</p> - <p class="node15">line15</p> - </div> - <div id="node16"> - <p id="node17">line17</p> - </div> - <div id="node18"> - <div id="node19"> - <div id="node20"> - <div id="node21"> - line21 - </div> - </div> - </div> - </div> - <div id="node22" class="unchanged"></div> - <div id="node23"></div> - <div id="node24"></div> - <div id="retag-me"> - <div id="retag-me-2"></div> - </div> - <div id="node25"></div> - </body> -</html> diff --git a/browser/devtools/markupview/test/browser_inspector_markup_edit.js b/browser/devtools/markupview/test/browser_inspector_markup_edit.js deleted file mode 100644 index 89af69914..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_edit.js +++ /dev/null @@ -1,443 +0,0 @@ -/* Any copyright", " is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests that various editors work as expected. Also checks - * that the various changes are properly undoable and redoable. - * For each step in the test, we: - * - Run the setup for that test (if any) - * - Check that the node we're editing is as we expect - * - Make the change, check that the change was made as we expect - * - Undo the change, check that the node is back in its original state - * - Redo the change, check that the node change was made again correctly. - * - * This test mostly tries to verify that the editor makes changes to the - * underlying DOM, not that the UI updates - UI updates are based on - * underlying DOM changes, and the mutation tests should cover those cases. - */ - -function test() { - let inspector; - let { - getInplaceEditorForSpan: inplaceEditor - } = devtools.require("devtools/shared/inplace-editor"); - - waitForExplicitFinish(); - - // Will hold the doc we're viewing - let doc; - - // Holds the MarkupTool object we're testing. - let markup; - - /** - * Edit a given editableField - */ - function editField(aField, aValue) - { - aField.focus(); - EventUtils.sendKey("return", inspector.panelWin); - let input = inplaceEditor(aField).input; - input.value = aValue; - EventUtils.sendKey("return", inspector.panelWin); - } - - /** - * Check that the appropriate attributes are assigned to a node. - * - * @param {HTMLNode} aElement - * The node to check. - * @param {Object} aAttributes - * An object containing the arguments to check. - * e.g. {id="id1",class="someclass"} - * - * NOTE: When checking attribute values bare in mind that node.getAttribute() - * returns attribute values provided by the HTML parser. The parser only - * provides unescaped entities so & will return &. - */ - function assertAttributes(aElement, aAttributes) - { - let attrs = Object.getOwnPropertyNames(aAttributes); - is(aElement.attributes.length, attrs.length, - "Node has the correct number of attributes"); - for (let attr of attrs) { - is(aElement.getAttribute(attr), aAttributes[attr], - "Node has the correct " + attr + " attribute."); - } - } - - // All the mutation types we want to test. - let edits = [ - { - desc: "Change an attribute", - before: function() { - assertAttributes(doc.querySelector("#node1"), { - id: "node1", - class: "node1" - }); - }, - execute: function(after) { - inspector.once("markupmutation", after); - let editor = markup.getContainer(doc.querySelector("#node1")).editor; - let attr = editor.attrs["class"].querySelector(".editable"); - editField(attr, 'class="changednode1"'); - }, - after: function() { - assertAttributes(doc.querySelector("#node1"), { - id: "node1", - class: "changednode1" - }); - } - }, - - { - desc: 'Try changing an attribute to a quote (") - this should result ' + - 'in it being set to an empty string', - before: function() { - assertAttributes(doc.querySelector("#node22"), { - id: "node22", - class: "unchanged" - }); - }, - execute: function(after) { - let editor = markup.getContainer(doc.querySelector("#node22")).editor; - let attr = editor.attrs["class"].querySelector(".editable"); - editField(attr, 'class="""'); - executeSoon(after); - }, - after: function() { - assertAttributes(doc.querySelector("#node22"), { - id: "node22", - class: "" - }); - } - }, - - { - desc: "Remove an attribute", - before: function() { - assertAttributes(doc.querySelector("#node4"), { - id: "node4", - class: "node4" - }); - }, - execute: function(after) { - inspector.once("markupmutation", after); - let editor = markup.getContainer(doc.querySelector("#node4")).editor; - let attr = editor.attrs["class"].querySelector(".editable"); - editField(attr, ''); - }, - after: function() { - assertAttributes(doc.querySelector("#node4"), { - id: "node4", - }); - } - }, - - { - desc: "Add an attribute by clicking the empty space after a node", - before: function() { - assertAttributes(doc.querySelector("#node14"), { - id: "node14", - }); - }, - execute: function(after) { - inspector.once("markupmutation", after); - let editor = markup.getContainer(doc.querySelector("#node14")).editor; - let attr = editor.newAttr; - editField(attr, 'class="newclass" style="color:green"'); - }, - after: function() { - assertAttributes(doc.querySelector("#node14"), { - id: "node14", - class: "newclass", - style: "color:green" - }); - } - }, - - { - desc: 'Try add an attribute containing a quote (") attribute by ' + - 'clicking the empty space after a node - this should result ' + - 'in it being set to an empty string', - before: function() { - assertAttributes(doc.querySelector("#node23"), { - id: "node23", - }); - }, - execute: function(after) { - let editor = markup.getContainer(doc.querySelector("#node23")).editor; - let attr = editor.newAttr; - editField(attr, 'class="newclass" style="""'); - executeSoon(after); - }, - after: function() { - assertAttributes(doc.querySelector("#node23"), { - id: "node23", - class: "newclass", - style: "" - }); - } - }, - - { - desc: "Try add attributes by adding to an existing attribute's entry", - before: function() { - assertAttributes(doc.querySelector("#node24"), { - id: "node24", - }); - }, - execute: function(after) { - let editor = markup.getContainer(doc.querySelector("#node24")).editor; - let attr = editor.attrs["id"].querySelector(".editable"); - editField(attr, attr.textContent + ' class="""'); - executeSoon(after); - }, - after: function() { - assertAttributes(doc.querySelector("#node24"), { - id: "node24", - class: "" - }); - } - }, - - { - desc: "Edit text", - before: function() { - let node = doc.querySelector('.node6').firstChild; - is(node.nodeValue, "line6", "Text should be unchanged"); - }, - execute: function(after) { - inspector.once("markupmutation", after); - let node = doc.querySelector('.node6').firstChild; - let editor = markup.getContainer(node).editor; - let field = editor.elt.querySelector("pre"); - editField(field, "New text"); - }, - after: function() { - let node = doc.querySelector('.node6').firstChild; - is(node.nodeValue, "New text", "Text should be changed."); - }, - }, - - { - desc: "Add an attribute value containing < > ü \" & '", - before: function() { - assertAttributes(doc.querySelector("#node25"), { - id: "node25", - }); - }, - execute: function(after) { - inspector.once("markupmutation", after); - let editor = markup.getContainer(doc.querySelector("#node25")).editor; - let attr = editor.newAttr; - editField(attr, 'src="somefile.html?param1=<a>¶m2=ü"bl\'ah"'); - }, - after: function() { - assertAttributes(doc.querySelector("#node25"), { - id: "node25", - src: "somefile.html?param1=<a>¶m2=ü"bl'ah" - }); - } - }, - ]; - - // Create the helper tab for parsing... - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(setupTest, content); - }, true); - content.location = "http://mochi.test:8888/browser/browser/devtools/markupview/test/browser_inspector_markup_edit.html"; - - function setupTest() { - var target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - inspector = toolbox.getCurrentPanel(); - startTests(); - }); - } - - function startTests() { - let startNode = doc.documentElement.cloneNode(); - markup = inspector.markup; - markup.expandAll(); - - let cursor = 0; - - function nextEditTest() { - executeSoon(function() { - if (cursor >= edits.length) { - addAttributes(); - } else { - let step = edits[cursor++]; - info("START " + step.desc); - if (step.setup) { - step.setup(); - } - step.before(); - info("before execute"); - step.execute(function() { - info("after execute"); - step.after(); - ok(markup.undo.canUndo(), "Should be able to undo."); - markup.undo.undo(); - step.before(); - ok(markup.undo.canRedo(), "Should be able to redo."); - markup.undo.redo(); - step.after(); - info("END " + step.desc); - nextEditTest(); - }); - } - }); - } - nextEditTest(); - } - - function addAttributes() { - let test = { - desc: "Add attributes by adding to an existing attribute's entry", - setup: function() { - inspector.selection.setNode(doc.querySelector("#node18")); - }, - before: function() { - assertAttributes(doc.querySelector("#node18"), { - id: "node18", - }); - - is(inspector.highlighter.nodeInfo.classesBox.textContent, "", - "No classes in the infobar before edit."); - }, - execute: function(after) { - inspector.once("markupmutation", function() { - // needed because we need to make sure the infobar is updated - // not just the markupview (which happens in this event loop) - executeSoon(after); - }); - let editor = markup.getContainer(doc.querySelector("#node18")).editor; - let attr = editor.attrs["id"].querySelector(".editable"); - editField(attr, attr.textContent + ' class="newclass" style="color:green"'); - }, - after: function() { - assertAttributes(doc.querySelector("#node18"), { - id: "node18", - class: "newclass", - style: "color:green" - }); - is(inspector.highlighter.nodeInfo.classesBox.textContent, ".newclass", - "Correct classes in the infobar after edit."); - } - }; - testAsyncSetup(test, editTagName); - } - - function editTagName() { - let test = { - desc: "Edit the tag name", - setup: function() { - inspector.selection.setNode(doc.querySelector("#retag-me")); - }, - before: function() { - let node = doc.querySelector("#retag-me"); - let container = markup.getContainer(node); - - is(node.tagName, "DIV", "retag-me should be a div."); - ok(container.selected, "retag-me should be selected."); - ok(container.expanded, "retag-me should be expanded."); - is(doc.querySelector("#retag-me-2").parentNode, node, - "retag-me-2 should be a child of the old element."); - }, - execute: function(after) { - inspector.once("markupmutation", after); - let node = doc.querySelector("#retag-me"); - let editor = markup.getContainer(node).editor; - let field = editor.tag; - editField(field, "p"); - }, - after: function() { - let node = doc.querySelector("#retag-me"); - let container = markup.getContainer(node); - is(node.tagName, "P", "retag-me should be a p."); - ok(container.selected, "retag-me should be selected."); - ok(container.expanded, "retag-me should be expanded."); - is(doc.querySelector("#retag-me-2").parentNode, node, - "retag-me-2 should be a child of the new element."); - } - }; - testAsyncSetup(test, removeElementWithDelete); - } - - function removeElementWithDelete() { - let test = { - desc: "Remove an element with the delete key", - before: function() { - ok(!!doc.querySelector("#node18"), "Node 18 should exist."); - }, - execute: function() { - inspector.selection.setNode(doc.querySelector("#node18")); - }, - executeCont: function() { - EventUtils.sendKey("delete", inspector.panelWin); - }, - after: function() { - ok(!doc.querySelector("#node18"), "Node 18 should not exist.") - } - }; - testAsyncExecute(test, finishUp); - } - - function testAsyncExecute(test, callback) { - info("START " + test.desc); - - test.before(); - inspector.selection.once("new-node", function BIMET_testAsyncExecNewNode() { - test.executeCont(); - test.after(); - undoRedo(test, callback); - }); - executeSoon(function BIMET_setNode1() { - test.execute(); - }); - } - - function testAsyncSetup(test, callback) { - info("START " + test.desc); - - inspector.selection.once("new-node", function BIMET_testAsyncSetupNewNode() { - test.before(); - test.execute(function() { - test.after(); - undoRedo(test, callback); - }); - }); - executeSoon(function BIMET_setNode2() { - test.setup(); - }); - } - - function undoRedo(test, callback) { - ok(markup.undo.canUndo(), "Should be able to undo."); - markup.undo.undo(); - executeSoon(function() { - test.before(); - ok(markup.undo.canRedo(), "Should be able to redo."); - markup.undo.redo(); - executeSoon(function() { - test.after(); - info("END " + test.desc); - callback(); - }); - }); - } - - function finishUp() { - while (markup.undo.canUndo()) { - markup.undo.undo(); - } - doc = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - } -} diff --git a/browser/devtools/markupview/test/browser_inspector_markup_mutation.html b/browser/devtools/markupview/test/browser_inspector_markup_mutation.html deleted file mode 100644 index 65895a26c..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_mutation.html +++ /dev/null @@ -1,37 +0,0 @@ -<!DOCTYPE html> - -<html class="html"> - - <body class="body"> - <div class="node0"> - <div id="node1" class="node1">line1</div> - <div id="node2" class="node2">line2</div> - <p class="node3">line3</p> - <!-- A comment --> - <p id="node4" class="node4">line4 - <span class="node5">line5</span> - <span class="node6">line6</span> - <!-- A comment --> - <a class="node7">line7<span class="node8">line8</span></a> - <span class="node9">line9</span> - <span class="node10">line10</span> - <span class="node11">line11</span> - <a class="node12">line12<span class="node13">line13</span></a> - </p> - <p id="node14">line14</p> - <p class="node15">line15</p> - </div> - <div id="node16"> - <p id="node17">line17</p> - </div> - <div id="node18"> - <div id="node19"> - <div id="node20"> - <div id="node21"> - line21 - </div> - </div> - </div> - </div> - </body> -</html> diff --git a/browser/devtools/markupview/test/browser_inspector_markup_mutation.js b/browser/devtools/markupview/test/browser_inspector_markup_mutation.js deleted file mode 100644 index 0923262ce..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_mutation.js +++ /dev/null @@ -1,181 +0,0 @@ -/* Any copyright", " is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests that various mutations to the dom update the markup tool correctly. - * The test for comparing the markup tool to the real dom is a bit weird: - * - Select the text in the markup tool - * - Parse that as innerHTML in a document we've created for the purpose. - * - Remove extraneous whitespace in that tree - * - Compare it to the real dom with isEqualNode. - */ - -function test() { - waitForExplicitFinish(); - - // Will hold the doc we're viewing - let contentTab; - let doc; - - // Holds the MarkupTool object we're testing. - let markup; - - // Holds the document we use to help re-parse the markup tool's output. - let parseTab; - let parseDoc; - - let inspector; - - // Strip whitespace from a node and its children. - function stripWhitespace(node) - { - node.normalize(); - let iter = node.ownerDocument.createNodeIterator(node, NodeFilter.SHOW_TEXT + NodeFilter.SHOW_COMMENT, - null); - - while ((node = iter.nextNode())) { - node.nodeValue = node.nodeValue.replace(/\s+/g, ''); - if (node.nodeType == Node.TEXT_NODE && - !/[^\s]/.exec(node.nodeValue)) { - node.parentNode.removeChild(node); - } - } - } - - // Verify that the markup in the tool is the same as the markup in the document. - function checkMarkup() - { - markup.expandAll(); - - let contentNode = doc.querySelector("body"); - let panelNode = markup._containers.get(contentNode).elt; - let parseNode = parseDoc.querySelector("body"); - - // Grab the text from the markup panel... - let sel = panelNode.ownerDocument.defaultView.getSelection(); - sel.selectAllChildren(panelNode); - - // Parse it - parseNode.outerHTML = sel; - parseNode = parseDoc.querySelector("body"); - - // Pull whitespace out of text and comment nodes, there will - // be minor unimportant differences. - stripWhitespace(parseNode); - - ok(contentNode.isEqualNode(parseNode), "Markup panel should match document."); - } - - // All the mutation types we want to test. - let mutations = [ - // Add an attribute - function() { - let node1 = doc.querySelector("#node1"); - node1.setAttribute("newattr", "newattrval"); - }, - function() { - let node1 = doc.querySelector("#node1"); - node1.removeAttribute("newattr"); - }, - function() { - let node1 = doc.querySelector("#node1"); - node1.textContent = "newtext"; - }, - function() { - let node2 = doc.querySelector("#node2"); - node2.innerHTML = "<div><span>foo</span></div>"; - }, - - function() { - let node4 = doc.querySelector("#node4"); - while (node4.firstChild) { - node4.removeChild(node4.firstChild); - } - }, - function() { - // Move a child to a new parent. - let node17 = doc.querySelector("#node17"); - let node1 = doc.querySelector("#node2"); - node1.appendChild(node17); - }, - - function() { - // Swap a parent and child element, putting them in the same tree. - // body - // node1 - // node18 - // node19 - // node20 - // node21 - // will become: - // body - // node1 - // node20 - // node21 - // node18 - // node19 - let node18 = doc.querySelector("#node18"); - let node20 = doc.querySelector("#node20"); - - let node1 = doc.querySelector("#node1"); - - node1.appendChild(node20); - node20.appendChild(node18); - }, - ]; - - // Create the helper tab for parsing... - parseTab = gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - parseDoc = content.document; - - // Then create the actual dom we're inspecting... - contentTab = gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload2() { - gBrowser.selectedBrowser.removeEventListener("load", onload2, true); - doc = content.document; - // Strip whitespace from the doc for easier comparison. - stripWhitespace(doc.documentElement); - waitForFocus(setupTest, content); - }, true); - content.location = "http://mochi.test:8888/browser/browser/devtools/markupview/test/browser_inspector_markup_mutation.html"; - }, true); - - content.location = "data:text/html,<html></html>"; - - function setupTest() { - var target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - inspector = toolbox.getCurrentPanel(); - startTests(); - }); - } - - function startTests() { - markup = inspector.markup; - checkMarkup(); - nextStep(0); - } - - function nextStep(cursor) { - if (cursor >= mutations.length) { - finishUp(); - return; - } - mutations[cursor](); - inspector.once("markupmutation", function() { - executeSoon(function() { - checkMarkup(); - nextStep(cursor + 1); - }); - }); - } - - function finishUp() { - doc = inspector = null; - gBrowser.removeTab(contentTab); - gBrowser.removeTab(parseTab); - finish(); - } -} diff --git a/browser/devtools/markupview/test/browser_inspector_markup_navigation.html b/browser/devtools/markupview/test/browser_inspector_markup_navigation.html deleted file mode 100644 index 9633052e1..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_navigation.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> - -<html class="html"> - <head class="head"> - <meta charset=utf-8 /> - </head> - - <body class="body"> - <div class="node0"> - <p class="node1">line1</p> - <p class="node2">line2</p> - <p class="node3">line3</p> - <!-- A comment --> - <p class="node4">line4 - <span class="node5">line5</span> - <span class="node6">line6</span> - <!-- A comment --> - <a class="node7">line7<span class="node8">line8</span></a> - <span class="node9">line9</span> - <span class="node10">line10</span> - <span class="node11">line11</span> - <a class="node12">line12<span class="node13">line13</span></a> - </p> - <p class="node14">line14</p> - <p class="node15">line15</p> - </div> - </body> -</html> diff --git a/browser/devtools/markupview/test/browser_inspector_markup_navigation.js b/browser/devtools/markupview/test/browser_inspector_markup_navigation.js deleted file mode 100644 index e36d3aa60..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_navigation.js +++ /dev/null @@ -1,151 +0,0 @@ -/* Any copyright", " is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ - - -function test() { - let inspector; - - waitForExplicitFinish(); - - let doc; - - let keySequences = [ - ["pageup", "*doctype*"], - ["down", "html"], - ["down", "head"], - ["down", "body"], - ["down", "node0"], - ["right", "node0"], - ["down", "node1"], - ["down", "node2"], - ["down", "node3"], - ["down", "*comment*"], - ["down", "node4"], - ["right", "node4"], - ["down", "*text*"], - ["down", "node5"], - ["down", "node6"], - ["down", "*comment*"], - ["down" , "node7"], - ["right", "node7"], - ["down", "*text*"], - ["down", "node8"], - ["left", "node7"], - ["left", "node7"], - ["right", "node7"], - ["right", "*text*"], - ["right", "*text*"], - ["down", "node8"], - ["right", "node8"], - ["left", "node8"], - ["down", "node9"], - ["down", "node10"], - ["down", "node11"], - ["down", "node12"], - ["right", "node12"], - ["down", "*text*"], - ["down", "node13"], - ["down", "node14"], - ["down", "node15"], - ["down", "node15"], - ["down", "node15"], - ["up", "node14"], - ["up", "node13"], - ["up", "*text*"], - ["up", "node12"], - ["left", "node12"], - ["down", "node14"], - ["home", "*doctype*"], - ["pagedown", "*text*"], - ["down", "node5"], - ["down", "node6"], - ["down", "*comment*"], - ["down", "node7"], - ["left", "node7"], - ["down", "node9"], - ["down", "node10"], - ["pageup", "node2"], - ["pageup", "*doctype*"], - ["down", "html"], - ["left", "html"], - ["down", "html"] - ]; - - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(setupTest, content); - }, true); - - content.location = "http://mochi.test:8888/browser/browser/devtools/markupview/test/browser_inspector_markup_navigation.html"; - - function setupTest() { - var target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - inspector = toolbox.getCurrentPanel(); - startNavigation(); - }); - } - - function startNavigation() { - nextStep(0); - } - - function nextStep(cursor) { - if (cursor >= keySequences.length) { - finishUp(); - return; - } - - let key = keySequences[cursor][0]; - let className = keySequences[cursor][1]; - inspector.markup._frame.focus(); - - switch(key) { - case "right": - EventUtils.synthesizeKey("VK_RIGHT", {}); - break; - case "down": - EventUtils.synthesizeKey("VK_DOWN", {}); - break; - case "left": - EventUtils.synthesizeKey("VK_LEFT", {}); - break; - case "up": - EventUtils.synthesizeKey("VK_UP", {}); - break; - case "pageup": - EventUtils.synthesizeKey("VK_PAGE_UP", {}); - break; - case "pagedown": - EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); - break; - case "home": - EventUtils.synthesizeKey("VK_HOME", {}); - break; - } - - executeSoon(function BIMNT_newNode() { - let node = inspector.selection.node; - - if (className == "*comment*") { - is(node.nodeType, Node.COMMENT_NODE, "[" + cursor + "] should be a comment after moving " + key); - } else if (className == "*text*") { - is(node.nodeType, Node.TEXT_NODE, "[" + cursor + "] should be text after moving " + key); - } else if (className == "*doctype*") { - is(node.nodeType, Node.DOCUMENT_TYPE_NODE, "[" + cursor + "] should be doctype after moving " + key); - } else { - is(node.className, className, "[" + cursor + "] right node selected: " + className + " after moving " + key); - } - - nextStep(cursor + 1); - }); - } - - function finishUp() { - doc = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - } -} diff --git a/browser/devtools/markupview/test/browser_inspector_markup_subset.html b/browser/devtools/markupview/test/browser_inspector_markup_subset.html deleted file mode 100644 index 8323f0b2e..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_subset.html +++ /dev/null @@ -1,32 +0,0 @@ -<!DOCTYPE html> - -<html class="html"> - <body class="body"> - <div id="a"></div> - <div id="b"></div> - <div id="c"></div> - <div id="d"></div> - <div id="e"></div> - <div id="f"></div> - <div id="g"></div> - <div id="h"></div> - <div id="i"></div> - <div id="j"></div> - <div id="k"></div> - <div id="l"></div> - <div id="m"></div> - <div id="n"></div> - <div id="o"></div> - <div id="p"></div> - <div id="q"></div> - <div id="r"></div> - <div id="s"></div> - <div id="t"></div> - <div id="u"></div> - <div id="v"></div> - <div id="w"></div> - <div id="x"></div> - <div id="y"></div> - <div id="z"></div> - </body> -</html> diff --git a/browser/devtools/markupview/test/browser_inspector_markup_subset.js b/browser/devtools/markupview/test/browser_inspector_markup_subset.js deleted file mode 100644 index 5b802c812..000000000 --- a/browser/devtools/markupview/test/browser_inspector_markup_subset.js +++ /dev/null @@ -1,146 +0,0 @@ -/* Any copyright", " is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ - -/** - * Tests that the markup view loads only as many nodes as specified - * by the devtools.markup.pagesize preference. - */ - -registerCleanupFunction(function() { - Services.prefs.clearUserPref("devtools.markup.pagesize"); -}); -Services.prefs.setIntPref("devtools.markup.pagesize", 5); - - -function test() { - waitForExplicitFinish(); - - // Will hold the doc we're viewing - let doc; - - let inspector; - - // Holds the MarkupTool object we're testing. - let markup; - - function assertChildren(expected) - { - let container = markup.getContainer(doc.querySelector("body")); - let found = []; - for (let child of container.children.children) { - if (child.classList.contains("more-nodes")) { - found += "*more*"; - } else { - found += child.container.node.getAttribute("id"); - } - } - is(expected, found, "Got the expected children."); - } - - function forceReload() - { - let container = markup.getContainer(doc.querySelector("body")); - container.childrenDirty = true; - } - - let selections = [ - { - desc: "Select the first item", - selector: "#a", - before: function() { - }, - after: function() { - assertChildren("abcde*more*"); - } - }, - { - desc: "Select the last item", - selector: "#z", - before: function() {}, - after: function() { - assertChildren("*more*vwxyz"); - } - }, - { - desc: "Select an already-visible item", - selector: "#v", - before: function() {}, - after: function() { - // Because "v" was already visible, we shouldn't have loaded - // a different page. - assertChildren("*more*vwxyz"); - }, - }, - { - desc: "Verify childrenDirty reloads the page", - selector: "#w", - before: function() { - forceReload(); - }, - after: function() { - // But now that we don't already have a loaded page, selecting - // w should center around w. - assertChildren("*more*uvwxy*more*"); - }, - }, - ]; - - // Create the helper tab for parsing... - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - doc = content.document; - waitForFocus(setupTest, content); - }, true); - content.location = "http://mochi.test:8888/browser/browser/devtools/markupview/test/browser_inspector_markup_subset.html"; - - function setupTest() { - var target = TargetFactory.forTab(gBrowser.selectedTab); - let toolbox = gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - toolbox.once("inspector-selected", function SE_selected(id, aInspector) { - inspector = aInspector; - markup = inspector.markup; - runNextSelection(); - }); - }); - } - - function runTests() { - inspector.selection.once("new-node", startTests); - executeSoon(function() { - inspector.selection.setNode(doc.body); - }); - } - - function runNextSelection() { - let selection = selections.shift(); - if (!selection) { - clickMore(); - return; - } - - info(selection.desc); - selection.before(); - inspector.selection.once("new-node", function() { - selection.after(); - runNextSelection(); - }); - inspector.selection.setNode(doc.querySelector(selection.selector)); - } - - function clickMore() { - info("Check that clicking more loads the whole thing."); - // Make sure that clicking the "more" button loads all the nodes. - let container = markup.getContainer(doc.querySelector("body")); - let button = container.elt.querySelector("button"); - button.click(); - assertChildren("abcdefghijklmnopqrstuvwxyz"); - finishUp(); - } - - function finishUp() { - doc = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - } -} diff --git a/browser/devtools/markupview/test/head.js b/browser/devtools/markupview/test/head.js deleted file mode 100644 index c1e1804bf..000000000 --- a/browser/devtools/markupview/test/head.js +++ /dev/null @@ -1,18 +0,0 @@ -/* 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/. */ - -const Cu = Components.utils; - -let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); -let TargetFactory = devtools.TargetFactory; - -// Clear preferences that may be set during the course of tests. -function clearUserPrefs() -{ - Services.prefs.clearUserPref("devtools.inspector.htmlPanelOpen"); - Services.prefs.clearUserPref("devtools.inspector.sidebarOpen"); - Services.prefs.clearUserPref("devtools.inspector.activeSidebar"); -} - -registerCleanupFunction(clearUserPrefs); diff --git a/browser/devtools/markupview/test/moz.build b/browser/devtools/markupview/test/moz.build deleted file mode 100644 index 895d11993..000000000 --- a/browser/devtools/markupview/test/moz.build +++ /dev/null @@ -1,6 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - |