OLD | NEW |
1 | |
2 /* | 1 /* |
3 Copyright © 2001-2004 World Wide Web Consortium, | 2 Copyright © 2001-2004 World Wide Web Consortium, |
4 (Massachusetts Institute of Technology, European Research Consortium | 3 (Massachusetts Institute of Technology, European Research Consortium |
5 for Informatics and Mathematics, Keio University). All | 4 for Informatics and Mathematics, Keio University). All |
6 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the | 5 Rights Reserved. This work is distributed under the W3C® Software License [1] i
n the |
7 hope that it will be useful, but WITHOUT ANY WARRANTY; without even | 6 hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
8 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
9 | 8 |
10 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 | 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 |
11 */ | 10 */ |
12 | 11 |
13 | |
14 // expose test function names | 12 // expose test function names |
15 function exposeTestFunctionNames() | 13 function exposeTestFunctionNames() |
16 { | 14 { |
17 return ['XPathResult_iteratorNext_UNORDERED_NODE_ITERATOR_TYPE']; | 15 return ['XPathResult_iteratorNext_UNORDERED_NODE_ITERATOR_TYPE']; |
18 } | 16 } |
19 | 17 |
20 var docsLoaded = -1000000; | 18 var docsLoaded = -1000000; |
21 var builder = null; | 19 var builder = null; |
22 | 20 |
23 // | 21 // |
24 // This function is called by the testing framework before | 22 // This function is called by the testing framework before |
25 // running the test suite. | 23 // running the test suite. |
26 // | 24 // |
27 // If there are no configuration exceptions, asynchronous | 25 // If there are no configuration exceptions, asynchronous |
28 // document loading is started. Otherwise, the status | 26 // document loading is started. Otherwise, the status |
29 // is set to complete and the exception is immediately | 27 // is set to complete and the exception is immediately |
30 // raised when entering the body of the test. | 28 // raised when entering the body of the test. |
31 // | 29 // |
32 function setUpPage() { | 30 function setUpPage() { |
33 setUpPageStatus = 'running'; | 31 setUpPageStatus = 'running'; |
34 try { | 32 try { |
35 // | 33 // |
36 // creates test document builder, may throw exception | 34 // creates test document builder, may throw exception |
37 // | 35 // |
38 builder = createConfiguredBuilder(); | 36 builder = createConfiguredBuilder(); |
39 | 37 |
40 docsLoaded = 0; | 38 docsLoaded = 0; |
41 | 39 |
42 var docRef = null; | 40 var docRef = null; |
43 if (typeof(this.doc) != 'undefined') { | 41 if (typeof(this.doc) != 'undefined') { |
44 docRef = this.doc; | 42 docRef = this.doc; |
45 } | 43 } |
46 docsLoaded += preload(docRef, "doc", "staff"); | 44 docsLoaded += preload(docRef, "doc", "staff"); |
47 | 45 |
48 if (docsLoaded == 1) { | 46 if (docsLoaded == 1) { |
49 setUpPageStatus = 'complete'; | 47 setUpPageStatus = 'complete'; |
50 } | 48 } |
51 } catch(ex) { | 49 } catch(ex) { |
52 » catchInitializationError(builder, ex); | 50 catchInitializationError(builder, ex); |
53 setUpPageStatus = 'complete'; | 51 setUpPageStatus = 'complete'; |
54 } | 52 } |
55 } | 53 } |
56 | 54 |
57 | |
58 | |
59 // | 55 // |
60 // This method is called on the completion of | 56 // This method is called on the completion of |
61 // each asychronous load started in setUpTests. | 57 // each asychronous load started in setUpTests. |
62 // | 58 // |
63 // When every synchronous loaded document has completed, | 59 // When every synchronous loaded document has completed, |
64 // the page status is changed which allows the | 60 // the page status is changed which allows the |
65 // body of the test to be executed. | 61 // body of the test to be executed. |
66 function loadComplete() { | 62 function loadComplete() { |
67 if (++docsLoaded == 1) { | 63 if (++docsLoaded == 1) { |
68 setUpPageStatus = 'complete'; | 64 setUpPageStatus = 'complete'; |
69 } | 65 } |
70 } | 66 } |
71 | 67 |
72 | |
73 /** | 68 /** |
74 * | 69 * |
75 Create an XPathResult UNORDERED_NODE_ITERATOR_TYPE XPathResultType for | 70 Create an XPathResult UNORDERED_NODE_ITERATOR_TYPE XPathResultType for |
76 expression /staff/employee/employeeId/text() checking that: | 71 expression /staff/employee/employeeId/text() checking that: |
77 XPathResult.iteratorNext contains the correct number of nodes. | 72 XPathResult.iteratorNext contains the correct number of nodes. |
78 | 73 |
79 * @author Bob Clary | 74 * @author Bob Clary |
80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
-iteratorNext | 75 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
-iteratorNext |
81 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult | 76 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult |
82 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
Type | 77 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathResult
Type |
83 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor-createNSResolver | 78 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua
tor-createNSResolver |
84 */ | 79 */ |
85 function XPathResult_iteratorNext_UNORDERED_NODE_ITERATOR_TYPE() { | 80 function XPathResult_iteratorNext_UNORDERED_NODE_ITERATOR_TYPE() { |
86 var success; | 81 var success; |
87 if(checkInitialization(builder, "XPathResult_iteratorNext_UNORDERED_NODE_ITE
RATOR_TYPE") != null) return; | 82 if(checkInitialization(builder, "XPathResult_iteratorNext_UNORDERED_NODE_ITE
RATOR_TYPE") != null) return; |
88 var ANY_TYPE = 0; | 83 var ANY_TYPE = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
104 var outresult = null; | 99 var outresult = null; |
105 | 100 |
106 var expression = "/staff/employee/employeeId/text()"; | 101 var expression = "/staff/employee/employeeId/text()"; |
107 var xpathType = UNORDERED_NODE_ITERATOR_TYPE; | 102 var xpathType = UNORDERED_NODE_ITERATOR_TYPE; |
108 var outNode; | 103 var outNode; |
109 var nodeType; | 104 var nodeType; |
110 var parent; | 105 var parent; |
111 var owner; | 106 var owner; |
112 var ownerType; | 107 var ownerType; |
113 var index; | 108 var index; |
114 | 109 |
115 var docRef = null; | 110 var docRef = null; |
116 if (typeof(this.doc) != 'undefined') { | 111 if (typeof(this.doc) != 'undefined') { |
117 docRef = this.doc; | 112 docRef = this.doc; |
118 } | 113 } |
119 doc = load(docRef, "doc", "staff"); | 114 doc = load(docRef, "doc", "staff"); |
120 evaluator = createXPathEvaluator(doc); | 115 evaluator = createXPathEvaluator(doc); |
121 resolver = evaluator.createNSResolver(doc); | 116 resolver = evaluator.createNSResolver(doc); |
122 contextNode = doc; | 117 contextNode = doc; |
123 outresult = evaluator.evaluate(expression,contextNode,resolver,xpathType,inresul
t); | 118 outresult = evaluator.evaluate(expression,contextNode,resolver,xpathType,inresul
t); |
124 index = 0; | 119 index = 0; |
125 outNode = outresult.iterateNext(); | 120 outNode = outresult.iterateNext(); |
126 | 121 |
127 while( | 122 while( |
128 | |
129 (outNode != null) | |
130 | 123 |
131 » ) { | 124 (outNode != null) |
132 » index += 1; | 125 |
| 126 ) { |
| 127 index += 1; |
133 outNode = outresult.iterateNext(); | 128 outNode = outresult.iterateNext(); |
134 | 129 |
135 » } | 130 } |
136 assertEquals("count",4,index); | 131 assertEquals("count",4,index); |
137 | 132 |
138 } | 133 } |
139 | 134 |
140 | |
141 | |
142 | |
143 function runTest() { | 135 function runTest() { |
144 XPathResult_iteratorNext_UNORDERED_NODE_ITERATOR_TYPE(); | 136 XPathResult_iteratorNext_UNORDERED_NODE_ITERATOR_TYPE(); |
145 } | 137 } |
OLD | NEW |