Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 <title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodenormalize01</title>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/javascript" src="DOMTestCase.js"></script>
10 <script type="text/javascript" src="exclusions.js"></script>
11 <script type="text/javascript">
12 // expose test function names
13 function exposeTestFunctionNames()
14 {
15 return ['nodenormalize01'];
16 }
18 var docsLoaded = -1000000;
19 var builder = null;
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();
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 setUpPage = 'complete';
48 }
49 } catch(ex) {
50 catchInitializationError(builder, ex);
51 setUpPage = 'complete';
52 }
53 }
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 runJSUnitTests();
66 markTodos();
67 SimpleTest.finish();
68 }
69 }
71 var docName = 'nodenormalize01';
74 /**
75 *
76 The method "normalize" puts all Text nodes in the full depth of the sub-tree underneath
77 this Node, including attribute nodes, into a "normal" form where only structure
78 (e.g., elements, comments, processing instructions, CDATA sections, and entity references)
79 separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
81 Create a dom tree consisting of elements, comments, processing instructions, CDATA sections,
82 and entity references nodes seperated by text nodes. Check the length of the node list of each
83 before and after normalize has been called.
85 * @author IBM
86 * @author Neil Delima
87 * @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-normalize
88 */
89 function nodenormalize01() {
90 var success;
91 if(checkInitialization(builder, "nodenormalize01") != null) return;
92 var doc;
93 var newDoc;
94 var domImpl;
95 var docType;
96 var docTypeNull = null;
98 var documentElement;
99 var element1;
100 var element2;
101 var element3;
102 var element4;
103 var element5;
104 var element6;
105 var element7;
106 var text1;
107 var text2;
108 var text3;
109 var pi;
110 var cData;
111 var comment;
112 var entRef;
113 var elementList;
114 var appendedChild;
116 var docRef = null;
117 if (typeof(this.doc) != 'undefined') {
118 docRef = this.doc;
119 }
120 doc = load(docRef, "doc", "staffNS");
121 domImpl = doc.implementation;
122 newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test","dom:root",docTypeNull);
123 element1 = newDoc.createElement("element1");
124 element2 = newDoc.createElement("element2");
125 element3 = newDoc.createElement("element3");
126 element4 = newDoc.createElement("element4");
127 element5 = newDoc.createElement("element5");
128 element6 = newDoc.createElement("element6");
129 element7 = newDoc.createElement("element7");
130 text1 = newDoc.createTextNode("text1");
131 text2 = newDoc.createTextNode("text2");
132 text3 = newDoc.createTextNode("text3");
133 cData = newDoc.createCDATASection("Cdata");
134 comment = newDoc.createComment("comment");
135 pi = newDoc.createProcessingInstruction("PITarget","PIData");
136 entRef = newDoc.createEntityReference("EntRef");
137 assertNotNull("createdEntRefNotNull",entRef);
138 documentElement = newDoc.documentElement;
140 appendedChild = documentElement.appendChild(element1);
141 appendedChild = element2.appendChild(text1);
142 appendedChild = element2.appendChild(text2);
143 appendedChild = element2.appendChild(text3);
144 appendedChild = element1.appendChild(element2);
145 text1 = text1.cloneNode(false);
146 text2 = text2.cloneNode(false);
147 appendedChild = element3.appendChild(entRef);
148 appendedChild = element3.appendChild(text1);
149 appendedChild = element3.appendChild(text2);
150 appendedChild = element1.appendChild(element3);
151 text1 = text1.cloneNode(false);
152 text2 = text2.cloneNode(false);
153 appendedChild = element4.appendChild(cData);
154 appendedChild = element4.appendChild(text1);
155 appendedChild = element4.appendChild(text2);
156 appendedChild = element1.appendChild(element4);
157 text2 = text2.cloneNode(false);
158 text3 = text3.cloneNode(false);
159 appendedChild = element5.appendChild(comment);
160 appendedChild = element5.appendChild(text2);
161 appendedChild = element5.appendChild(text3);
162 appendedChild = element1.appendChild(element5);
163 text2 = text2.cloneNode(false);
164 text3 = text3.cloneNode(false);
165 appendedChild = element6.appendChild(pi);
166 appendedChild = element6.appendChild(text2);
167 appendedChild = element6.appendChild(text3);
168 appendedChild = element1.appendChild(element6);
169 entRef = entRef.cloneNode(false);
170 text1 = text1.cloneNode(false);
171 text2 = text2.cloneNode(false);
172 text3 = text3.cloneNode(false);
173 appendedChild = element7.appendChild(entRef);
174 appendedChild = element7.appendChild(text1);
175 appendedChild = element7.appendChild(text2);
176 appendedChild = element7.appendChild(text3);
177 appendedChild = element1.appendChild(element7);
178 elementList = element1.childNodes;
180 assertSize("nodeNormalize01_1Bef",6,elementList);
181 elementList = element2.childNodes;
183 assertSize("nodeNormalize01_2Bef",3,elementList);
184 elementList = element3.childNodes;
186 assertSize("nodeNormalize01_3Bef",3,elementList);
187 elementList = element4.childNodes;
189 assertSize("nodeNormalize01_4Bef",3,elementList);
190 elementList = element5.childNodes;
192 assertSize("nodeNormalize01_5Bef",3,elementList);
193 elementList = element6.childNodes;
195 assertSize("nodeNormalize01_6Bef",3,elementList);
196 elementList = element7.childNodes;
198 assertSize("nodeNormalize01_7Bef",4,elementList);
199 newDoc.normalize();
200 elementList = element1.childNodes;
202 assertSize("nodeNormalize01_1Aft",6,elementList);
203 elementList = element2.childNodes;
205 assertSize("nodeNormalize01_2Aft",1,elementList);
206 elementList = element3.childNodes;
208 assertSize("nodeNormalize01_3Aft",2,elementList);
209 elementList = element4.childNodes;
211 assertSize("nodeNormalize01_4Aft",2,elementList);
212 elementList = element5.childNodes;
214 assertSize("nodeNormalize01_5Aft",2,elementList);
215 elementList = element6.childNodes;
217 assertSize("nodeNormalize01_6Aft",2,elementList);
218 elementList = element7.childNodes;
220 assertSize("nodeNormalize01_7Aft",2,elementList);
222 }
224 </script>
225 </head>
226 <body>
227 <h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodenormalize01</h2>
228 <p></p>
229 <p>
230 Copyright (c) 2001-2004 World Wide Web Consortium,
231 (Massachusetts Institute of Technology, European Research Consortium
232 for Informatics and Mathematics, Keio University). All
233 Rights Reserved. This work is distributed under the <a href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">W3C(r) Software License</a> in the
234 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
235 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
236 </p>
237 </body>
238 </html>