Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: third_party/WebKit/LayoutTests/dom/svg/level3/xpath/Text_Nodes.js

Issue 2670783003: Move DOM conformance tests to dom/legacy_dom_conformance/, part 3/N. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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] i n 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.
8
9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
10 */
11
12 // expose test function names
13 function exposeTestFunctionNames()
14 {
15 return ['Text_Nodes'];
16 }
17
18 var docsLoaded = -1000000;
19 var builder = null;
20
21 //
22 // This function is called by the testing framework before
23 // running the test suite.
24 //
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.
29 //
30 function setUpPage() {
31 setUpPageStatus = 'running';
32 try {
33 //
34 // creates test document builder, may throw exception
35 //
36 builder = createConfiguredBuilder();
37
38 docsLoaded = 0;
39
40 var docRef = null;
41 if (typeof(this.doc) != 'undefined') {
42 docRef = this.doc;
43 }
44 docsLoaded += preload(docRef, "doc", "staff");
45
46 if (docsLoaded == 1) {
47 setUpPageStatus = 'complete';
48 }
49 } catch(ex) {
50 catchInitializationError(builder, ex);
51 setUpPageStatus = 'complete';
52 }
53 }
54
55 //
56 // This method is called on the completion of
57 // each asychronous load started in setUpTests.
58 //
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 }
66 }
67
68 /**
69 *
70 1.2.4 Text Nodes -
71 Create ANY_TYPE XPathResult matching //text(),
72 check that each matching Node is a Text Node, and
73 that no pair of nodes in the result are siblings.
74
75 * @author Bob Clary
76 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#Mapping
77 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua tor
78 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua tor-createNSResolver
79 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvalua tor-evaluate
80 * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSReso lver
81 * @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 -iterateNext
83 */
84 function Text_Nodes() {
85 var success;
86 if(checkInitialization(builder, "Text_Nodes") != null) return;
87 var ANY_TYPE = 0;
88 var NUMBER_TYPE = 1;
89 var STRING_TYPE = 2;
90 var BOOLEAN_TYPE = 3;
91 var UNORDERED_NODE_ITERATOR_TYPE = 4;
92 var ORDERED_NODE_ITERATOR_TYPE = 5;
93 var UNORDERED_NODE_SNAPSHOT_TYPE = 6;
94 var ORDERED_NODE_SNAPSHOT_TYPE = 7;
95 var ANY_UNORDERED_NODE_TYPE = 8;
96 var FIRST_ORDERED_NODE_TYPE = 9;
97 var doc;
98 var resolver;
99 var evaluator;
100 var contextNode;
101 var inresult = null;
102
103 var outresult = null;
104
105 var expression = "//text()";
106 var xpathType = ANY_TYPE;
107 var currNode;
108 var nextNode;
109 var currNodeNextSibling;
110 var nextNodePrevSibling;
111 var nodeType;
112 var isTextNode;
113
114 var docRef = null;
115 if (typeof(this.doc) != 'undefined') {
116 docRef = this.doc;
117 }
118 doc = load(docRef, "doc", "staff");
119 evaluator = createXPathEvaluator(doc);
120 resolver = evaluator.createNSResolver(doc);
121 contextNode = doc;
122 outresult = evaluator.evaluate(expression,contextNode,resolver,xpathType,inresul t);
123 currNode = outresult.iterateNext();
124
125 while(
126
127 (currNode != null)
128
129 ) {
130 nodeType = currNode.nodeType;
131
132 isTextNode = "true";
133
134 if(
135
136 (!(3 == nodeType) && !(4 == nodeType))
137
138 ) {
139 isTextNode = "false";
140
141 }
142 assertEquals("S1.2.4-Text-Nodes-nodeType","true".toLowerCase(),isTextNode.to LowerCase());
143 nextNode = outresult.iterateNext();
144
145 if(
146
147 (nextNode != null)
148
149 ) {
150 currNodeNextSibling = currNode.nextSibling;
151
152 // WebKit fix: inverted the condition: <http://bugs.webkit.org/show_bug.cgi? id=12560>.
153 if(
154
155 same(nextNode,currNodeNextSibling)
156
157 ) {
158 assertTrue("S1.2.4-Text-Nodes-Adjacent-Next",false);
159
160 }
161 nextNodePrevSibling = nextNode.previousSibling;
162
163 // WebKit fix: inverted the condition: <http://bugs.webkit.org/show_bug.cgi? id=12560>.
164 if(
165
166 same(nextNodePrevSibling,currNode)
167
168 ) {
169 assertTrue("S1.2.4-Text-Nodes-Adjacent-Prev",false);
170
171 }
172
173 }
174 currNode = nextNode;
175
176 }
177
178 }
179
180 function runTest() {
181 Text_Nodes();
182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698