| OLD | NEW |
| (Empty) |
| 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] i
n 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 | |
| 15 /** | |
| 16 * Gets URI that identifies the test. | |
| 17 * @return uri identifier of test | |
| 18 */ | |
| 19 function getTargetURI() { | |
| 20 return "http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormaliz
edocument07"; | |
| 21 } | |
| 22 | |
| 23 var docsLoaded = -1000000; | |
| 24 var builder = null; | |
| 25 | |
| 26 // | |
| 27 // This function is called by the testing framework before | |
| 28 // running the test suite. | |
| 29 // | |
| 30 // If there are no configuration exceptions, asynchronous | |
| 31 // document loading is started. Otherwise, the status | |
| 32 // is set to complete and the exception is immediately | |
| 33 // raised when entering the body of the test. | |
| 34 // | |
| 35 function setUpPage() { | |
| 36 setUpPageStatus = 'running'; | |
| 37 try { | |
| 38 // | |
| 39 // creates test document builder, may throw exception | |
| 40 // | |
| 41 builder = createConfiguredBuilder(); | |
| 42 | |
| 43 docsLoaded = 0; | |
| 44 | |
| 45 var docRef = null; | |
| 46 if (typeof(this.doc) != 'undefined') { | |
| 47 docRef = this.doc; | |
| 48 } | |
| 49 docsLoaded += preload(docRef, "doc", "barfoo"); | |
| 50 | |
| 51 if (docsLoaded == 1) { | |
| 52 setUpPageStatus = 'complete'; | |
| 53 } | |
| 54 } catch(ex) { | |
| 55 catchInitializationError(builder, ex); | |
| 56 setUpPageStatus = 'complete'; | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 | |
| 61 | |
| 62 // | |
| 63 // This method is called on the completion of | |
| 64 // each asychronous load started in setUpTests. | |
| 65 // | |
| 66 // When every synchronous loaded document has completed, | |
| 67 // the page status is changed which allows the | |
| 68 // body of the test to be executed. | |
| 69 function loadComplete() { | |
| 70 if (++docsLoaded == 1) { | |
| 71 setUpPageStatus = 'complete'; | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 //DOMErrorMonitor's require a document level variable named errorMonitor | |
| 76 var errorMonitor; | |
| 77 | |
| 78 /** | |
| 79 * | |
| 80 Add a CDATASection containing "]]>" and perform normalization with split-cdata-s
ections=false. Should result | |
| 81 in an error. | |
| 82 | |
| 83 * @author Curt Arnold | |
| 84 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#Document3-no
rmalizeDocument | |
| 85 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#parameter-sp
lit-cdata-sections | |
| 86 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-severity | |
| 87 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-message | |
| 88 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-type | |
| 89 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-relatedException | |
| 90 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-relatedData | |
| 91 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-location | |
| 92 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#DOMLocator-l
ine-number | |
| 93 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#DOMLocator-c
olumn-number | |
| 94 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#DOMLocator-b
yteOffset | |
| 95 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#DOMLocator-u
tf16Offset | |
| 96 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#DOMLocator-n
ode | |
| 97 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#DOMLocator-u
ri | |
| 98 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=542 | |
| 99 */ | |
| 100 function documentnormalizedocument07() { | |
| 101 var success; | |
| 102 if(checkInitialization(builder, "documentnormalizedocument07") != null) retu
rn; | |
| 103 var doc; | |
| 104 var elem; | |
| 105 var domConfig; | |
| 106 var elemList; | |
| 107 var newChild; | |
| 108 var oldChild; | |
| 109 var retval; | |
| 110 errorMonitor = new DOMErrorMonitor(); | |
| 111 | |
| 112 var errors = new Array(); | |
| 113 | |
| 114 var error; | |
| 115 var errorCount = 0; | |
| 116 var severity; | |
| 117 var problemNode; | |
| 118 var location; | |
| 119 var lineNumber; | |
| 120 var columnNumber; | |
| 121 var byteOffset; | |
| 122 var utf16Offset; | |
| 123 var uri; | |
| 124 var type; | |
| 125 var message; | |
| 126 var relatedException; | |
| 127 var relatedData; | |
| 128 var length; | |
| 129 | |
| 130 var docRef = null; | |
| 131 if (typeof(this.doc) != 'undefined') { | |
| 132 docRef = this.doc; | |
| 133 } | |
| 134 doc = load(docRef, "doc", "barfoo"); | |
| 135 elemList = doc.getElementsByTagName("p"); | |
| 136 elem = elemList.item(0); | |
| 137 oldChild = elem.firstChild; | |
| 138 | |
| 139 newChild = doc.createCDATASection("this is not ]]> good"); | |
| 140 retval = elem.replaceChild(newChild,oldChild); | |
| 141 domConfig = doc.domConfig; | |
| 142 | |
| 143 domConfig.setParameter("split-cdata-sections", false); | |
| 144 domConfig.setParameter("error-handler", errorMonitor.handleError); | |
| 145 doc.normalizeDocument(); | |
| 146 errors = errorMonitor.allErrors; | |
| 147 for(var indexN100E0 = 0;indexN100E0 < errors.length; indexN100E0++) { | |
| 148 error = errors[indexN100E0]; | |
| 149 severity = error.severity; | |
| 150 | |
| 151 | |
| 152 if( | |
| 153 (2 == severity) | |
| 154 ) { | |
| 155 location = error.location; | |
| 156 | |
| 157 problemNode = location.relatedNode; | |
| 158 | |
| 159 assertSame("relatedNode",newChild,problemNode); | |
| 160 lineNumber = location.lineNumber; | |
| 161 | |
| 162 columnNumber = location.columnNumber; | |
| 163 | |
| 164 byteOffset = location.byteOffset; | |
| 165 | |
| 166 utf16Offset = location.utf16Offset; | |
| 167 | |
| 168 uri = location.uri; | |
| 169 | |
| 170 message = error.message; | |
| 171 | |
| 172 length = message.length; | |
| 173 assertTrue("messageNotEmpty", | |
| 174 | |
| 175 (length > 0) | |
| 176 ); | |
| 177 type = error.type; | |
| 178 | |
| 179 relatedData = error.relatedData; | |
| 180 | |
| 181 relatedException = error.relatedException; | |
| 182 | |
| 183 errorCount += 1; | |
| 184 | |
| 185 } | |
| 186 | |
| 187 else { | |
| 188 assertEquals("anyOthersShouldBeWarnings",1,severity); | |
| 189 | |
| 190 } | |
| 191 | |
| 192 } | |
| 193 assertEquals("oneError",1,errorCount); | |
| 194 | |
| 195 } | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 function runTest() { | |
| 201 documentnormalizedocument07(); | |
| 202 } | |
| OLD | NEW |