Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xpath / document-order.html
blobee940cbc993ec4e6a45322d9950169733b628533
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
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>
11 doc = (new DOMParser).parseFromString(
12 '<doc>' +
13 '<CHILD attr1="val1" attr31="31">' +
14 '<GCHILD name="GCHILD11"/>' +
15 '<GCHILD name="GCHILD12"/>' +
16 'TEXT1' +
17 '</CHILD>' +
18 '<CHILD attr4="4">' +
19 '<GCHILD name="GCHILD21"/>' +
20 '</CHILD>' +
21 '</doc>',
22 'application/xml');
24 CHILD1 = doc.getElementsByTagName("CHILD")[0];
25 CHILD2 = doc.getElementsByTagName("CHILD")[1];
26 attr1 = CHILD1.getAttributeNode("attr1");
27 attr31 = CHILD1.getAttributeNode("attr31");
28 attr4 = CHILD2.getAttributeNode("attr4");
29 GCHILD11 = doc.getElementsByTagName("GCHILD")[0];
30 GCHILD12 = doc.getElementsByTagName("GCHILD")[1];
31 GCHILD21 = doc.getElementsByTagName("GCHILD")[2];
32 TEXT1 = GCHILD12.nextSibling;
35 result = doc.evaluate("ancestor::*", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
36 checkSnapshot("ancestor::* (context = attr1)",
37 result,
38 [doc.documentElement, CHILD1]);
40 result = doc.evaluate("ancestor::*", GCHILD11, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
41 checkSnapshot("ancestor::* (context = GCHILD11)",
42 result,
43 [doc.documentElement, CHILD1]);
45 result = doc.evaluate("ancestor::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
46 checkSnapshot("ancestor::node() (context = attr1)",
47 result,
48 [doc, doc.documentElement, CHILD1]);
50 result = doc.evaluate("ancestor::node()", GCHILD11, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
51 checkSnapshot("ancestor::node() (context = GCHILD11)",
52 result,
53 [doc, doc.documentElement, CHILD1]);
55 result = doc.evaluate("preceding::node()", attr4, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
56 checkSnapshot("preceding::node() (context = attr4)",
57 result,
58 [CHILD1, GCHILD11, GCHILD12, TEXT1]);
60 result = doc.evaluate("preceding::node()", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
61 checkSnapshot("preceding::node() (context = CHILD2)",
62 result,
63 [CHILD1, GCHILD11, GCHILD12, TEXT1]);
65 result = doc.evaluate("preceding::node()", GCHILD12, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
66 checkSnapshot("preceding::node() (context = GCHILD12)",
67 result,
68 [GCHILD11]);
70 result = doc.evaluate("following::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
71 checkSnapshot("following::node() (context = attr1)",
72 result,
73 [GCHILD11, GCHILD12, TEXT1, CHILD2, GCHILD21]);
75 result = doc.evaluate("following::node()", CHILD1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
76 checkSnapshot("following::node() (context = CHILD1)",
77 result,
78 [CHILD2, GCHILD21]);
80 result = doc.evaluate("following::node()", GCHILD11, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
81 checkSnapshot("following::node() (context = GCHILD11)",
82 result,
83 [GCHILD12, TEXT1, CHILD2, GCHILD21]);
85 result = doc.evaluate("following::node()", CHILD2, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
86 checkSnapshot("following::node() (context = CHILD2)",
87 result,
88 []);
90 result = doc.evaluate("//CHILD | //@attr1", doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
91 checkSnapshot("//CHILD | //@attr1",
92 result,
93 [CHILD1, attr1, CHILD2]);
95 result = doc.evaluate("//CHILD | //@attr1 | //*[@name='GCHILD12'] | //@attr31", doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
96 checkSnapshot("//CHILD | //@attr1 | //*[@name='GCHILD12'] | //@attr31",
97 result,
98 [CHILD1, attr1, attr31, GCHILD12, CHILD2]);
100 result = doc.evaluate("(//CHILD | //@attr1 | //*[@name='GCHILD12'] | //@attr31)[3]", doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
101 checkSnapshot("(//CHILD | //@attr1 | //*[@name='GCHILD12'] | //@attr31)[3]",
102 result,
103 [attr31]);
105 result = doc.evaluate("(//CHILD | //@attr1 | //*[@name='GCHILD12'] | //@attr31)[position() = last()]", doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
106 checkSnapshot("(//CHILD | //@attr1 | //*[@name='GCHILD12'] | //@attr31)[position() = last()]",
107 result,
108 [CHILD2]);
110 result = doc.evaluate("//CHILD[2]/GCHILD | //CHILD[1]/GCHILD", doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
111 checkSnapshot("//CHILD[2]/GCHILD | //CHILD[1]/GCHILD",
112 result,
113 [GCHILD11, GCHILD12, GCHILD21]);
115 shouldBe('doc.evaluate("string(//*[@name=\'GCHILD12\'] | //CHILD | //@attr1 | //@attr31)", doc, null, XPathResult.STRING_TYPE, null).stringValue', '"TEXT1"');
117 result = doc.evaluate("descendant::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
118 checkSnapshot("descendant::node() (context = attr1)",
119 result,
120 []);
122 result = doc.evaluate("child::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
123 checkSnapshot("child::node() (context = attr1)",
124 result,
125 []);
127 result = doc.evaluate("parent::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
128 checkSnapshot("parent::node() (context = attr1)",
129 result,
130 [CHILD1]);
132 result = doc.evaluate("following-sibling::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
133 checkSnapshot("following-sibling::node() (context = attr1)",
134 result,
135 []);
137 result = doc.evaluate("preceding-sibling::node()", attr4, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
138 checkSnapshot("preceding-sibling::node() (context = attr4)",
139 result,
140 []);
142 result = doc.evaluate("attribute::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
143 checkSnapshot("attribute::node() (context = attr1)",
144 result,
145 []);
147 result = doc.evaluate("self::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
148 checkSnapshot("self::node() (context = attr1)",
149 result,
150 [attr1]);
152 result = doc.evaluate("self::*", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
153 checkSnapshot("self::* (context = attr1)",
154 result,
155 []);
157 result = doc.evaluate("descendant-or-self::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
158 checkSnapshot("descendant-or-self::node() (context = attr1)",
159 result,
160 [attr1]);
162 result = doc.evaluate("ancestor-or-self::node()", attr1, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
163 checkSnapshot("ancestor-or-self::node() (context = attr1)",
164 result,
165 [doc, doc.documentElement, CHILD1, attr1]);
167 </script>
168 </body>
169 </html>