mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1208864 - Tests for duplicate node context menu item in markup view. r=pbro
--HG-- extra : commitid : YsgJ6hXJtQ
This commit is contained in:
parent
6ac6649cf7
commit
c1ba6f6f41
@ -4,17 +4,14 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// Tests for menuitem functionality that doesn't fit into any specific category
|
||||
|
||||
const TEST_URL = TEST_URL_ROOT + "doc_inspector_menu.html";
|
||||
|
||||
add_task(function* () {
|
||||
let { inspector, toolbox, testActor } = yield openInspectorForURL(TEST_URL);
|
||||
|
||||
yield testShowDOMProperties();
|
||||
yield testDuplicateNode();
|
||||
yield testDeleteNode();
|
||||
yield testDeleteRootNode();
|
||||
yield testScrollIntoView();
|
||||
|
||||
function* testShowDOMProperties() {
|
||||
info("Testing 'Show DOM Properties' menu item.");
|
||||
let showDOMPropertiesNode = inspector.panelDoc.getElementById("node-menu-showdomproperties");
|
||||
@ -29,20 +26,38 @@ add_task(function* () {
|
||||
let webconsoleUI = toolbox.getPanel("webconsole").hud.ui;
|
||||
let messagesAdded = webconsoleUI.once("new-messages");
|
||||
yield messagesAdded;
|
||||
|
||||
info("Checking if 'inspect($0)' was evaluated");
|
||||
ok(webconsoleUI.jsterm.history[0] === 'inspect($0)');
|
||||
|
||||
yield toolbox.toggleSplitConsole();
|
||||
}
|
||||
function* testDuplicateNode() {
|
||||
info("Testing 'Duplicate Node' menu item for normal elements.");
|
||||
|
||||
yield selectNode(".duplicate", inspector);
|
||||
is((yield testActor.getNumberOfElementMatches(".duplicate")), 1,
|
||||
"There should initially be 1 .duplicate node");
|
||||
|
||||
let menuItem = inspector.panelDoc.getElementById("node-menu-duplicatenode");
|
||||
ok(menuItem, "'Duplicate node' menu item should exist");
|
||||
|
||||
info("Triggering 'Duplicate Node' and waiting for inspector to update");
|
||||
let updated = inspector.once("markupmutation");
|
||||
dispatchCommandEvent(menuItem);
|
||||
yield updated;
|
||||
|
||||
is((yield testActor.getNumberOfElementMatches(".duplicate")), 2,
|
||||
"The duplicated node should be in the markup.");
|
||||
|
||||
let container = yield getContainerForSelector(".duplicate + .duplicate",
|
||||
inspector);
|
||||
ok(container, "A MarkupContainer should be created for the new node");
|
||||
}
|
||||
|
||||
function* testDeleteNode() {
|
||||
info("Testing 'Delete Node' menu item for normal elements.");
|
||||
|
||||
yield selectNode("#delete", inspector);
|
||||
let deleteNode = inspector.panelDoc.getElementById("node-menu-delete");
|
||||
ok(deleteNode, "the popup menu has a delete menu item");
|
||||
|
||||
let updated = inspector.once("inspector-updated");
|
||||
|
||||
info("Triggering 'Delete Node' and waiting for inspector to update");
|
||||
|
@ -15,6 +15,7 @@
|
||||
</div>
|
||||
<p data-id="copy">Paragraph for testing copy</p>
|
||||
<p id="sensitivity">Paragraph for sensitivity</p>
|
||||
<p class="duplicate">This will be duplicated</p>
|
||||
<p id="delete">This has to be deleted</p>
|
||||
<img id="copyimage" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVQYV2P4DwABAQEAWk1v8QAAAABJRU5ErkJggg==" />
|
||||
<div id="hiddenElement" style="display: none;">
|
||||
|
@ -82,6 +82,21 @@ var TestActor = exports.TestActor = protocol.ActorClass({
|
||||
}
|
||||
return node;
|
||||
},
|
||||
/**
|
||||
* Helper to get the number of elements matching a selector
|
||||
* @param {string} CSS selector.
|
||||
*/
|
||||
getNumberOfElementMatches: protocol.method(function (selector,
|
||||
root=this.content.document) {
|
||||
return root.querySelectorAll(selector).length;
|
||||
}, {
|
||||
request: {
|
||||
selector: Arg(0, "string"),
|
||||
},
|
||||
response: {
|
||||
value: RetVal("number")
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Get a value for a given attribute name, on one of the elements of the box
|
||||
|
@ -57,6 +57,7 @@ skip-if = buildapp == 'mulet'
|
||||
[test_inspector-changeattrs.html]
|
||||
[test_inspector-changevalue.html]
|
||||
[test_inspector-dead-nodes.html]
|
||||
[test_inspector-duplicate-node.html]
|
||||
[test_inspector_getImageData.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[test_inspector_getImageDataFromURL.html]
|
||||
|
@ -80,12 +80,11 @@
|
||||
<select multiple><option>one</option><option>two</option></select>
|
||||
<div id="pseudo"><span>middle</span></div>
|
||||
<div id="pseudo-empty"></div>
|
||||
|
||||
<div id="shadow">light dom</div>
|
||||
|
||||
<object>
|
||||
<div id="1"></div>
|
||||
</object>
|
||||
<div class="node-to-duplicate"></div>
|
||||
<div id="scroll-into-view" style="margin-top: 1000px;">scroll</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1208864
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1208864</title>
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
const inspector = require("devtools/server/actors/inspector");
|
||||
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
var gInspectee = null;
|
||||
var gClient = null;
|
||||
var gWalker = null;
|
||||
|
||||
function assertOwnership() {
|
||||
assertOwnershipTrees(gWalker);
|
||||
}
|
||||
|
||||
addTest(function setup() {
|
||||
let url = document.getElementById("inspectorContent").href;
|
||||
attachURL(url, function(err, client, tab, doc) {
|
||||
gInspectee = doc;
|
||||
let {InspectorFront} = require("devtools/server/actors/inspector");
|
||||
let inspector = InspectorFront(client, tab);
|
||||
promiseDone(inspector.getWalker().then(walker => {
|
||||
ok(walker, "getWalker() should return an actor.");
|
||||
gClient = client;
|
||||
gWalker = walker;
|
||||
}).then(runNextTest));
|
||||
});
|
||||
});
|
||||
|
||||
addTest(Task.async(function* testDuplicateNode() {
|
||||
let className = ".node-to-duplicate";
|
||||
let matches = yield gWalker.querySelectorAll(gWalker.rootNode, className);
|
||||
is(matches.length, 1, "There should initially be one node to duplicate.");
|
||||
|
||||
let nodeFront = yield gWalker.querySelector(gWalker.rootNode, className);
|
||||
yield gWalker.duplicateNode(nodeFront);
|
||||
|
||||
matches = yield gWalker.querySelectorAll(gWalker.rootNode, className);
|
||||
is(matches.length, 2, "The node should now be duplicated.");
|
||||
|
||||
runNextTest();
|
||||
}));
|
||||
|
||||
addTest(function cleanup() {
|
||||
delete gWalker;
|
||||
delete gInspectee;
|
||||
delete gClient;
|
||||
runNextTest();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1208864">Mozilla Bug 1208864</a>
|
||||
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user