| 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 | |
| 15 /** | 12 /** |
| 16 * Gets URI that identifies the test. | 13 * Gets URI that identifies the test. |
| 17 * @return uri identifier of test | 14 * @return uri identifier of test |
| 18 */ | 15 */ |
| 19 function getTargetURI() { | 16 function getTargetURI() { |
| 20 return "http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormaliz
edocument06"; | 17 return "http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentnormaliz
edocument06"; |
| 21 } | 18 } |
| 22 | 19 |
| 23 var docsLoaded = -1000000; | 20 var docsLoaded = -1000000; |
| 24 var builder = null; | 21 var builder = null; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 function setUpPage() { | 32 function setUpPage() { |
| 36 setUpPageStatus = 'running'; | 33 setUpPageStatus = 'running'; |
| 37 try { | 34 try { |
| 38 // | 35 // |
| 39 // creates test document builder, may throw exception | 36 // creates test document builder, may throw exception |
| 40 // | 37 // |
| 41 builder = createConfiguredBuilder(); | 38 builder = createConfiguredBuilder(); |
| 42 setImplementationAttribute("namespaceAware", true); | 39 setImplementationAttribute("namespaceAware", true); |
| 43 | 40 |
| 44 docsLoaded = 0; | 41 docsLoaded = 0; |
| 45 | 42 |
| 46 var docRef = null; | 43 var docRef = null; |
| 47 if (typeof(this.doc) != 'undefined') { | 44 if (typeof(this.doc) != 'undefined') { |
| 48 docRef = this.doc; | 45 docRef = this.doc; |
| 49 } | 46 } |
| 50 docsLoaded += preload(docRef, "doc", "barfoo"); | 47 docsLoaded += preload(docRef, "doc", "barfoo"); |
| 51 | 48 |
| 52 if (docsLoaded == 1) { | 49 if (docsLoaded == 1) { |
| 53 setUpPageStatus = 'complete'; | 50 setUpPageStatus = 'complete'; |
| 54 } | 51 } |
| 55 } catch(ex) { | 52 } catch(ex) { |
| 56 » catchInitializationError(builder, ex); | 53 catchInitializationError(builder, ex); |
| 57 setUpPageStatus = 'complete'; | 54 setUpPageStatus = 'complete'; |
| 58 } | 55 } |
| 59 } | 56 } |
| 60 | 57 |
| 61 | |
| 62 | |
| 63 // | 58 // |
| 64 // This method is called on the completion of | 59 // This method is called on the completion of |
| 65 // each asychronous load started in setUpTests. | 60 // each asychronous load started in setUpTests. |
| 66 // | 61 // |
| 67 // When every synchronous loaded document has completed, | 62 // When every synchronous loaded document has completed, |
| 68 // the page status is changed which allows the | 63 // the page status is changed which allows the |
| 69 // body of the test to be executed. | 64 // body of the test to be executed. |
| 70 function loadComplete() { | 65 function loadComplete() { |
| 71 if (++docsLoaded == 1) { | 66 if (++docsLoaded == 1) { |
| 72 setUpPageStatus = 'complete'; | 67 setUpPageStatus = 'complete'; |
| 73 } | 68 } |
| 74 } | 69 } |
| 75 | 70 |
| 76 //DOMErrorMonitor's require a document level variable named errorMonitor | 71 //DOMErrorMonitor's require a document level variable named errorMonitor |
| 77 var errorMonitor; | 72 var errorMonitor; |
| 78 » | 73 |
| 79 /** | 74 /** |
| 80 * | 75 * |
| 81 Add a CDATASection containing "]]>" perform normalization with split-cdata-secti
ons=true. Should result | 76 Add a CDATASection containing "]]>" perform normalization with split-cdata-secti
ons=true. Should result |
| 82 in an warning. | 77 in an warning. |
| 83 | 78 |
| 84 * @author Curt Arnold | 79 * @author Curt Arnold |
| 85 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#Document3-no
rmalizeDocument | 80 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#Document3-no
rmalizeDocument |
| 86 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#parameter-sp
lit-cdata-sections | 81 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#parameter-sp
lit-cdata-sections |
| 87 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-severity | 82 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-severity |
| 88 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-message | 83 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-message |
| 89 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-type | 84 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-type |
| 90 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-relatedException | 85 * @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ERROR-DOMErr
or-relatedException |
| (...skipping 11 matching lines...) Expand all Loading... |
| 102 var success; | 97 var success; |
| 103 if(checkInitialization(builder, "documentnormalizedocument06") != null) retu
rn; | 98 if(checkInitialization(builder, "documentnormalizedocument06") != null) retu
rn; |
| 104 var doc; | 99 var doc; |
| 105 var elem; | 100 var elem; |
| 106 var domConfig; | 101 var domConfig; |
| 107 var elemList; | 102 var elemList; |
| 108 var newChild; | 103 var newChild; |
| 109 var oldChild; | 104 var oldChild; |
| 110 var retval; | 105 var retval; |
| 111 errorMonitor = new DOMErrorMonitor(); | 106 errorMonitor = new DOMErrorMonitor(); |
| 112 | 107 |
| 113 var errors = new Array(); | 108 var errors = new Array(); |
| 114 | 109 |
| 115 var error; | 110 var error; |
| 116 var splittedCount = 0; | 111 var splittedCount = 0; |
| 117 var severity; | 112 var severity; |
| 118 var problemNode; | 113 var problemNode; |
| 119 var location; | 114 var location; |
| 120 var lineNumber; | 115 var lineNumber; |
| 121 var columnNumber; | 116 var columnNumber; |
| 122 var byteOffset; | 117 var byteOffset; |
| 123 var utf16Offset; | 118 var utf16Offset; |
| 124 var uri; | 119 var uri; |
| 125 var type; | 120 var type; |
| 126 var message; | 121 var message; |
| 127 var relatedException; | 122 var relatedException; |
| 128 var relatedData; | 123 var relatedData; |
| 129 var length; | 124 var length; |
| 130 var nodeType; | 125 var nodeType; |
| 131 var nodeValue; | 126 var nodeValue; |
| 132 | 127 |
| 133 var docRef = null; | 128 var docRef = null; |
| 134 if (typeof(this.doc) != 'undefined') { | 129 if (typeof(this.doc) != 'undefined') { |
| 135 docRef = this.doc; | 130 docRef = this.doc; |
| 136 } | 131 } |
| 137 doc = load(docRef, "doc", "barfoo"); | 132 doc = load(docRef, "doc", "barfoo"); |
| 138 elemList = doc.getElementsByTagName("p"); | 133 elemList = doc.getElementsByTagName("p"); |
| 139 elem = elemList.item(0); | 134 elem = elemList.item(0); |
| 140 newChild = doc.createCDATASection("this is not ]]> good"); | 135 newChild = doc.createCDATASection("this is not ]]> good"); |
| 141 oldChild = elem.firstChild; | 136 oldChild = elem.firstChild; |
| 142 | 137 |
| 143 retval = elem.replaceChild(newChild,oldChild); | 138 retval = elem.replaceChild(newChild,oldChild); |
| 144 domConfig = doc.domConfig; | 139 domConfig = doc.domConfig; |
| 145 | 140 |
| 146 domConfig.setParameter("split-cdata-sections", true); | 141 domConfig.setParameter("split-cdata-sections", true); |
| 147 » domConfig.setParameter("error-handler", errorMonitor.handleError); | 142 domConfig.setParameter("error-handler", errorMonitor.handleError); |
| 148 » doc.normalizeDocument(); | 143 doc.normalizeDocument(); |
| 149 newChild = elem.firstChild; | 144 newChild = elem.firstChild; |
| 150 | 145 |
| 151 nodeValue = newChild.nodeValue; | 146 nodeValue = newChild.nodeValue; |
| 152 | 147 |
| 153 nodeType = newChild.nodeType; | 148 nodeType = newChild.nodeType; |
| 154 | 149 |
| 155 | 150 { |
| 156 » » » { | 151 assertFalse("wasSplit", |
| 157 » » » assertFalse("wasSplit", | 152 ((4 == nodeType) && (nodeValue.indexOf("]]>") >= 0)) |
| 158 » ((4 == nodeType) && (nodeValue.indexOf("]]>") >= 0)) | |
| 159 ); | 153 ); |
| 160 errors = errorMonitor.allErrors; | 154 errors = errorMonitor.allErrors; |
| 161 for(var indexN1010C = 0;indexN1010C < errors.length; indexN1010C++) { | 155 for(var indexN1010C = 0;indexN1010C < errors.length; indexN1010C++) { |
| 162 error = errors[indexN1010C]; | 156 error = errors[indexN1010C]; |
| 163 type = error.type; | 157 type = error.type; |
| 164 | 158 |
| 165 severity = error.severity; | 159 severity = error.severity; |
| 166 | 160 |
| 167 | 161 if( |
| 168 » if( | 162 ("cdata-sections-splitted" == type) |
| 169 » ("cdata-sections-splitted" == type) | 163 ) { |
| 170 » ) { | 164 relatedData = error.relatedData; |
| 171 » relatedData = error.relatedData; | |
| 172 | 165 |
| 173 assertSame("relatedData",newChild,relatedData); | 166 assertSame("relatedData",newChild,relatedData); |
| 174 assertEquals("severity",1,severity); | 167 assertEquals("severity",1,severity); |
| 175 message = error.message; | 168 message = error.message; |
| 176 | 169 |
| 177 length = message.length; | 170 length = message.length; |
| 178 » assertTrue("messageNotEmpty", | 171 assertTrue("messageNotEmpty", |
| 179 | 172 |
| 180 » (length > 0) | 173 (length > 0) |
| 181 ); | 174 ); |
| 182 relatedException = error.relatedException; | 175 relatedException = error.relatedException; |
| 183 | 176 |
| 184 location = error.location; | 177 location = error.location; |
| 185 | 178 |
| 186 problemNode = location.relatedNode; | 179 problemNode = location.relatedNode; |
| 187 | 180 |
| 188 assertSame("relatedNode",newChild,problemNode); | 181 assertSame("relatedNode",newChild,problemNode); |
| 189 lineNumber = location.lineNumber; | 182 lineNumber = location.lineNumber; |
| 190 | 183 |
| 191 columnNumber = location.columnNumber; | 184 columnNumber = location.columnNumber; |
| 192 | 185 |
| 193 byteOffset = location.byteOffset; | 186 byteOffset = location.byteOffset; |
| 194 | 187 |
| 195 utf16Offset = location.utf16Offset; | 188 utf16Offset = location.utf16Offset; |
| 196 | 189 |
| 197 uri = location.uri; | 190 uri = location.uri; |
| 198 | 191 |
| 199 splittedCount += 1; | 192 splittedCount += 1; |
| 200 | 193 |
| 201 » } | 194 } |
| 202 » | 195 |
| 203 » » else { | 196 else { |
| 204 » » » assertEquals("anyOthersShouldBeWarnings",1,severity); | 197 assertEquals("anyOthersShouldBeWarnings",1,severity); |
| 205 | 198 |
| 206 » » } | 199 } |
| 207 » | 200 |
| 208 » } | 201 } |
| 209 assertEquals("oneSplittedWarning",1,splittedCount); | 202 assertEquals("oneSplittedWarning",1,splittedCount); |
| 210 | 203 |
| 211 } | 204 } |
| 212 | 205 |
| 213 | |
| 214 | |
| 215 | |
| 216 function runTest() { | 206 function runTest() { |
| 217 documentnormalizedocument06(); | 207 documentnormalizedocument06(); |
| 218 } | 208 } |
| OLD | NEW |