| 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..4591febdacc323f676043a1714222d8c8c71605c
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector/elements/elements-css-path.html
|
| @@ -0,0 +1,102 @@
|
| +<!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)
|
| +{
|
| + var res = document.querySelectorAll(selector).length;
|
| + return res;
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + var nodeQueue = [];
|
| +
|
| + InspectorTest.runTestSuite([
|
| + 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"));
|
| + var escapedPath = cssPath.replace(/'/g, "\\\'");
|
| + InspectorTest.evaluateInPage("matchingElements('" + escapedPath + "')", 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="id-with-class" class="moo">4</div>
|
| +
|
| +<div id="container">
|
| + <div>5</div>
|
| + <div>6</div>
|
| + <div id="inner-id">7</div>
|
| + <div id='#"ridiculous".id'>8</div>
|
| + <div id="'quoted.value'">9</div>
|
| + <div id=".foo.bar">10</div>
|
| + <p>11</p>
|
| +</div>
|
| +
|
| +</body>
|
| +</html>
|
|
|