Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xpath / position.html
blob702423510f10807d22f55e8723b6f0ec7ff4eb0b
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="xpath-test-pre.js"></script>
6 </head>
7 <body>
8 <div id="console"></div>
10 <script>
12 var ROOT = document.createElement('div');
13 ROOT.innerHTML = '<p>a</p><div><span id="21"></span><span id="22"></span><span id="23"></span></div>';
14 var CHILD1 = ROOT.firstChild;
15 var CHILD1TEXT = CHILD1.firstChild;
16 var CHILD2 = ROOT.lastChild;
17 var CHILD21 = CHILD2.firstChild;
18 var CHILD22 = CHILD21.nextSibling;
19 var CHILD23 = CHILD22.nextSibling;
21 result = document.evaluate(".//*", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
22 checkSnapshot(".//*", result, [CHILD1, CHILD2, CHILD21, CHILD22, CHILD23]);
24 result = document.evaluate("*[position() = 2]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
25 checkSnapshot("*[position() = 2]", result, [CHILD2]);
27 result = document.evaluate(".//*[position() = 2]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
28 checkSnapshot(".//*[position() = 2]", result, [CHILD2, CHILD22]);
30 result = document.evaluate("./././/*[2]/.", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
31 checkSnapshot("./././/*[2]/.", result, [CHILD2, CHILD22]);
33 result = document.evaluate(".//*/span[2]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
34 checkSnapshot(".//*/span[2]", result, [CHILD22]);
36 result = document.evaluate(".//*[position() = 1]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
37 checkSnapshot(".//*[position() = 1]", result, [CHILD1, CHILD21]);
39 result = document.evaluate("./descendant-or-self::node()/child::*[position() = 2]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
40 checkSnapshot("./descendant-or-self::node()/child::*[position() = 2]", result, [CHILD2, CHILD22]);
42 result = document.evaluate("descendant-or-self::node()/child::*[position() = 2]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
43 checkSnapshot("descendant-or-self::node()/child::*[position() = 2]", result, [CHILD2, CHILD22]);
45 result = document.evaluate(".//*/*[2]", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
46 checkSnapshot(".//*/*[2]", result, [CHILD22]);
48 result = document.evaluate("preceding::node()[1]", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
49 checkSnapshot("preceding::node()[1]", result, [CHILD1TEXT]);
51 result = document.evaluate("preceding::node()[2]", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
52 checkSnapshot("preceding::node()[2]", result, [CHILD1]);
54 result = document.evaluate("preceding::node()[3]", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
55 checkSnapshot("preceding::node()[3]", result, []);
57 result = document.evaluate("preceding::node()/*[3]", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
58 checkSnapshot("preceding::node()/*[3]", result, []);
60 result = document.evaluate("ancestor::node()[2]", CHILD21, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
61 checkSnapshot("ancestor::node()[2]", result, [ROOT]);
63 result = document.evaluate("ancestor-or-self::node()[2]", CHILD21, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
64 checkSnapshot("ancestor-or-self::node()[2]", result, [CHILD2]);
66 result = document.evaluate("ancestor-or-self::node()[3]", CHILD21, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
67 checkSnapshot("ancestor-or-self::node()[3]", result, [ROOT]);
69 result = document.evaluate("preceding::span[1]", CHILD23, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
70 checkSnapshot("preceding::span[1]", result, [CHILD22]);
72 result = document.evaluate("(preceding::span)[1]", CHILD23, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
73 checkSnapshot("(preceding::span)[1]", result, [CHILD21]);
75 var ROOT2 = document.createElement('div');
76 ROOT2.innerHTML = '<p num="1"></p><p num="2" type="warning"></p><p num="3" type="warning"></p><p num="4" type="warning"></p><p num="5" type="warning"></p><p num="6" type="warning"></p>';
78 shouldBe("document.evaluate('p[@type=\"warning\"][5]/@num', ROOT2, null, XPathResult.STRING_TYPE, null).stringValue", "'6'");
79 shouldBe("document.evaluate('p[5][@type=\"warning\"]/@num', ROOT2, null, XPathResult.STRING_TYPE, null).stringValue", "'5'");
81 </script>
82 </body>
83 </html>