| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (c) 2001-2005 World Wide Web Consortium, | 2 Copyright (c) 2001-2005 World Wide Web Consortium, |
| 3 (Massachusetts Institute of Technology, European Research Consortium | 3 (Massachusetts Institute of Technology, European Research Consortium |
| 4 for Informatics and Mathematics, Keio University). All | 4 for Informatics and Mathematics, Keio University). All |
| 5 Rights Reserved. This work is distributed under the W3C(r) Software License [1]
in the | 5 Rights Reserved. This work is distributed under the W3C(r) Software License [1]
in the |
| 6 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 |
| 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | 8 |
| 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 | 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 function assertSize(descr, expected, actual) { | 12 function assertSize(descr, expected, actual) { |
| 13 var actualSize; | 13 var actualSize; |
| 14 assertNotNull(descr, actual); | 14 assertNotNull(descr, actual); |
| 15 actualSize = actual.length; | 15 actualSize = actual.length; |
| 16 assertEquals(descr, expected, actualSize); | 16 assertEquals(descr, expected, actualSize); |
| 17 } | 17 } |
| 18 | 18 |
| 19 function assertEqualsAutoCase(context, descr, expected, actual) { | 19 function assertEqualsAutoCase(context, descr, expected, actual) { |
| 20 » if (builder.contentType == "text/html") { | 20 if (builder.contentType == "text/html") { |
| 21 » if(context == "attribute") { | 21 if(context == "attribute") { |
| 22 » » assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()
); | 22 assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()); |
| 23 » } else { | 23 } else { |
| 24 » assertEquals(descr, expected.toUpperCase(), actual); | 24 assertEquals(descr, expected.toUpperCase(), actual); |
| 25 » } | 25 } |
| 26 » } else { | 26 } else { |
| 27 » » assertEquals(descr, expected, actual); | 27 assertEquals(descr, expected, actual); |
| 28 » } | 28 } |
| 29 } | 29 } |
| 30 | |
| 31 | 30 |
| 32 function assertEqualsCollectionAutoCase(context, descr, expected, actual) { | 31 function assertEqualsCollectionAutoCase(context, descr, expected, actual) { |
| 33 // | 32 // |
| 34 // if they aren't the same size, they aren't equal | 33 // if they aren't the same size, they aren't equal |
| 35 assertEquals(descr, expected.length, actual.length); | 34 assertEquals(descr, expected.length, actual.length); |
| 36 | 35 |
| 37 // | 36 // |
| 38 // if there length is the same, then every entry in the expected list | 37 // if there length is the same, then every entry in the expected list |
| 39 // must appear once and only once in the actual list | 38 // must appear once and only once in the actual list |
| 40 var expectedLen = expected.length; | 39 var expectedLen = expected.length; |
| 41 var expectedValue; | 40 var expectedValue; |
| 42 var actualLen = actual.length; | 41 var actualLen = actual.length; |
| 43 var i; | 42 var i; |
| 44 var j; | 43 var j; |
| 45 var matches; | 44 var matches; |
| 46 for(i = 0; i < expectedLen; i++) { | 45 for(i = 0; i < expectedLen; i++) { |
| 47 matches = 0; | 46 matches = 0; |
| 48 expectedValue = expected[i]; | 47 expectedValue = expected[i]; |
| 49 for(j = 0; j < actualLen; j++) { | 48 for(j = 0; j < actualLen; j++) { |
| 50 » if (builder.contentType == "text/html") { | 49 if (builder.contentType == "text/html") { |
| 51 » » if (context == "attribute") { | 50 if (context == "attribute") { |
| 52 » » » if (expectedValue.toLowerCase() == actual[j].toL
owerCase()) { | 51 if (expectedValue.toLowerCase() == actual[j].toLowerCase())
{ |
| 53 » » » » matches++; | 52 matches++; |
| 54 » » » } | 53 } |
| 55 » » } else { | 54 } else { |
| 56 » » » if (expectedValue.toUpperCase() == actual[j]) { | 55 if (expectedValue.toUpperCase() == actual[j]) { |
| 57 » » » » matches++; | 56 matches++; |
| 58 » » » } | 57 } |
| 59 » » } | 58 } |
| 60 » } else { | 59 } else { |
| 61 » if(expectedValue == actual[j]) { | 60 if(expectedValue == actual[j]) { |
| 62 » matches++; | 61 matches++; |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 } | 64 } |
| 66 if(matches == 0) { | 65 if(matches == 0) { |
| 67 assert(descr + ": No match found for " + expectedValue,false); | 66 assert(descr + ": No match found for " + expectedValue,false); |
| 68 } | 67 } |
| 69 if(matches > 1) { | 68 if(matches > 1) { |
| 70 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); | 69 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); |
| 71 } | 70 } |
| 72 } | 71 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 95 } | 94 } |
| 96 if(matches == 0) { | 95 if(matches == 0) { |
| 97 assert(descr + ": No match found for " + expectedValue,false); | 96 assert(descr + ": No match found for " + expectedValue,false); |
| 98 } | 97 } |
| 99 if(matches > 1) { | 98 if(matches > 1) { |
| 100 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); | 99 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); |
| 101 } | 100 } |
| 102 } | 101 } |
| 103 } | 102 } |
| 104 | 103 |
| 105 | |
| 106 function assertEqualsListAutoCase(context, descr, expected, actual) { | 104 function assertEqualsListAutoCase(context, descr, expected, actual) { |
| 107 » var minLength = expected.length; | 105 var minLength = expected.length; |
| 108 » if (actual.length < minLength) { | 106 if (actual.length < minLength) { |
| 109 » minLength = actual.length; | 107 minLength = actual.length; |
| 110 » } | 108 } |
| 111 // | 109 // |
| 112 for(var i = 0; i < minLength; i++) { | 110 for(var i = 0; i < minLength; i++) { |
| 113 » » assertEqualsAutoCase(context, descr, expected[i], actual[i]); | 111 assertEqualsAutoCase(context, descr, expected[i], actual[i]); |
| 114 } | 112 } |
| 115 // | 113 // |
| 116 // if they aren't the same size, they aren't equal | 114 // if they aren't the same size, they aren't equal |
| 117 assertEquals(descr, expected.length, actual.length); | 115 assertEquals(descr, expected.length, actual.length); |
| 118 } | 116 } |
| 119 | 117 |
| 120 | |
| 121 function assertEqualsList(descr, expected, actual) { | 118 function assertEqualsList(descr, expected, actual) { |
| 122 » var minLength = expected.length; | 119 var minLength = expected.length; |
| 123 » if (actual.length < minLength) { | 120 if (actual.length < minLength) { |
| 124 » minLength = actual.length; | 121 minLength = actual.length; |
| 125 » } | 122 } |
| 126 // | 123 // |
| 127 for(var i = 0; i < minLength; i++) { | 124 for(var i = 0; i < minLength; i++) { |
| 128 if(expected[i] != actual[i]) { | 125 if(expected[i] != actual[i]) { |
| 129 » » » assertEquals(descr, expected[i], actual[i]); | 126 assertEquals(descr, expected[i], actual[i]); |
| 130 } | 127 } |
| 131 } | 128 } |
| 132 // | 129 // |
| 133 // if they aren't the same size, they aren't equal | 130 // if they aren't the same size, they aren't equal |
| 134 assertEquals(descr, expected.length, actual.length); | 131 assertEquals(descr, expected.length, actual.length); |
| 135 } | 132 } |
| 136 | 133 |
| 137 function assertInstanceOf(descr, type, obj) { | 134 function assertInstanceOf(descr, type, obj) { |
| 138 if(type == "Attr") { | 135 if(type == "Attr") { |
| 139 assertEquals(descr,2,obj.nodeType); | 136 assertEquals(descr,2,obj.nodeType); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 217 } |
| 221 assertEquals(assertID, name, actualName); | 218 assertEquals(assertID, name, actualName); |
| 222 } | 219 } |
| 223 } | 220 } |
| 224 | 221 |
| 225 if(isAbsolute != null) { | 222 if(isAbsolute != null) { |
| 226 assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); | 223 assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); |
| 227 } | 224 } |
| 228 } | 225 } |
| 229 | 226 |
| 230 | |
| 231 // size() used by assertSize element | 227 // size() used by assertSize element |
| 232 function size(collection) | 228 function size(collection) |
| 233 { | 229 { |
| 234 return collection.length; | 230 return collection.length; |
| 235 } | 231 } |
| 236 | 232 |
| 237 function same(expected, actual) | 233 function same(expected, actual) |
| 238 { | 234 { |
| 239 return expected === actual; | 235 return expected === actual; |
| 240 } | 236 } |
| 241 | 237 |
| 242 function equalsAutoCase(context, expected, actual) { | 238 function equalsAutoCase(context, expected, actual) { |
| 243 » if (builder.contentType == "text/html") { | 239 if (builder.contentType == "text/html") { |
| 244 » » if (context == "attribute") { | 240 if (context == "attribute") { |
| 245 » » » return expected.toLowerCase() == actual; | 241 return expected.toLowerCase() == actual; |
| 246 » » } | 242 } |
| 247 » » return expected.toUpperCase() == actual; | 243 return expected.toUpperCase() == actual; |
| 248 » } | 244 } |
| 249 » return expected == actual; | 245 return expected == actual; |
| 250 } | 246 } |
| 251 | 247 |
| 252 function toLowerArray(src) { | 248 function toLowerArray(src) { |
| 253 var newArray = new Array(); | 249 var newArray = new Array(); |
| 254 var i; | 250 var i; |
| 255 for (i = 0; i < src.length; i++) { | 251 for (i = 0; i < src.length; i++) { |
| 256 newArray[i] = src[i].toLowerCase(); | 252 newArray[i] = src[i].toLowerCase(); |
| 257 } | 253 } |
| 258 return newArray; | 254 return newArray; |
| 259 } | 255 } |
| 260 | 256 |
| 261 function createTempURI(scheme) { | 257 function createTempURI(scheme) { |
| 262 if (scheme == "http") { | 258 if (scheme == "http") { |
| 263 » return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() *
100000) + ".xml"; | 259 return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() *
100000) + ".xml"; |
| 264 } | 260 } |
| 265 return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml"; | 261 return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml"; |
| 266 } | 262 } |
| 267 | 263 |
| 268 | |
| 269 | |
| 270 function EventMonitor() { | 264 function EventMonitor() { |
| 271 this.atEvents = new Array(); | 265 this.atEvents = new Array(); |
| 272 this.bubbledEvents = new Array(); | 266 this.bubbledEvents = new Array(); |
| 273 this.capturedEvents = new Array(); | 267 this.capturedEvents = new Array(); |
| 274 this.allEvents = new Array(); | 268 this.allEvents = new Array(); |
| 275 } | 269 } |
| 276 | 270 |
| 277 EventMonitor.prototype.handleEvent = function(evt) { | 271 EventMonitor.prototype.handleEvent = function(evt) { |
| 278 switch(evt.eventPhase) { | 272 switch(evt.eventPhase) { |
| 279 case 1: | 273 case 1: |
| 280 monitor.capturedEvents[monitor.capturedEvents.length] = evt; | 274 monitor.capturedEvents[monitor.capturedEvents.length] = evt; |
| 281 break; | 275 break; |
| 282 | 276 |
| 283 case 2: | 277 case 2: |
| 284 monitor.atEvents[monitor.atEvents.length] = evt; | 278 monitor.atEvents[monitor.atEvents.length] = evt; |
| 285 break; | 279 break; |
| 286 | 280 |
| 287 case 3: | 281 case 3: |
| 288 monitor.bubbledEvents[monitor.bubbledEvents.length] = evt; | 282 monitor.bubbledEvents[monitor.bubbledEvents.length] = evt; |
| 289 break; | 283 break; |
| 290 } | 284 } |
| 291 monitor.allEvents[monitor.allEvents.length] = evt; | 285 monitor.allEvents[monitor.allEvents.length] = evt; |
| 292 } | 286 } |
| 293 | 287 |
| 294 function DOMErrorImpl(err) { | 288 function DOMErrorImpl(err) { |
| 295 this.severity = err.severity; | 289 this.severity = err.severity; |
| 296 this.message = err.message; | 290 this.message = err.message; |
| 297 this.type = err.type; | 291 this.type = err.type; |
| 298 this.relatedException = err.relatedException; | 292 this.relatedException = err.relatedException; |
| 299 this.relatedData = err.relatedData; | 293 this.relatedData = err.relatedData; |
| 300 this.location = err.location; | 294 this.location = err.location; |
| 301 } | 295 } |
| 302 | 296 |
| 303 | |
| 304 | |
| 305 function DOMErrorMonitor() { | 297 function DOMErrorMonitor() { |
| 306 this.allErrors = new Array(); | 298 this.allErrors = new Array(); |
| 307 } | 299 } |
| 308 | 300 |
| 309 DOMErrorMonitor.prototype.handleError = function(err) { | 301 DOMErrorMonitor.prototype.handleError = function(err) { |
| 310 errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err
); | 302 errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err
); |
| 311 } | 303 } |
| 312 | 304 |
| 313 DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) { | 305 DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) { |
| 314 var i; | 306 var i; |
| 315 for (i = 0; i < this.allErrors.length; i++) { | 307 for (i = 0; i < this.allErrors.length; i++) { |
| 316 if (this.allErrors[i].severity >= severity) { | 308 if (this.allErrors[i].severity >= severity) { |
| 317 assertEquals(id, severity - 1, this.allErrors[i].severity); | 309 assertEquals(id, severity - 1, this.allErrors[i].severity); |
| 318 } | 310 } |
| 319 } | 311 } |
| 320 } | 312 } |
| 321 | 313 |
| 322 function UserDataNotification(operation, key, data, src, dst) { | 314 function UserDataNotification(operation, key, data, src, dst) { |
| 323 this.operation = operation; | 315 this.operation = operation; |
| 324 this.key = key; | 316 this.key = key; |
| 325 this.data = data; | 317 this.data = data; |
| 326 this.src = src; | 318 this.src = src; |
| 327 this.dst = dst; | 319 this.dst = dst; |
| 328 } | 320 } |
| 329 | 321 |
| 330 function UserDataMonitor() { | 322 function UserDataMonitor() { |
| 331 » this.allNotifications = new Array(); | 323 this.allNotifications = new Array(); |
| 332 } | 324 } |
| 333 | 325 |
| 334 UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) { | 326 UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) { |
| 335 userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] = | 327 userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] = |
| 336 new UserDataNotification(operation, key, data, src, dst); | 328 new UserDataNotification(operation, key, data, src, dst); |
| 337 } | 329 } |
| 338 | 330 |
| 339 | |
| 340 | |
| 341 function HTMLBuilder() { | 331 function HTMLBuilder() { |
| 342 this.contentType = "application/xhtml+xml"; | 332 this.contentType = "application/xhtml+xml"; |
| 343 this.supportedContentTypes = [ "application/xhtml+xml" ]; | 333 this.supportedContentTypes = [ "application/xhtml+xml" ]; |
| 344 | 334 |
| 345 this.supportsAsyncChange = false; | 335 this.supportsAsyncChange = false; |
| 346 this.async = false; | 336 this.async = false; |
| 347 this.fixedAttributeNames = [ | 337 this.fixedAttributeNames = [ |
| 348 "validating", "expandEntityReferences", "coalescing", | 338 "validating", "expandEntityReferences", "coalescing", |
| 349 "signed", "hasNullString", "ignoringElementContentWhitespace", "namespac
eAware", "ignoringComments", "schemaValidating"]; | 339 "signed", "hasNullString", "ignoringElementContentWhitespace", "namespac
eAware", "ignoringComments", "schemaValidating"]; |
| 350 | 340 |
| 351 this.fixedAttributeValues = [false, true, false, true, true , false, true,
false, false ]; | 341 this.fixedAttributeValues = [false, true, false, true, true , false, true,
false, false ]; |
| 352 this.configurableAttributeNames = [ ]; | 342 this.configurableAttributeNames = [ ]; |
| 353 this.configurableAttributeValues = [ ]; | 343 this.configurableAttributeValues = [ ]; |
| 354 this.initializationError = null; | 344 this.initializationError = null; |
| 355 this.initializationFatalError = null; | 345 this.initializationFatalError = null; |
| 356 this.skipIncompatibleTests = true; | 346 this.skipIncompatibleTests = true; |
| 357 this.documentURLs = new Array(); | 347 this.documentURLs = new Array(); |
| 358 this.documentVarnames = new Array(); | 348 this.documentVarnames = new Array(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 387 } |
| 398 var srcChild = srcNode.firstChild; | 388 var srcChild = srcNode.firstChild; |
| 399 while(srcChild != null) { | 389 while(srcChild != null) { |
| 400 var cloneChild = this.cloneNode(srcChild, doc); | 390 var cloneChild = this.cloneNode(srcChild, doc); |
| 401 if (cloneChild != null) { | 391 if (cloneChild != null) { |
| 402 clone.appendChild(cloneChild); | 392 clone.appendChild(cloneChild); |
| 403 } | 393 } |
| 404 srcChild = srcChild.nextSibling; | 394 srcChild = srcChild.nextSibling; |
| 405 } | 395 } |
| 406 break; | 396 break; |
| 407 | 397 |
| 408 case 3: | 398 case 3: |
| 409 clone = doc.createTextNode(srcNode.nodeValue); | 399 clone = doc.createTextNode(srcNode.nodeValue); |
| 410 break; | 400 break; |
| 411 | 401 |
| 412 case 4: | 402 case 4: |
| 413 clone = doc.createCDATASection(srcNode.nodeValue); | 403 clone = doc.createCDATASection(srcNode.nodeValue); |
| 414 break; | 404 break; |
| 415 | 405 |
| 416 case 5: | 406 case 5: |
| 417 clone = doc.createEntityReference(srcNode.nodeName); | 407 clone = doc.createEntityReference(srcNode.nodeName); |
| 418 break; | 408 break; |
| 419 | 409 |
| 420 case 7: | 410 case 7: |
| 421 clone = doc.createProcessingInstruction(srcNode.target, srcNode.data); | 411 clone = doc.createProcessingInstruction(srcNode.target, srcNode.data); |
| 422 break; | 412 break; |
| 423 | 413 |
| 424 case 8: | 414 case 8: |
| 425 clone = doc.createComment(srcNode.nodeValue); | 415 clone = doc.createComment(srcNode.nodeValue); |
| 426 break; | 416 break; |
| 427 } | 417 } |
| 428 return clone; | 418 return clone; |
| 429 | 419 |
| 430 } | 420 } |
| 431 | 421 |
| 432 | |
| 433 HTMLBuilder.prototype.load = function(frame, varname, url) { | 422 HTMLBuilder.prototype.load = function(frame, varname, url) { |
| 434 if (this.documentVarnames[0] == varname) { | 423 if (this.documentVarnames[0] == varname) { |
| 435 » return document; | 424 return document; |
| 436 } | 425 } |
| 437 // | 426 // |
| 438 // | 427 // |
| 439 // not a perfect way to do this | 428 // not a perfect way to do this |
| 440 // Document.cloneNode is implementation dependent but exists in L1 | 429 // Document.cloneNode is implementation dependent but exists in L1 |
| 441 // and implemented in IE. The alternative brute force copy | 430 // and implemented in IE. The alternative brute force copy |
| 442 // only works in L2 or higher implementations and can't copy | 431 // only works in L2 or higher implementations and can't copy |
| 443 // entity and notation definitions, etc. | 432 // entity and notation definitions, etc. |
| 444 var clone = null; | 433 var clone = null; |
| 445 try { | 434 try { |
| 446 clone = document.cloneNode(true); | 435 clone = document.cloneNode(true); |
| 447 } catch(ex) { | 436 } catch(ex) { |
| 448 } | 437 } |
| 449 if (clone == null) { | 438 if (clone == null) { |
| 450 clone = document.implementation.createDocument( | 439 clone = document.implementation.createDocument( |
| 451 document.documentElement.namespaceURI, | 440 document.documentElement.namespaceURI, |
| 452 document.documentElement.nodeName, | 441 document.documentElement.nodeName, |
| 453 null); | 442 null); |
| 454 // | 443 // |
| 455 // Work-around since | 444 // Work-around since |
| 456 // Safari does not create document element | 445 // Safari does not create document element |
| 457 // create document. | 446 // create document. |
| 458 if (clone.documentElement == null) { | 447 if (clone.documentElement == null) { |
| 459 clone.appendChild(clone.createElementNS( | 448 clone.appendChild(clone.createElementNS( |
| 460 document.documentElement.namespaceURI, | 449 document.documentElement.namespaceURI, |
| 461 document.documentElement.nodeName)); | 450 document.documentElement.nodeName)); |
| 462 } | 451 } |
| 463 var attrs = document.documentElement.attributes; | 452 var attrs = document.documentElement.attributes; |
| 464 for(var i = 0; i < attrs.length; i++) { | 453 for(var i = 0; i < attrs.length; i++) { |
| 465 var srcAttr = attrs.item(i); | 454 var srcAttr = attrs.item(i); |
| 466 clone.documentElement.setAttributeNS( | 455 clone.documentElement.setAttributeNS( |
| 467 srcAttr.namespaceURI, srcAttr.nodeName, srcAttr.nodeValue); | 456 srcAttr.namespaceURI, srcAttr.nodeName, srcAttr.nodeValue); |
| 468 } | 457 } |
| 469 | 458 |
| 470 var srcNode = document.firstChild; | 459 var srcNode = document.firstChild; |
| 471 while(srcNode != null && srcNode.nodeType != 1) { | 460 while(srcNode != null && srcNode.nodeType != 1) { |
| 472 if (srcNode.nodeType != 10) { | 461 if (srcNode.nodeType != 10) { |
| 473 » var cloneNode = this.cloneNode(srcNode, clone); | 462 var cloneNode = this.cloneNode(srcNode, clone); |
| 474 clone.insertBefore(cloneNode, clone.documentElement); | 463 clone.insertBefore(cloneNode, clone.documentElement); |
| 475 } | 464 } |
| 476 srcNode = srcNode.nextSibling; | 465 srcNode = srcNode.nextSibling; |
| 477 } | 466 } |
| 478 srcNode = document.documentElement.nextSibling; | 467 srcNode = document.documentElement.nextSibling; |
| 479 while(srcNode != null) { | 468 while(srcNode != null) { |
| 480 var cloneNode = this.cloneNode(srcNode, clone); | 469 var cloneNode = this.cloneNode(srcNode, clone); |
| 481 clone.appendChild(cloneNode); | 470 clone.appendChild(cloneNode); |
| 482 srcNode = srcNode.nextSibling; | 471 srcNode = srcNode.nextSibling; |
| 483 } | 472 } |
| 484 srcNode = document.documentElement.firstChild; | 473 srcNode = document.documentElement.firstChild; |
| 485 while(srcNode != null) { | 474 while(srcNode != null) { |
| 486 var cloneNode = this.cloneNode(srcNode, clone); | 475 var cloneNode = this.cloneNode(srcNode, clone); |
| 487 if (cloneNode != null) { | 476 if (cloneNode != null) { |
| 488 clone.documentElement.appendChild(cloneNode); | 477 clone.documentElement.appendChild(cloneNode); |
| 489 } | 478 } |
| 490 srcNode = srcNode.nextSibling; | 479 srcNode = srcNode.nextSibling; |
| 491 } | 480 } |
| 492 } | 481 } |
| 493 return clone; | 482 return clone; |
| 494 } | 483 } |
| 495 | 484 |
| 496 HTMLBuilder.prototype.getImplementationAttribute = function(attr) { | 485 HTMLBuilder.prototype.getImplementationAttribute = function(attr) { |
| 497 for (var i = 0; i < this.fixedAttributeNames.length; i++) { | 486 for (var i = 0; i < this.fixedAttributeNames.length; i++) { |
| 498 if (this.fixedAttributeNames[i] == attr) { | 487 if (this.fixedAttributeNames[i] == attr) { |
| 499 return this.fixedAttributeValues[i]; | 488 return this.fixedAttributeValues[i]; |
| 500 } | 489 } |
| 501 } | 490 } |
| 502 throw "Unrecognized implementation attribute: " + attr; | 491 throw "Unrecognized implementation attribute: " + attr; |
| 503 } | 492 } |
| 504 | 493 |
| 505 | |
| 506 HTMLBuilder.prototype.setImplementationAttribute = function(attribute, value) { | 494 HTMLBuilder.prototype.setImplementationAttribute = function(attribute, value) { |
| 507 var supported = this.getImplementationAttribute(attribute); | 495 var supported = this.getImplementationAttribute(attribute); |
| 508 if (supported != value) { | 496 if (supported != value) { |
| 509 this.initializationError = "HTML loader does not support " + attribute +
"=" + value; | 497 this.initializationError = "HTML loader does not support " + attribute +
"=" + value; |
| 510 } | 498 } |
| 511 } | 499 } |
| 512 | 500 |
| 513 HTMLBuilder.prototype.canSetImplementationAttribute = function(attribute, value)
{ | 501 HTMLBuilder.prototype.canSetImplementationAttribute = function(attribute, value)
{ |
| 514 var supported = this.getImplementationAttribute(attribute); | 502 var supported = this.getImplementationAttribute(attribute); |
| 515 return (supported == value); | 503 return (supported == value); |
| 516 } | 504 } |
| 517 | 505 |
| 518 | |
| 519 | |
| 520 | |
| 521 function createConfiguredBuilder() { | 506 function createConfiguredBuilder() { |
| 522 return new HTMLBuilder(); | 507 return new HTMLBuilder(); |
| 523 } | 508 } |
| 524 | 509 |
| 525 function catchInitializationError(buildr, ex) { | 510 function catchInitializationError(buildr, ex) { |
| 526 buildr.initializationError = ex; | 511 buildr.initializationError = ex; |
| 527 buildr.initializationFatalError = ex; | 512 buildr.initializationFatalError = ex; |
| 528 } | 513 } |
| 529 | 514 |
| 530 | |
| 531 function checkFeature(feature, version) | 515 function checkFeature(feature, version) |
| 532 { | 516 { |
| 533 if (!builder.hasFeature(feature, version)) | 517 if (!builder.hasFeature(feature, version)) |
| 534 { | 518 { |
| 535 // | 519 // |
| 536 // don't throw exception so that users can select to ignore the preconditi
on | 520 // don't throw exception so that users can select to ignore the preconditi
on |
| 537 // | 521 // |
| 538 builder.initializationError = "builder does not support feature " + feature
+ " version " + version; | 522 builder.initializationError = "builder does not support feature " + feature
+ " version " + version; |
| 539 } | 523 } |
| 540 } | 524 } |
| 541 | 525 |
| 542 function setResult(resultType, message) { | 526 function setResult(resultType, message) { |
| 543 var testName = getTargetURI(); | 527 var testName = getTargetURI(); |
| 544 document.title = testName + ":" + resultType; | 528 document.title = testName + ":" + resultType; |
| 545 var xhtmlNS = "http://www.w3.org/1999/xhtml"; | 529 var xhtmlNS = "http://www.w3.org/1999/xhtml"; |
| 546 var newBody = document.createElementNS(xhtmlNS, "body"); | 530 var newBody = document.createElementNS(xhtmlNS, "body"); |
| 547 var newTable = document.createElementNS(xhtmlNS, "table"); | 531 var newTable = document.createElementNS(xhtmlNS, "table"); |
| 548 newTable.width = "100%"; | 532 newTable.width = "100%"; |
| 549 newTable.border = "1"; | 533 newTable.border = "1"; |
| 550 newBody.appendChild(newTable); | 534 newBody.appendChild(newTable); |
| 551 var testRow = newTable.insertRow(-1); | 535 var testRow = newTable.insertRow(-1); |
| 552 var testDiv1 = testRow.insertCell(-1); | 536 var testDiv1 = testRow.insertCell(-1); |
| 553 testDiv1.appendChild(document.createTextNode("Test")); | 537 testDiv1.appendChild(document.createTextNode("Test")); |
| 554 var testDiv2 = testRow.insertCell(-1); | 538 var testDiv2 = testRow.insertCell(-1); |
| 555 testDiv2.appendChild(document.createTextNode(testName)); | 539 testDiv2.appendChild(document.createTextNode(testName)); |
| 556 var statusRow = newTable.insertRow(-1); | 540 var statusRow = newTable.insertRow(-1); |
| 557 var statusDiv1 = statusRow.insertCell(-1); | 541 var statusDiv1 = statusRow.insertCell(-1); |
| 558 statusDiv1.appendChild(document.createTextNode("Status")); | 542 statusDiv1.appendChild(document.createTextNode("Status")); |
| 559 var statusDiv2 = statusRow.insertCell(-1); | 543 var statusDiv2 = statusRow.insertCell(-1); |
| 560 var style = "color:green"; | 544 var style = "color:green"; |
| 561 if (resultType == null) { | 545 if (resultType == null) { |
| 562 » » statusDiv2.appendChild(document.createTextNode("Success")); | 546 statusDiv2.appendChild(document.createTextNode("Success")); |
| 563 } else { | 547 } else { |
| 564 » » statusDiv2.appendChild(document.createTextNode(resultType)); | 548 statusDiv2.appendChild(document.createTextNode(resultType)); |
| 565 » » if (resultType == "skip") { | 549 if (resultType == "skip") { |
| 566 » » style = "color:blue"; | 550 style = "color:blue"; |
| 567 » » } else { | 551 } else { |
| 568 » » style = "color:red"; | 552 style = "color:red"; |
| 569 » » } | 553 } |
| 570 } | 554 } |
| 571 newTable.setAttributeNS(null, "style", style); | 555 newTable.setAttributeNS(null, "style", style); |
| 572 if (message != null) { | 556 if (message != null) { |
| 573 var messageRow = newTable.insertRow(-1); | 557 var messageRow = newTable.insertRow(-1); |
| 574 » var messageDiv1 = messageRow.insertCell(-1); | 558 var messageDiv1 = messageRow.insertCell(-1); |
| 575 messageDiv1.appendChild(document.createTextNode("Message")); | 559 messageDiv1.appendChild(document.createTextNode("Message")); |
| 576 var messageDiv2 = messageRow.insertCell(-1); | 560 var messageDiv2 = messageRow.insertCell(-1); |
| 577 messageDiv2.appendChild(document.createTextNode((message instanceof Error)
? ("Line " + message.line + ": " + message.name) : message)); | 561 messageDiv2.appendChild(document.createTextNode((message instanceof Error)
? ("Line " + message.line + ": " + message.name) : message)); |
| 578 } | 562 } |
| 579 var oldBody = document.getElementsByTagName("body")[0]; | 563 var oldBody = document.getElementsByTagName("body")[0]; |
| 580 oldBody.parentNode.replaceChild(newBody, oldBody); | 564 oldBody.parentNode.replaceChild(newBody, oldBody); |
| 581 if (parent != window && typeof(parent.setResult) != 'undefined') { | 565 if (parent != window && typeof(parent.setResult) != 'undefined') { |
| 582 parent.setResult(testName, resultType, message); | 566 parent.setResult(testName, resultType, message); |
| 583 } | 567 } |
| 584 } | 568 } |
| 585 | 569 |
| 586 function checkInitialization(buildr, testname) { | 570 function checkInitialization(buildr, testname) { |
| 587 return buildr.initializationError; | 571 return buildr.initializationError; |
| 588 } | 572 } |
| 589 | 573 |
| 590 function preload(docRef, varname, href) { | 574 function preload(docRef, varname, href) { |
| 591 return builder.preload(docRef, varname, href); | 575 return builder.preload(docRef, varname, href); |
| 592 } | 576 } |
| 593 | 577 |
| 594 | |
| 595 function load(docRef, varname, href) { | 578 function load(docRef, varname, href) { |
| 596 return builder.load(docRef, varname, href); | 579 return builder.load(docRef, varname, href); |
| 597 } | 580 } |
| 598 | 581 |
| 599 | |
| 600 function getImplementationAttribute(attr) { | 582 function getImplementationAttribute(attr) { |
| 601 return builder.getImplementationAttribute(attr); | 583 return builder.getImplementationAttribute(attr); |
| 602 } | 584 } |
| 603 | 585 |
| 604 | |
| 605 function setImplementationAttribute(attribute, value) { | 586 function setImplementationAttribute(attribute, value) { |
| 606 builder.setImplementationAttribute(attribute, value); | 587 builder.setImplementationAttribute(attribute, value); |
| 607 } | 588 } |
| 608 | 589 |
| 609 function createXPathEvaluator(doc) { | 590 function createXPathEvaluator(doc) { |
| 610 try { | 591 try { |
| 611 return doc.getFeature("XPath", null); | 592 return doc.getFeature("XPath", null); |
| 612 } | 593 } |
| 613 catch(ex) { | 594 catch(ex) { |
| 614 } | 595 } |
| 615 return doc; | 596 return doc; |
| 616 } | 597 } |
| 617 | 598 |
| 618 | |
| 619 function getImplementation() { | 599 function getImplementation() { |
| 620 return builder.getImplementation(); | 600 return builder.getImplementation(); |
| 621 } | 601 } |
| 622 | 602 |
| 623 function assertEquals(id, expected, actual) { | 603 function assertEquals(id, expected, actual) { |
| 624 var myActual; | 604 var myActual; |
| 625 if (expected != actual) { | 605 if (expected != actual) { |
| 626 myActual = actual; | 606 myActual = actual; |
| 627 if (actual == null) { | 607 if (actual == null) { |
| 628 myActual = "null"; | 608 myActual = "null"; |
| 629 } | 609 } |
| 630 throw "failure:" + id + ": assertEquals failed, actual " + myActual + ",
expected " + expected + "."; | 610 throw "failure:" + id + ": assertEquals failed, actual " + myActual + ",
expected " + expected + "."; |
| 631 } | 611 } |
| 632 } | 612 } |
| 633 | 613 |
| 634 function assertNull(id, actual) { | 614 function assertNull(id, actual) { |
| 635 if (actual != null) { | 615 if (actual != null) { |
| 636 throw "failure:" + id + ": assertNull failed, actual " + actual; | 616 throw "failure:" + id + ": assertNull failed, actual " + actual; |
| 637 } | 617 } |
| 638 } | 618 } |
| 639 | 619 |
| 640 | |
| 641 function assertTrue(id, actual) { | 620 function assertTrue(id, actual) { |
| 642 if (!actual) { | 621 if (!actual) { |
| 643 throw "failure:" + id + ": assertTrue failed"; | 622 throw "failure:" + id + ": assertTrue failed"; |
| 644 } | 623 } |
| 645 } | 624 } |
| 646 | 625 |
| 647 | |
| 648 function assertFalse(id, actual) { | 626 function assertFalse(id, actual) { |
| 649 if (actual) { | 627 if (actual) { |
| 650 throw "failure:" + id + ": assertTrue failed"; | 628 throw "failure:" + id + ": assertTrue failed"; |
| 651 } | 629 } |
| 652 } | 630 } |
| 653 | 631 |
| 654 function assertNotNull(id, actual) { | 632 function assertNotNull(id, actual) { |
| 655 if (actual == null) { | 633 if (actual == null) { |
| 656 throw "failure:" + id + ": assertNotNull failed"; | 634 throw "failure:" + id + ": assertNotNull failed"; |
| 657 } | 635 } |
| 658 } | 636 } |
| 659 | 637 |
| 660 function fail(id) { | 638 function fail(id) { |
| 661 throw "failure:" + id + ": fail"; | 639 throw "failure:" + id + ": fail"; |
| 662 } | 640 } |
| 663 | 641 |
| 664 | |
| 665 | |
| 666 function getSuffix(contentType) { | 642 function getSuffix(contentType) { |
| 667 switch(contentType) { | 643 switch(contentType) { |
| 668 case "text/html": | 644 case "text/html": |
| 669 return ".html"; | 645 return ".html"; |
| 670 | 646 |
| 671 case "text/xml": | 647 case "text/xml": |
| 672 return ".xml"; | 648 return ".xml"; |
| 673 | 649 |
| 674 case "image/svg+xml": | 650 case "image/svg+xml": |
| 675 return ".svg"; | 651 return ".svg"; |
| 676 | 652 |
| 677 case "text/mathml": | 653 case "text/mathml": |
| 678 return ".mml"; | 654 return ".mml"; |
| 679 } | 655 } |
| 680 return ".xhtml"; | 656 return ".xhtml"; |
| 681 } | 657 } |
| 682 | 658 |
| 683 | |
| 684 function getResourceURI(name, scheme, contentType) { | 659 function getResourceURI(name, scheme, contentType) { |
| 685 var base = document.documentURI; | 660 var base = document.documentURI; |
| 686 if (base == null) { | 661 if (base == null) { |
| 687 base = ""; | 662 base = ""; |
| 688 } else { | 663 } else { |
| 689 » base = base.substring(0, base.lastIndexOf('/') + 1) + "files/"; | 664 base = base.substring(0, base.lastIndexOf('/') + 1) + "files/"; |
| 690 } | 665 } |
| 691 return base + name + getSuffix(contentType); | 666 return base + name + getSuffix(contentType); |
| 692 } | 667 } |
| 693 | 668 |
| 694 | |
| 695 | |
| 696 function startTest() { | 669 function startTest() { |
| 697 | 670 |
| 698 // | 671 // |
| 699 // WebKit modification: 18-August-2005 | 672 // WebKit modification: 18-August-2005 |
| 700 // | 673 // |
| 701 // Inform the test controller that this test has a text-format result and so sh
ould | 674 // Inform the test controller that this test has a text-format result and so sh
ould |
| 702 // be dumped as text, and also that the dump should not occur automatically. | 675 // be dumped as text, and also that the dump should not occur automatically. |
| 703 // | 676 // |
| 704 if (window.testRunner) { | 677 if (window.testRunner) { |
| 705 testRunner.dumpAsText(); | 678 testRunner.dumpAsText(); |
| 706 testRunner.waitUntilDone(); | 679 testRunner.waitUntilDone(); |
| 707 } | 680 } |
| 708 // | 681 // |
| 709 // End WebKit modification | 682 // End WebKit modification |
| 710 // | 683 // |
| 711 | 684 |
| 712 » // | 685 // |
| 713 » // invoke test setup | 686 // invoke test setup |
| 714 » // | 687 // |
| 715 » setUpPage(); | 688 setUpPage(); |
| 716 » try { | 689 try { |
| 717 » runTest(); | 690 runTest(); |
| 718 » if (builder.initializationError == null) { | 691 if (builder.initializationError == null) { |
| 719 » setResult(null, null); | 692 setResult(null, null); |
| 720 » } else { | 693 } else { |
| 721 » setResult("skip", builder.initializationError); | 694 setResult("skip", builder.initializationError); |
| 722 » } | 695 } |
| 723 » } catch(ex) { | 696 } catch(ex) { |
| 724 » if (typeof(ex.substring) != 'undefined' && ex.substring(0, 8) == "fa
ilure:") { | 697 if (typeof(ex.substring) != 'undefined' && ex.substring(0, 8) == "failur
e:") { |
| 725 setResult("failure", ex.substring(8)); | 698 setResult("failure", ex.substring(8)); |
| 726 } else { | 699 } else { |
| 727 setResult("error", ex); | 700 setResult("error", ex); |
| 728 } | 701 } |
| 729 } | 702 } |
| 730 | 703 |
| 731 // | 704 // |
| 732 // WebKit modification: 18-August-2005 | 705 // WebKit modification: 18-August-2005 |
| 733 // | 706 // |
| 734 // Inform the test controller that this test is complete, so it's time to dump. | 707 // Inform the test controller that this test is complete, so it's time to dump. |
| 735 // | 708 // |
| 736 if (window.testRunner) { | 709 if (window.testRunner) { |
| 737 testRunner.notifyDone(); | 710 testRunner.notifyDone(); |
| 738 } | 711 } |
| 739 // | 712 // |
| 740 // End WebKit modification | 713 // End WebKit modification |
| 741 // | 714 // |
| 742 | 715 |
| 743 } | 716 } |
| OLD | NEW |