Index: LayoutTests/inspector/elements/elements-css-path.html |
diff --git a/LayoutTests/inspector/elements/elements-css-path.html b/LayoutTests/inspector/elements/elements-css-path.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..10c05bff3b731fcb998b7d8e13138db032515738 |
--- /dev/null |
+++ b/LayoutTests/inspector/elements/elements-css-path.html |
@@ -0,0 +1,96 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script src="../../http/tests/inspector/inspector-test.js" id="script-id"></script> |
+<script src="../../http/tests/inspector/elements-test.js"></script> |
+<script id="test-script"> |
+function matchingElements(selector) |
+{ |
+ return document.querySelectorAll(selector).length; |
+} |
+ |
+function test() |
+{ |
+ var nodeQueue = []; |
+ |
+ InspectorTest.runTestSuite([ |
aandrey
2013/11/18 15:36:26
I thought every function passed to the suite shoul
|
+ function init(next) |
+ { |
+ InspectorTest.expandElementsTree(next); |
+ }, |
+ |
+ function enqueueNodes(next) |
+ { |
+ enqueueNode("", getDocumentElement()); |
+ next(); |
+ }, |
+ |
+ function dumpNodes(next) |
+ { |
+ dumpNodeData(); |
+ |
+ function dumpNodeData() |
+ { |
+ var entry = nodeQueue.shift(); |
+ if (!entry) { |
+ InspectorTest.completeTest(); |
+ return; |
+ } |
+ var cssPath = entry.node.cssPath(true); |
+ var result = entry.prefix + cssPath; |
+ InspectorTest.addResult(result.replace(/\n/g, "\\n")); |
+ InspectorTest.evaluateInPage("matchingElements('" + cssPath + "')", callback); |
+ |
+ function callback(result) |
+ { |
+ InspectorTest.assertEquals(1, result.value); |
+ dumpNodeData(); |
+ } |
+ } |
+ } |
+ ]); |
+ |
+ function getDocumentElement() |
+ { |
+ var map = WebInspector.domAgent._idToDOMNode; |
+ for (var id in map) { |
+ if (map[id].nodeName() === "#document") |
+ return map[id]; |
+ } |
+ |
+ return null; |
+ } |
+ |
+ |
+ function enqueueNode(prefix, node) |
+ { |
+ if (node.nodeType() === Node.ELEMENT_NODE) |
+ nodeQueue.push({prefix: prefix, node: node}); |
+ var children = node.children(); |
+ for (var i = 0; children && i < children.length; ++i) |
+ enqueueNode(prefix + " ", children[i]); |
+ } |
+ |
+} |
+</script> |
+</head> |
+ |
+<body onload="runTest()"> |
+<p>Tests DOMNode.cssPath()</p> |
+ |
+<article>First</article> |
+<article>Second</article> |
+ |
+<div class="foo bar">1</div> |
+<div class="foo foo">2</div> |
+<span class="bar">3</span> |
+ |
+<div id="container"> |
+ <div>4</div> |
+ <div>5</div> |
+ <div id="inner-id">6</div> |
+ <p>7</p> |
+</div> |
+ |
+</body> |
+</html> |