Drop legacy XPathException type
[WebKit.git] / LayoutTests / dom / svg / level3 / xpath / XPathResult_TYPE_ERR.js
1
2 /*
3 Copyright Â© 2001-2004 World Wide Web Consortium, 
4 (Massachusetts Institute of Technology, European Research Consortium 
5 for Informatics and Mathematics, Keio University). All 
6 Rights Reserved. This work is distributed under the W3C® Software License [1] in the 
7 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
8 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
9
10 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 */
12
13
14 // expose test function names
15 function exposeTestFunctionNames()
16 {
17 return ['XPathResult_TYPE_ERR'];
18 }
19
20 var docsLoaded = -1000000;
21 var builder = null;
22
23 //
24 //   This function is called by the testing framework before
25 //      running the test suite.
26 //
27 //   If there are no configuration exceptions, asynchronous
28 //        document loading is started.  Otherwise, the status
29 //        is set to complete and the exception is immediately
30 //        raised when entering the body of the test.
31 //
32 function setUpPage() {
33    setUpPageStatus = 'running';
34    try {
35      //
36      //   creates test document builder, may throw exception
37      //
38      builder = createConfiguredBuilder();
39
40       docsLoaded = 0;
41       
42       var docRef = null;
43       if (typeof(this.doc) != 'undefined') {
44         docRef = this.doc;
45       }
46       docsLoaded += preload(docRef, "doc", "staff");
47         
48        if (docsLoaded == 1) {
49           setUpPageStatus = 'complete';
50        }
51     } catch(ex) {
52         catchInitializationError(builder, ex);
53         setUpPageStatus = 'complete';
54     }
55 }
56
57
58
59 //
60 //   This method is called on the completion of 
61 //      each asychronous load started in setUpTests.
62 //
63 //   When every synchronous loaded document has completed,
64 //      the page status is changed which allows the
65 //      body of the test to be executed.
66 function loadComplete() {
67     if (++docsLoaded == 1) {
68         setUpPageStatus = 'complete';
69     }
70 }
71
72
73 /**
74
75       Create an XPathResult for the expression /staff/employee
76       for each type of XPathResultType, checking that TYPE_ERR
77       is thrown when inappropriate properties and methods are accessed.
78     
79 * @author Bob Clary
80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#TYPE_ERR
81 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathException
82 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
83 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResultType
84 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createNSResolver
85 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-resultType
86 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-booleanValue
87 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-numberValue
88 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-singleNodeValue
89 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-snapshot-length
90 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-stringValue
91 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-iterateNext
92 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult-snapshotItem
93 */
94 function XPathResult_TYPE_ERR() {
95    var success;
96     if(checkInitialization(builder, "XPathResult_TYPE_ERR") != null) return;
97     var doc;
98       var resolver;
99       var evaluator;
100       var expression = "/staff/employee";
101       var contextNode;
102       var inresult = null;
103
104       var outresult = null;
105
106       var inNodeType;
107       var outNodeType;
108       var ANY_TYPE = 0;
109       var NUMBER_TYPE = 1;
110       var STRING_TYPE = 2;
111       var BOOLEAN_TYPE = 3;
112       var UNORDERED_NODE_ITERATOR_TYPE = 4;
113       var ORDERED_NODE_ITERATOR_TYPE = 5;
114       var UNORDERED_NODE_SNAPSHOT_TYPE = 6;
115       var ORDERED_NODE_SNAPSHOT_TYPE = 7;
116       var ANY_UNORDERED_NODE_TYPE = 8;
117       var FIRST_ORDERED_NODE_TYPE = 9;
118       var booleanValue;
119       var shortValue;
120       var intValue;
121       var doubleValue;
122       var nodeValue;
123       var stringValue;
124       nodeTypeList = new Array();
125       nodeTypeList[0] = 0;
126       nodeTypeList[1] = 1;
127       nodeTypeList[2] = 2;
128       nodeTypeList[3] = 3;
129       nodeTypeList[4] = 4;
130       nodeTypeList[5] = 5;
131       nodeTypeList[6] = 6;
132       nodeTypeList[7] = 7;
133       nodeTypeList[8] = 8;
134       nodeTypeList[9] = 9;
135
136       
137       var docRef = null;
138       if (typeof(this.doc) != 'undefined') {
139         docRef = this.doc;
140       }
141       doc = load(docRef, "doc", "staff");
142       evaluator = createXPathEvaluator(doc);
143 resolver = evaluator.createNSResolver(doc);
144       contextNode =  doc;
145 for(var indexN65778 = 0;indexN65778 < nodeTypeList.length; indexN65778++) {
146       inNodeType = nodeTypeList[indexN65778];
147       outresult = evaluator.evaluate(expression,contextNode,resolver,inNodeType,inresult);
148       outNodeType = outresult.resultType;
149
150       
151         if(
152         (outNodeType == NUMBER_TYPE)
153         ) {
154         
155         {
156                 success = false;
157                 try {
158             booleanValue = outresult.booleanValue;
159
160         }
161                 catch(ex) {            
162       success = (ex.name == "TypeError");
163                 }
164                 assertTrue("number_booleanValue_TYPE_ERR",success);
165         }
166
167         {
168                 success = false;
169                 try {
170             nodeValue = outresult.singleNodeValue;
171
172         }
173                 catch(ex) {            
174       success = (ex.name == "TypeError");
175                 }
176                 assertTrue("number_singleNodeValue_TYPE_ERR",success);
177         }
178
179         {
180                 success = false;
181                 try {
182             intValue = outresult.snapshotLength;
183
184         }
185                 catch(ex) {            
186       success = (ex.name == "TypeError");
187                 }
188                 assertTrue("number_snapshotLength_TYPE_ERR",success);
189         }
190
191         {
192                 success = false;
193                 try {
194             stringValue = outresult.stringValue;
195
196         }
197                 catch(ex) {            
198       success = (ex.name == "TypeError");
199                 }
200                 assertTrue("number_stringValue_TYPE_ERR",success);
201         }
202
203         {
204                 success = false;
205                 try {
206             nodeValue = outresult.iterateNext();
207         }
208                 catch(ex) {            
209       success = (ex.name == "TypeError");
210                 }
211                 assertTrue("number_iterateNext_TYPE_ERR",success);
212         }
213
214         {
215                 success = false;
216                 try {
217             nodeValue = outresult.snapshotItem(0);
218         }
219                 catch(ex) {            
220       success = (ex.name == "TypeError");
221                 }
222                 assertTrue("number_snapshotItem_TYPE_ERR",success);
223         }
224
225         }
226         
227         if(
228         (outNodeType == STRING_TYPE)
229         ) {
230         
231         {
232                 success = false;
233                 try {
234             booleanValue = outresult.booleanValue;
235
236         }
237                 catch(ex) {            
238       success = (ex.name == "TypeError");
239                 }
240                 assertTrue("string_booleanValue_TYPE_ERR",success);
241         }
242
243         {
244                 success = false;
245                 try {
246             doubleValue = outresult.numberValue;
247
248         }
249                 catch(ex) {            
250       success = (ex.name == "TypeError");
251                 }
252                 assertTrue("string_numberValue_TYPE_ERR",success);
253         }
254
255         {
256                 success = false;
257                 try {
258             nodeValue = outresult.singleNodeValue;
259
260         }
261                 catch(ex) {            
262       success = (ex.name == "TypeError");
263                 }
264                 assertTrue("string_singleNodeValue_TYPE_ERR",success);
265         }
266
267         {
268                 success = false;
269                 try {
270             intValue = outresult.snapshotLength;
271
272         }
273                 catch(ex) {            
274       success = (ex.name == "TypeError");
275                 }
276                 assertTrue("string_snapshotLength_TYPE_ERR",success);
277         }
278
279         {
280                 success = false;
281                 try {
282             nodeValue = outresult.iterateNext();
283         }
284                 catch(ex) {            
285       success = (ex.name == "TypeError");
286                 }
287                 assertTrue("string_iterateNext_TYPE_ERR",success);
288         }
289
290         {
291                 success = false;
292                 try {
293             nodeValue = outresult.snapshotItem(0);
294         }
295                 catch(ex) {            
296       success = (ex.name == "TypeError");
297                 }
298                 assertTrue("string_snapshotItem_TYPE_ERR",success);
299         }
300
301         }
302         
303         if(
304         (outNodeType == BOOLEAN_TYPE)
305         ) {
306         
307         {
308                 success = false;
309                 try {
310             doubleValue = outresult.numberValue;
311
312         }
313                 catch(ex) {            
314       success = (ex.name == "TypeError");
315                 }
316                 assertTrue("boolean_numberValue_TYPE_ERR",success);
317         }
318
319         {
320                 success = false;
321                 try {
322             nodeValue = outresult.singleNodeValue;
323
324         }
325                 catch(ex) {            
326       success = (ex.name == "TypeError");
327                 }
328                 assertTrue("boolean_singleNodeValue_TYPE_ERR",success);
329         }
330
331         {
332                 success = false;
333                 try {
334             intValue = outresult.snapshotLength;
335
336         }
337                 catch(ex) {            
338       success = (ex.name == "TypeError");
339                 }
340                 assertTrue("boolean_snapshotLength_TYPE_ERR",success);
341         }
342
343         {
344                 success = false;
345                 try {
346             stringValue = outresult.stringValue;
347
348         }
349                 catch(ex) {            
350       success = (ex.name == "TypeError");
351                 }
352                 assertTrue("boolean_stringValue_TYPE_ERR",success);
353         }
354
355         {
356                 success = false;
357                 try {
358             nodeValue = outresult.iterateNext();
359         }
360                 catch(ex) {            
361       success = (ex.name == "TypeError");
362                 }
363                 assertTrue("boolean_iterateNext_TYPE_ERR",success);
364         }
365
366         {
367                 success = false;
368                 try {
369             nodeValue = outresult.snapshotItem(0);
370         }
371                 catch(ex) {            
372       success = (ex.name == "TypeError");
373                 }
374                 assertTrue("boolean_snapshotItem_TYPE_ERR",success);
375         }
376
377         }
378         
379         if(
380         (outNodeType == UNORDERED_NODE_ITERATOR_TYPE)
381         ) {
382         
383         {
384                 success = false;
385                 try {
386             booleanValue = outresult.booleanValue;
387
388         }
389                 catch(ex) {            
390       success = (ex.name == "TypeError");
391                 }
392                 assertTrue("unordered_node_iterator_booleanValue_TYPE_ERR",success);
393         }
394
395         {
396                 success = false;
397                 try {
398             doubleValue = outresult.numberValue;
399
400         }
401                 catch(ex) {            
402       success = (ex.name == "TypeError");
403                 }
404                 assertTrue("unordered_node_iterator_numberValue_TYPE_ERR",success);
405         }
406
407         {
408                 success = false;
409                 try {
410             nodeValue = outresult.singleNodeValue;
411
412         }
413                 catch(ex) {            
414       success = (ex.name == "TypeError");
415                 }
416                 assertTrue("unordered_node_iterator_singleNodeValue_TYPE_ERR",success);
417         }
418
419         {
420                 success = false;
421                 try {
422             intValue = outresult.snapshotLength;
423
424         }
425                 catch(ex) {            
426       success = (ex.name == "TypeError");
427                 }
428                 assertTrue("unordered_node_iterator_snapshotLength_TYPE_ERR",success);
429         }
430
431         {
432                 success = false;
433                 try {
434             stringValue = outresult.stringValue;
435
436         }
437                 catch(ex) {            
438       success = (ex.name == "TypeError");
439                 }
440                 assertTrue("unordered_node_iterator_stringValue_TYPE_ERR",success);
441         }
442
443         {
444                 success = false;
445                 try {
446             nodeValue = outresult.snapshotItem(0);
447         }
448                 catch(ex) {            
449       success = (ex.name == "TypeError");
450                 }
451                 assertTrue("unordered_node_iterator_snapshotItem_TYPE_ERR",success);
452         }
453
454         }
455         
456         if(
457         (outNodeType == ORDERED_NODE_ITERATOR_TYPE)
458         ) {
459         
460         {
461                 success = false;
462                 try {
463             booleanValue = outresult.booleanValue;
464
465         }
466                 catch(ex) {            
467       success = (ex.name == "TypeError");
468                 }
469                 assertTrue("ordered_node_iterator_booleanValue_TYPE_ERR",success);
470         }
471
472         {
473                 success = false;
474                 try {
475             doubleValue = outresult.numberValue;
476
477         }
478                 catch(ex) {            
479       success = (ex.name == "TypeError");
480                 }
481                 assertTrue("ordered_node_iterator_numberValue_TYPE_ERR",success);
482         }
483
484         {
485                 success = false;
486                 try {
487             nodeValue = outresult.singleNodeValue;
488
489         }
490                 catch(ex) {            
491       success = (ex.name == "TypeError");
492                 }
493                 assertTrue("ordered_node_iterator_singleNodeValue_TYPE_ERR",success);
494         }
495
496         {
497                 success = false;
498                 try {
499             intValue = outresult.snapshotLength;
500
501         }
502                 catch(ex) {            
503       success = (ex.name == "TypeError");
504                 }
505                 assertTrue("ordered_node_iterator_snapshotLength_TYPE_ERR",success);
506         }
507
508         {
509                 success = false;
510                 try {
511             stringValue = outresult.stringValue;
512
513         }
514                 catch(ex) {            
515       success = (ex.name == "TypeError");
516                 }
517                 assertTrue("ordered_node_iterator_stringValue_TYPE_ERR",success);
518         }
519
520         {
521                 success = false;
522                 try {
523             nodeValue = outresult.snapshotItem(0);
524         }
525                 catch(ex) {            
526       success = (ex.name == "TypeError");
527                 }
528                 assertTrue("ordered_node_iterator_snapshotItem_TYPE_ERR",success);
529         }
530
531         }
532         
533         if(
534         (outNodeType == UNORDERED_NODE_SNAPSHOT_TYPE)
535         ) {
536         
537         {
538                 success = false;
539                 try {
540             booleanValue = outresult.booleanValue;
541
542         }
543                 catch(ex) {            
544       success = (ex.name == "TypeError");
545                 }
546                 assertTrue("unordered_node_snapshot_booleanValue_TYPE_ERR",success);
547         }
548
549         {
550                 success = false;
551                 try {
552             doubleValue = outresult.numberValue;
553
554         }
555                 catch(ex) {            
556       success = (ex.name == "TypeError");
557                 }
558                 assertTrue("unordered_node_snapshot_numberValue_TYPE_ERR",success);
559         }
560
561         {
562                 success = false;
563                 try {
564             nodeValue = outresult.singleNodeValue;
565
566         }
567                 catch(ex) {            
568       success = (ex.name == "TypeError");
569                 }
570                 assertTrue("unordered_node_snapshot_singleNodeValue_TYPE_ERR",success);
571         }
572
573         {
574                 success = false;
575                 try {
576             stringValue = outresult.stringValue;
577
578         }
579                 catch(ex) {            
580       success = (ex.name == "TypeError");
581                 }
582                 assertTrue("unordered_node_snapshot_stringValue_TYPE_ERR",success);
583         }
584
585         {
586                 success = false;
587                 try {
588             nodeValue = outresult.iterateNext();
589         }
590                 catch(ex) {            
591       success = (ex.name == "TypeError");
592                 }
593                 assertTrue("unordered_node_snapshot_iterateNext_TYPE_ERR",success);
594         }
595
596         }
597         
598         if(
599         (outNodeType == ORDERED_NODE_SNAPSHOT_TYPE)
600         ) {
601         
602         {
603                 success = false;
604                 try {
605             booleanValue = outresult.booleanValue;
606
607         }
608                 catch(ex) {            
609       success = (ex.name == "TypeError");
610                 }
611                 assertTrue("ordered_node_snapshot_booleanValue_TYPE_ERR",success);
612         }
613
614         {
615                 success = false;
616                 try {
617             doubleValue = outresult.numberValue;
618
619         }
620                 catch(ex) {            
621       success = (ex.name == "TypeError");
622                 }
623                 assertTrue("ordered_node_snapshot_numberValue_TYPE_ERR",success);
624         }
625
626         {
627                 success = false;
628                 try {
629             nodeValue = outresult.singleNodeValue;
630
631         }
632                 catch(ex) {            
633       success = (ex.name == "TypeError");
634                 }
635                 assertTrue("ordered_node_snapshot_singleNodeValue_TYPE_ERR",success);
636         }
637
638         {
639                 success = false;
640                 try {
641             stringValue = outresult.stringValue;
642
643         }
644                 catch(ex) {            
645       success = (ex.name == "TypeError");
646                 }
647                 assertTrue("ordered_node_snapshot_stringValue_TYPE_ERR",success);
648         }
649
650         {
651                 success = false;
652                 try {
653             nodeValue = outresult.iterateNext();
654         }
655                 catch(ex) {            
656       success = (ex.name == "TypeError");
657                 }
658                 assertTrue("ordered_node_snapshot_iterateNext_TYPE_ERR",success);
659         }
660
661         }
662         
663         if(
664         (outNodeType == ANY_UNORDERED_NODE_TYPE)
665         ) {
666         
667         {
668                 success = false;
669                 try {
670             booleanValue = outresult.booleanValue;
671
672         }
673                 catch(ex) {            
674       success = (ex.name == "TypeError");
675                 }
676                 assertTrue("any_unordered_node_booleanValue_TYPE_ERR",success);
677         }
678
679         {
680                 success = false;
681                 try {
682             doubleValue = outresult.numberValue;
683
684         }
685                 catch(ex) {            
686       success = (ex.name == "TypeError");
687                 }
688                 assertTrue("any_unordered_node_numberValue_TYPE_ERR",success);
689         }
690
691         {
692                 success = false;
693                 try {
694             intValue = outresult.snapshotLength;
695
696         }
697                 catch(ex) {            
698       success = (ex.name == "TypeError");
699                 }
700                 assertTrue("any_unordered_node_snapshotLength_TYPE_ERR",success);
701         }
702
703         {
704                 success = false;
705                 try {
706             stringValue = outresult.stringValue;
707
708         }
709                 catch(ex) {            
710       success = (ex.name == "TypeError");
711                 }
712                 assertTrue("any_unordered_node_stringValue_TYPE_ERR",success);
713         }
714
715         {
716                 success = false;
717                 try {
718             nodeValue = outresult.iterateNext();
719         }
720                 catch(ex) {            
721       success = (ex.name == "TypeError");
722                 }
723                 assertTrue("any_unordered_node_iterateNext_TYPE_ERR",success);
724         }
725
726         {
727                 success = false;
728                 try {
729             nodeValue = outresult.snapshotItem(0);
730         }
731                 catch(ex) {            
732       success = (ex.name == "TypeError");
733                 }
734                 assertTrue("any_unordered_node_snapshotItem_TYPE_ERR",success);
735         }
736
737         }
738         
739         if(
740         (outNodeType == FIRST_ORDERED_NODE_TYPE)
741         ) {
742         
743         {
744                 success = false;
745                 try {
746             booleanValue = outresult.booleanValue;
747
748         }
749                 catch(ex) {            
750       success = (ex.name == "TypeError");
751                 }
752                 assertTrue("first_ordered_node_booleanValue_TYPE_ERR",success);
753         }
754
755         {
756                 success = false;
757                 try {
758             doubleValue = outresult.numberValue;
759
760         }
761                 catch(ex) {            
762       success = (ex.name == "TypeError");
763                 }
764                 assertTrue("first_ordered_node_numberValue_TYPE_ERR",success);
765         }
766
767         {
768                 success = false;
769                 try {
770             intValue = outresult.snapshotLength;
771
772         }
773                 catch(ex) {            
774       success = (ex.name == "TypeError");
775                 }
776                 assertTrue("first_ordered_node_snapshotLength_TYPE_ERR",success);
777         }
778
779         {
780                 success = false;
781                 try {
782             stringValue = outresult.stringValue;
783
784         }
785                 catch(ex) {            
786       success = (ex.name == "TypeError");
787                 }
788                 assertTrue("first_ordered_node_stringValue_TYPE_ERR",success);
789         }
790
791         {
792                 success = false;
793                 try {
794             nodeValue = outresult.iterateNext();
795         }
796                 catch(ex) {            
797       success = (ex.name == "TypeError");
798                 }
799                 assertTrue("first_ordered_node_iterateNext_TYPE_ERR",success);
800         }
801
802         {
803                 success = false;
804                 try {
805             nodeValue = outresult.snapshotItem(0);
806         }
807                 catch(ex) {            
808       success = (ex.name == "TypeError");
809                 }
810                 assertTrue("first_ordered_node_snapshotItem_TYPE_ERR",success);
811         }
812
813         }
814         
815         }
816    
817 }
818
819
820
821
822 function runTest() {
823    XPathResult_TYPE_ERR();
824 }