1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/dom-level2-core/test_nodenormalize01.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,238 @@ 1.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> 1.5 +<html> 1.6 +<head> 1.7 +<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> 1.8 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 1.9 +<title>http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodenormalize01</title> 1.10 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> 1.11 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 +<script type="text/javascript" src="DOMTestCase.js"></script> 1.13 +<script type="text/javascript" src="exclusions.js"></script> 1.14 +<script type="text/javascript"> 1.15 +// expose test function names 1.16 +function exposeTestFunctionNames() 1.17 +{ 1.18 +return ['nodenormalize01']; 1.19 +} 1.20 + 1.21 +var docsLoaded = -1000000; 1.22 +var builder = null; 1.23 + 1.24 +// 1.25 +// This function is called by the testing framework before 1.26 +// running the test suite. 1.27 +// 1.28 +// If there are no configuration exceptions, asynchronous 1.29 +// document loading is started. Otherwise, the status 1.30 +// is set to complete and the exception is immediately 1.31 +// raised when entering the body of the test. 1.32 +// 1.33 +function setUpPage() { 1.34 + setUpPageStatus = 'running'; 1.35 + try { 1.36 + // 1.37 + // creates test document builder, may throw exception 1.38 + // 1.39 + builder = createConfiguredBuilder(); 1.40 + 1.41 + docsLoaded = 0; 1.42 + 1.43 + var docRef = null; 1.44 + if (typeof(this.doc) != 'undefined') { 1.45 + docRef = this.doc; 1.46 + } 1.47 + docsLoaded += preload(docRef, "doc", "staffNS"); 1.48 + 1.49 + if (docsLoaded == 1) { 1.50 + setUpPage = 'complete'; 1.51 + } 1.52 + } catch(ex) { 1.53 + catchInitializationError(builder, ex); 1.54 + setUpPage = 'complete'; 1.55 + } 1.56 +} 1.57 + 1.58 +// 1.59 +// This method is called on the completion of 1.60 +// each asychronous load started in setUpTests. 1.61 +// 1.62 +// When every synchronous loaded document has completed, 1.63 +// the page status is changed which allows the 1.64 +// body of the test to be executed. 1.65 +function loadComplete() { 1.66 + if (++docsLoaded == 1) { 1.67 + setUpPageStatus = 'complete'; 1.68 + runJSUnitTests(); 1.69 + markTodos(); 1.70 + SimpleTest.finish(); 1.71 + } 1.72 +} 1.73 + 1.74 +var docName = 'nodenormalize01'; 1.75 + 1.76 + 1.77 +/** 1.78 +* 1.79 + The method "normalize" puts all Text nodes in the full depth of the sub-tree underneath 1.80 + this Node, including attribute nodes, into a "normal" form where only structure 1.81 + (e.g., elements, comments, processing instructions, CDATA sections, and entity references) 1.82 + separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. 1.83 + 1.84 + Create a dom tree consisting of elements, comments, processing instructions, CDATA sections, 1.85 + and entity references nodes seperated by text nodes. Check the length of the node list of each 1.86 + before and after normalize has been called. 1.87 + 1.88 +* @author IBM 1.89 +* @author Neil Delima 1.90 +* @see http://www.w3.org/TR/DOM-Level-2-Core/core#ID-normalize 1.91 +*/ 1.92 +function nodenormalize01() { 1.93 + var success; 1.94 + if(checkInitialization(builder, "nodenormalize01") != null) return; 1.95 + var doc; 1.96 + var newDoc; 1.97 + var domImpl; 1.98 + var docType; 1.99 + var docTypeNull = null; 1.100 + 1.101 + var documentElement; 1.102 + var element1; 1.103 + var element2; 1.104 + var element3; 1.105 + var element4; 1.106 + var element5; 1.107 + var element6; 1.108 + var element7; 1.109 + var text1; 1.110 + var text2; 1.111 + var text3; 1.112 + var pi; 1.113 + var cData; 1.114 + var comment; 1.115 + var entRef; 1.116 + var elementList; 1.117 + var appendedChild; 1.118 + 1.119 + var docRef = null; 1.120 + if (typeof(this.doc) != 'undefined') { 1.121 + docRef = this.doc; 1.122 + } 1.123 + doc = load(docRef, "doc", "staffNS"); 1.124 + domImpl = doc.implementation; 1.125 +newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test","dom:root",docTypeNull); 1.126 + element1 = newDoc.createElement("element1"); 1.127 + element2 = newDoc.createElement("element2"); 1.128 + element3 = newDoc.createElement("element3"); 1.129 + element4 = newDoc.createElement("element4"); 1.130 + element5 = newDoc.createElement("element5"); 1.131 + element6 = newDoc.createElement("element6"); 1.132 + element7 = newDoc.createElement("element7"); 1.133 + text1 = newDoc.createTextNode("text1"); 1.134 + text2 = newDoc.createTextNode("text2"); 1.135 + text3 = newDoc.createTextNode("text3"); 1.136 + cData = newDoc.createCDATASection("Cdata"); 1.137 + comment = newDoc.createComment("comment"); 1.138 + pi = newDoc.createProcessingInstruction("PITarget","PIData"); 1.139 + entRef = newDoc.createEntityReference("EntRef"); 1.140 + assertNotNull("createdEntRefNotNull",entRef); 1.141 +documentElement = newDoc.documentElement; 1.142 + 1.143 + appendedChild = documentElement.appendChild(element1); 1.144 + appendedChild = element2.appendChild(text1); 1.145 + appendedChild = element2.appendChild(text2); 1.146 + appendedChild = element2.appendChild(text3); 1.147 + appendedChild = element1.appendChild(element2); 1.148 + text1 = text1.cloneNode(false); 1.149 + text2 = text2.cloneNode(false); 1.150 + appendedChild = element3.appendChild(entRef); 1.151 + appendedChild = element3.appendChild(text1); 1.152 + appendedChild = element3.appendChild(text2); 1.153 + appendedChild = element1.appendChild(element3); 1.154 + text1 = text1.cloneNode(false); 1.155 + text2 = text2.cloneNode(false); 1.156 + appendedChild = element4.appendChild(cData); 1.157 + appendedChild = element4.appendChild(text1); 1.158 + appendedChild = element4.appendChild(text2); 1.159 + appendedChild = element1.appendChild(element4); 1.160 + text2 = text2.cloneNode(false); 1.161 + text3 = text3.cloneNode(false); 1.162 + appendedChild = element5.appendChild(comment); 1.163 + appendedChild = element5.appendChild(text2); 1.164 + appendedChild = element5.appendChild(text3); 1.165 + appendedChild = element1.appendChild(element5); 1.166 + text2 = text2.cloneNode(false); 1.167 + text3 = text3.cloneNode(false); 1.168 + appendedChild = element6.appendChild(pi); 1.169 + appendedChild = element6.appendChild(text2); 1.170 + appendedChild = element6.appendChild(text3); 1.171 + appendedChild = element1.appendChild(element6); 1.172 + entRef = entRef.cloneNode(false); 1.173 + text1 = text1.cloneNode(false); 1.174 + text2 = text2.cloneNode(false); 1.175 + text3 = text3.cloneNode(false); 1.176 + appendedChild = element7.appendChild(entRef); 1.177 + appendedChild = element7.appendChild(text1); 1.178 + appendedChild = element7.appendChild(text2); 1.179 + appendedChild = element7.appendChild(text3); 1.180 + appendedChild = element1.appendChild(element7); 1.181 + elementList = element1.childNodes; 1.182 + 1.183 + assertSize("nodeNormalize01_1Bef",6,elementList); 1.184 +elementList = element2.childNodes; 1.185 + 1.186 + assertSize("nodeNormalize01_2Bef",3,elementList); 1.187 +elementList = element3.childNodes; 1.188 + 1.189 + assertSize("nodeNormalize01_3Bef",3,elementList); 1.190 +elementList = element4.childNodes; 1.191 + 1.192 + assertSize("nodeNormalize01_4Bef",3,elementList); 1.193 +elementList = element5.childNodes; 1.194 + 1.195 + assertSize("nodeNormalize01_5Bef",3,elementList); 1.196 +elementList = element6.childNodes; 1.197 + 1.198 + assertSize("nodeNormalize01_6Bef",3,elementList); 1.199 +elementList = element7.childNodes; 1.200 + 1.201 + assertSize("nodeNormalize01_7Bef",4,elementList); 1.202 +newDoc.normalize(); 1.203 + elementList = element1.childNodes; 1.204 + 1.205 + assertSize("nodeNormalize01_1Aft",6,elementList); 1.206 +elementList = element2.childNodes; 1.207 + 1.208 + assertSize("nodeNormalize01_2Aft",1,elementList); 1.209 +elementList = element3.childNodes; 1.210 + 1.211 + assertSize("nodeNormalize01_3Aft",2,elementList); 1.212 +elementList = element4.childNodes; 1.213 + 1.214 + assertSize("nodeNormalize01_4Aft",2,elementList); 1.215 +elementList = element5.childNodes; 1.216 + 1.217 + assertSize("nodeNormalize01_5Aft",2,elementList); 1.218 +elementList = element6.childNodes; 1.219 + 1.220 + assertSize("nodeNormalize01_6Aft",2,elementList); 1.221 +elementList = element7.childNodes; 1.222 + 1.223 + assertSize("nodeNormalize01_7Aft",2,elementList); 1.224 + 1.225 +} 1.226 + 1.227 +</script> 1.228 +</head> 1.229 +<body> 1.230 +<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodenormalize01</h2> 1.231 +<p></p> 1.232 +<p> 1.233 +Copyright (c) 2001-2004 World Wide Web Consortium, 1.234 +(Massachusetts Institute of Technology, European Research Consortium 1.235 +for Informatics and Mathematics, Keio University). All 1.236 +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 1.237 +hope that it will be useful, but WITHOUT ANY WARRANTY; without even 1.238 +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1.239 +</p> 1.240 +</body> 1.241 +</html>