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] in 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/level1/core/hc_documentgetelementsbytagnametotallength"; 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", "hc_staff"); 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 76 /** 77 * 78 Retrieve the entire DOM document and invoke its 79 "getElementsByTagName(tagName)" method with tagName 80 equal to "*". The method should return a NodeList 81 that contains all the elements of the document. 82 83 * @author Curt Arnold 84 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 85 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 86 */ 87 function hc_documentgetelementsbytagnametotallength() { 88 var success; 89 if(checkInitialization(builder, "hc_documentgetelementsbytagnametotallength") != null) return; 90 var doc; 91 var nameList; 92 expectedNames = new Array(); 93 expectedNames[0] = "html"; 94 expectedNames[1] = "head"; 95 expectedNames[2] = "meta"; 96 expectedNames[3] = "title"; 97 expectedNames[4] = "script"; 98 expectedNames[5] = "script"; 99 expectedNames[6] = "script"; 100 expectedNames[7] = "body"; 101 expectedNames[8] = "p"; 102 expectedNames[9] = "em"; 103 expectedNames[10] = "strong"; 104 expectedNames[11] = "code"; 105 expectedNames[12] = "sup"; 106 expectedNames[13] = "var"; 107 expectedNames[14] = "acronym"; 108 expectedNames[15] = "p"; 109 expectedNames[16] = "em"; 110 expectedNames[17] = "strong"; 111 expectedNames[18] = "code"; 112 expectedNames[19] = "sup"; 113 expectedNames[20] = "var"; 114 expectedNames[21] = "acronym"; 115 expectedNames[22] = "p"; 116 expectedNames[23] = "em"; 117 expectedNames[24] = "strong"; 118 expectedNames[25] = "code"; 119 expectedNames[26] = "sup"; 120 expectedNames[27] = "var"; 121 expectedNames[28] = "acronym"; 122 expectedNames[29] = "p"; 123 expectedNames[30] = "em"; 124 expectedNames[31] = "strong"; 125 expectedNames[32] = "code"; 126 expectedNames[33] = "sup"; 127 expectedNames[34] = "var"; 128 expectedNames[35] = "acronym"; 129 expectedNames[36] = "p"; 130 expectedNames[37] = "em"; 131 expectedNames[38] = "strong"; 132 expectedNames[39] = "code"; 133 expectedNames[40] = "sup"; 134 expectedNames[41] = "var"; 135 expectedNames[42] = "acronym"; 136 137 svgExpectedNames = new Array(); 138 svgExpectedNames[0] = "svg"; 139 svgExpectedNames[1] = "rect"; 140 svgExpectedNames[2] = "script"; 141 svgExpectedNames[3] = "head"; 142 svgExpectedNames[4] = "meta"; 143 svgExpectedNames[5] = "title"; 144 svgExpectedNames[6] = "body"; 145 svgExpectedNames[7] = "p"; 146 svgExpectedNames[8] = "em"; 147 svgExpectedNames[9] = "strong"; 148 svgExpectedNames[10] = "code"; 149 svgExpectedNames[11] = "sup"; 150 svgExpectedNames[12] = "var"; 151 svgExpectedNames[13] = "acronym"; 152 svgExpectedNames[14] = "p"; 153 svgExpectedNames[15] = "em"; 154 svgExpectedNames[16] = "strong"; 155 svgExpectedNames[17] = "code"; 156 svgExpectedNames[18] = "sup"; 157 svgExpectedNames[19] = "var"; 158 svgExpectedNames[20] = "acronym"; 159 svgExpectedNames[21] = "p"; 160 svgExpectedNames[22] = "em"; 161 svgExpectedNames[23] = "strong"; 162 svgExpectedNames[24] = "code"; 163 svgExpectedNames[25] = "sup"; 164 svgExpectedNames[26] = "var"; 165 svgExpectedNames[27] = "acronym"; 166 svgExpectedNames[28] = "p"; 167 svgExpectedNames[29] = "em"; 168 svgExpectedNames[30] = "strong"; 169 svgExpectedNames[31] = "code"; 170 svgExpectedNames[32] = "sup"; 171 svgExpectedNames[33] = "var"; 172 svgExpectedNames[34] = "acronym"; 173 svgExpectedNames[35] = "p"; 174 svgExpectedNames[36] = "em"; 175 svgExpectedNames[37] = "strong"; 176 svgExpectedNames[38] = "code"; 177 svgExpectedNames[39] = "sup"; 178 svgExpectedNames[40] = "var"; 179 svgExpectedNames[41] = "acronym"; 180 181 var actualNames = new Array(); 182 183 var thisElement; 184 var thisTag; 185 186 var docRef = null; 187 if (typeof(this.doc) != 'undefined') { 188 docRef = this.doc; 189 } 190 doc = load(docRef, "doc", "hc_staff"); 191 nameList = doc.getElementsByTagName("*"); 192 for(var indexN10148 = 0;indexN10148 < nameList.length; indexN10148++) { 193 thisElement = nameList.item(indexN10148); 194 thisTag = thisElement.tagName; 195 196 actualNames[actualNames.length] = thisTag; 197 198 } 199 200 if( 201 202 (builder.contentType == "image/svg+xml") 203 204 ) { 205 assertEqualsListAutoCase("element", "svgTagNames",svgExpectedNames,actualNames); 206 207 } 208 209 else { 210 assertEqualsListAutoCase("element", "tagNames",expectedNames,actualNames); 211 212 } 213 214 } 215 216 217 218 219 function runTest() { 220 hc_documentgetelementsbytagnametotallength(); 221 } 222