Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / dom / svg / level3 / xpath / Conformance_Expressions.js
blob342826b0e2e35452a02d073af7afd8f01bfb1850
1 /*
2 Copyright Â© 2001-2004 World Wide Web Consortium,
3 (Massachusetts Institute of Technology, European Research Consortium
4 for Informatics and Mathematics, Keio University). All
5 Rights Reserved. This work is distributed under the W3C® Software License [1] in the
6 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
12 // expose test function names
13 function exposeTestFunctionNames()
15 return ['Conformance_Expressions'];
18 var docsLoaded = -1000000;
19 var builder = null;
22 //   This function is called by the testing framework before
23 //      running the test suite.
25 //   If there are no configuration exceptions, asynchronous
26 //        document loading is started.  Otherwise, the status
27 //        is set to complete and the exception is immediately
28 //        raised when entering the body of the test.
30 function setUpPage() {
31    setUpPageStatus = 'running';
32    try {
33      //
34      //   creates test document builder, may throw exception
35      //
36      builder = createConfiguredBuilder();
38       docsLoaded = 0;
40       var docRef = null;
41       if (typeof(this.doc) != 'undefined') {
42         docRef = this.doc;
43       }
44       docsLoaded += preload(docRef, "doc", "staffNS");
46        if (docsLoaded == 1) {
47           setUpPageStatus = 'complete';
48        }
49     } catch(ex) {
50         catchInitializationError(builder, ex);
51         setUpPageStatus = 'complete';
52     }
56 //   This method is called on the completion of
57 //      each asychronous load started in setUpTests.
59 //   When every synchronous loaded document has completed,
60 //      the page status is changed which allows the
61 //      body of the test to be executed.
62 function loadComplete() {
63     if (++docsLoaded == 1) {
64         setUpPageStatus = 'complete';
65     }
68 /**
70       1.3 Conformance - Iterate over a list of strings containing
71       valid XPath expressions, calling XPathEvaluator.createExpression
72       for each. If no expections are thrown and each result is non-null,
73       then the test passes.
75 * @author Bob Clary
76 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#Conformance
77 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator
78 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createNSResolver
79 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createExpression
80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSResolver
82 function Conformance_Expressions() {
83    var success;
84     if(checkInitialization(builder, "Conformance_Expressions") != null) return;
85     var doc;
86       var resolver;
87       var evaluator;
88       var expression;
89       var expressionList = new Array();
91       var xpathexpression;
93       var docRef = null;
94       if (typeof(this.doc) != 'undefined') {
95         docRef = this.doc;
96       }
97       doc = load(docRef, "doc", "staffNS");
98       evaluator = createXPathEvaluator(doc);
99 resolver = evaluator.createNSResolver(doc);
100       expressionList[expressionList.length] = "/";
101 expressionList[expressionList.length] = "child::comment()";
102 expressionList[expressionList.length] = "child::text()";
103 expressionList[expressionList.length] = "child::processing-instruction()";
104 expressionList[expressionList.length] = "child::processing-instruction('name')";
105 expressionList[expressionList.length] = "child::node()";
106 expressionList[expressionList.length] = "child::*";
107 expressionList[expressionList.length] = "child::nist:*";
108 expressionList[expressionList.length] = "child::employee";
109 expressionList[expressionList.length] = "descendant::comment()";
110 expressionList[expressionList.length] = "descendant::text()";
111 expressionList[expressionList.length] = "descendant::processing-instruction()";
112 expressionList[expressionList.length] = "descendant::processing-instruction('name')";
113 expressionList[expressionList.length] = "descendant::node()";
114 expressionList[expressionList.length] = "descendant::*";
115 expressionList[expressionList.length] = "descendant::nist:*";
116 expressionList[expressionList.length] = "descendant::employee";
117 expressionList[expressionList.length] = "parent::comment()";
118 expressionList[expressionList.length] = "parent::text()";
119 expressionList[expressionList.length] = "parent::processing-instruction()";
120 expressionList[expressionList.length] = "parent::processing-instruction('name')";
121 expressionList[expressionList.length] = "parent::node()";
122 expressionList[expressionList.length] = "parent::*";
123 expressionList[expressionList.length] = "parent::nist:*";
124 expressionList[expressionList.length] = "parent::employee";
125 expressionList[expressionList.length] = "ancestor::comment()";
126 expressionList[expressionList.length] = "ancestor::text()";
127 expressionList[expressionList.length] = "ancestor::processing-instruction()";
128 expressionList[expressionList.length] = "ancestor::processing-instruction('name')";
129 expressionList[expressionList.length] = "ancestor::node()";
130 expressionList[expressionList.length] = "ancestor::*";
131 expressionList[expressionList.length] = "ancestor::nist:*";
132 expressionList[expressionList.length] = "ancestor::employee";
133 expressionList[expressionList.length] = "following-sibling::comment()";
134 expressionList[expressionList.length] = "following-sibling::text()";
135 expressionList[expressionList.length] = "following-sibling::processing-instruction()";
136 expressionList[expressionList.length] = "following-sibling::processing-instruction('name')";
137 expressionList[expressionList.length] = "following-sibling::node()";
138 expressionList[expressionList.length] = "following-sibling::*";
139 expressionList[expressionList.length] = "following-sibling::nist:*";
140 expressionList[expressionList.length] = "following-sibling::employee";
141 expressionList[expressionList.length] = "preceding-sibling::comment()";
142 expressionList[expressionList.length] = "preceding-sibling::text()";
143 expressionList[expressionList.length] = "preceding-sibling::processing-instruction()";
144 expressionList[expressionList.length] = "preceding-sibling::processing-instruction('name')";
145 expressionList[expressionList.length] = "preceding-sibling::node()";
146 expressionList[expressionList.length] = "preceding-sibling::*";
147 expressionList[expressionList.length] = "preceding-sibling::nist:*";
148 expressionList[expressionList.length] = "preceding-sibling::employee";
149 expressionList[expressionList.length] = "following::comment()";
150 expressionList[expressionList.length] = "following::text()";
151 expressionList[expressionList.length] = "following::processing-instruction()";
152 expressionList[expressionList.length] = "following::processing-instruction('name')";
153 expressionList[expressionList.length] = "following::node()";
154 expressionList[expressionList.length] = "following::*";
155 expressionList[expressionList.length] = "following::nist:*";
156 expressionList[expressionList.length] = "following::employee";
157 expressionList[expressionList.length] = "preceding::comment()";
158 expressionList[expressionList.length] = "preceding::text()";
159 expressionList[expressionList.length] = "preceding::processing-instruction()";
160 expressionList[expressionList.length] = "preceding::processing-instruction('name')";
161 expressionList[expressionList.length] = "preceding::node()";
162 expressionList[expressionList.length] = "preceding::*";
163 expressionList[expressionList.length] = "preceding::nist:*";
164 expressionList[expressionList.length] = "preceding::employee";
165 expressionList[expressionList.length] = "attribute::comment()";
166 expressionList[expressionList.length] = "attribute::text()";
167 expressionList[expressionList.length] = "attribute::processing-instruction()";
168 expressionList[expressionList.length] = "attribute::processing-instruction('name')";
169 expressionList[expressionList.length] = "attribute::node()";
170 expressionList[expressionList.length] = "attribute::*";
171 expressionList[expressionList.length] = "attribute::nist:*";
172 expressionList[expressionList.length] = "attribute::employee";
173 expressionList[expressionList.length] = "namespace::comment()";
174 expressionList[expressionList.length] = "namespace::text()";
175 expressionList[expressionList.length] = "namespace::processing-instruction()";
176 expressionList[expressionList.length] = "namespace::processing-instruction('name')";
177 expressionList[expressionList.length] = "namespace::node()";
178 expressionList[expressionList.length] = "namespace::*";
179 expressionList[expressionList.length] = "namespace::nist:*";
180 expressionList[expressionList.length] = "namespace::employee";
181 expressionList[expressionList.length] = "self::comment()";
182 expressionList[expressionList.length] = "self::text()";
183 expressionList[expressionList.length] = "self::processing-instruction()";
184 expressionList[expressionList.length] = "self::processing-instruction('name')";
185 expressionList[expressionList.length] = "self::node()";
186 expressionList[expressionList.length] = "self::*";
187 expressionList[expressionList.length] = "self::nist:*";
188 expressionList[expressionList.length] = "self::employee";
189 expressionList[expressionList.length] = "descendant-or-self::comment()";
190 expressionList[expressionList.length] = "descendant-or-self::text()";
191 expressionList[expressionList.length] = "descendant-or-self::processing-instruction()";
192 expressionList[expressionList.length] = "descendant-or-self::processing-instruction('name')";
193 expressionList[expressionList.length] = "descendant-or-self::node()";
194 expressionList[expressionList.length] = "descendant-or-self::*";
195 expressionList[expressionList.length] = "descendant-or-self::nist:*";
196 expressionList[expressionList.length] = "descendant-or-self::employee";
197 expressionList[expressionList.length] = "ancestor-or-self::comment()";
198 expressionList[expressionList.length] = "ancestor-or-self::text()";
199 expressionList[expressionList.length] = "ancestor-or-self::processing-instruction()";
200 expressionList[expressionList.length] = "ancestor-or-self::processing-instruction('name')";
201 expressionList[expressionList.length] = "ancestor-or-self::node()";
202 expressionList[expressionList.length] = "ancestor-or-self::*";
203 expressionList[expressionList.length] = "ancestor-or-self::nist:*";
204 expressionList[expressionList.length] = "ancestor-or-self::employee";
205 expressionList[expressionList.length] = "comment()";
206 expressionList[expressionList.length] = "text()";
207 expressionList[expressionList.length] = "processing-instruction()";
208 expressionList[expressionList.length] = "processing-instruction('name')";
209 expressionList[expressionList.length] = "node()";
210 expressionList[expressionList.length] = "*";
211 expressionList[expressionList.length] = "nist:*";
212 expressionList[expressionList.length] = "employee";
213 expressionList[expressionList.length] = ".//comment()";
214 expressionList[expressionList.length] = ".//text()";
215 expressionList[expressionList.length] = ".//processing-instruction()";
216 expressionList[expressionList.length] = ".//processing-instruction('name')";
217 expressionList[expressionList.length] = ".//node()";
218 expressionList[expressionList.length] = ".//*";
219 expressionList[expressionList.length] = ".//nist:*";
220 expressionList[expressionList.length] = ".//employee";
221 expressionList[expressionList.length] = "../comment()";
222 expressionList[expressionList.length] = "../text()";
223 expressionList[expressionList.length] = "../processing-instruction()";
224 expressionList[expressionList.length] = "../processing-instruction('name')";
225 expressionList[expressionList.length] = "../node()";
226 expressionList[expressionList.length] = "../*";
227 expressionList[expressionList.length] = "../nist:*";
228 expressionList[expressionList.length] = "../employee";
229 expressionList[expressionList.length] = "@attributename";
230 expressionList[expressionList.length] = "./comment()";
231 expressionList[expressionList.length] = "./text()";
232 expressionList[expressionList.length] = "./processing-instruction()";
233 expressionList[expressionList.length] = "./processing-instruction('name')";
234 expressionList[expressionList.length] = "./node()";
235 expressionList[expressionList.length] = "./*";
236 expressionList[expressionList.length] = "./nist:*";
237 expressionList[expressionList.length] = "./employee";
238 expressionList[expressionList.length] = "comment() | text() | processing-instruction() | node()";
239 expressionList[expressionList.length] = "employee[address]";
240 expressionList[expressionList.length] = "employee/address[@street]";
241 expressionList[expressionList.length] = "employee[position='Computer Specialist']";
242 expressionList[expressionList.length] = "employee[position!='Computer Specialist']";
243 expressionList[expressionList.length] = "employee[gender='Male' or gender='Female']";
244 expressionList[expressionList.length] = "employee[gender!='Male' and gender!='Female']";
245 expressionList[expressionList.length] = "employee/address[@street='Yes']";
246 expressionList[expressionList.length] = "employee/address[@street!='Yes']";
247 expressionList[expressionList.length] = "employee[position()=1]";
248 expressionList[expressionList.length] = "employee[1]";
249 expressionList[expressionList.length] = "employee[position()=last()]";
250 expressionList[expressionList.length] = "employee[last()]";
251 expressionList[expressionList.length] = "employee[position()>1 and position<last()]";
252 expressionList[expressionList.length] = "employee[position()>=1 and position<=last()]";
253 expressionList[expressionList.length] = "employee[count(.)>0]";
254 expressionList[expressionList.length] = "employee[position() mod 2=0]";
255 expressionList[expressionList.length] = "employee[position() mod -2=0]";
256 expressionList[expressionList.length] = "employee[position() div 2=0]";
257 expressionList[expressionList.length] = "employee[position() div -2=-1]";
258 expressionList[expressionList.length] = "employee[position() div 2 * 2=position()]";
259 expressionList[expressionList.length] = "employee[3 > 2 > 1]";
260 expressionList[expressionList.length] = "id('CANADA')";
261 expressionList[expressionList.length] = "*[local-name()='employee']";
262 expressionList[expressionList.length] = "*[local-name(.)='employee']";
263 expressionList[expressionList.length] = "*[local-name(employee)='employee']";
264 expressionList[expressionList.length] = "*[local-name()='employee']";
265 expressionList[expressionList.length] = "*[namespace-uri()='http://www.nist.gov']";
266 expressionList[expressionList.length] = "*[name()='nist:employee']";
267 expressionList[expressionList.length] = "*[string()]";
268 expressionList[expressionList.length] = "*[string(10 div foo)='NaN']";
269 expressionList[expressionList.length] = "*[concat('a', 'b', 'c')]";
270 expressionList[expressionList.length] = "*[starts-with('employee', 'emp')]";
271 expressionList[expressionList.length] = "*[contains('employee', 'emp')]";
272 expressionList[expressionList.length] = "*[substring-before('employeeId', 'Id')]";
273 expressionList[expressionList.length] = "*[substring-after('employeeId', 'employee')]";
274 expressionList[expressionList.length] = "*[substring('employeeId', 4)]";
275 expressionList[expressionList.length] = "*[substring('employeeId', 4, 5)]";
276 expressionList[expressionList.length] = "*[string-length()=2]";
277 expressionList[expressionList.length] = "*[string-length(.)=string-length(normalize-space(.))]";
278 expressionList[expressionList.length] = "*[translate('bar', 'abc', 'ABC')='BAr']";
279 expressionList[expressionList.length] = "*[boolean(.)]";
280 expressionList[expressionList.length] = "*[not(boolean(.))]";
281 expressionList[expressionList.length] = "*[true()]";
282 expressionList[expressionList.length] = "*[false()]";
283 expressionList[expressionList.length] = "*[lang('en')]";
284 expressionList[expressionList.length] = "*[number()]";
285 expressionList[expressionList.length] = "*[number('4')]";
286 expressionList[expressionList.length] = "*[floor(.)]>0";
287 expressionList[expressionList.length] = "*[ceiling(.)]<1";
288 expressionList[expressionList.length] = "*[round(number(.))=0]<1";
289 for(var indexN66388 = 0;indexN66388 < expressionList.length; indexN66388++) {
290       expression = expressionList[indexN66388];
291       xpathexpression = evaluator.createExpression(expression,resolver);
293     }
297 function runTest() {
298    Conformance_Expressions();