| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 Copyright (c) 2001-2005 World Wide Web Consortium, | |
| 3 (Massachusetts Institute of Technology, European Research Consortium | |
| 4 for Informatics and Mathematics, Keio University). All | |
| 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 | |
| 7 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 8 | |
| 9 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 | |
| 10 */ | |
| 11 | |
| 12 function assertSize(descr, expected, actual) { | |
| 13 var actualSize; | |
| 14 assertNotNull(descr, actual); | |
| 15 actualSize = actual.length; | |
| 16 assertEquals(descr, expected, actualSize); | |
| 17 } | |
| 18 | |
| 19 function assertEqualsAutoCase(context, descr, expected, actual) { | |
| 20 if (builder.contentType == "text/html") { | |
| 21 if(context == "attribute") { | |
| 22 assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()); | |
| 23 } else { | |
| 24 assertEquals(descr, expected.toUpperCase(), actual); | |
| 25 } | |
| 26 } else { | |
| 27 assertEquals(descr, expected, actual); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 function assertEqualsCollectionAutoCase(context, descr, expected, actual) { | |
| 32 // | |
| 33 // if they aren't the same size, they aren't equal | |
| 34 assertEquals(descr, expected.length, actual.length); | |
| 35 | |
| 36 // | |
| 37 // if there length is the same, then every entry in the expected list | |
| 38 // must appear once and only once in the actual list | |
| 39 var expectedLen = expected.length; | |
| 40 var expectedValue; | |
| 41 var actualLen = actual.length; | |
| 42 var i; | |
| 43 var j; | |
| 44 var matches; | |
| 45 for(i = 0; i < expectedLen; i++) { | |
| 46 matches = 0; | |
| 47 expectedValue = expected[i]; | |
| 48 for(j = 0; j < actualLen; j++) { | |
| 49 if (builder.contentType == "text/html") { | |
| 50 if (context == "attribute") { | |
| 51 if (expectedValue.toLowerCase() == actual[j].toLowerCase())
{ | |
| 52 matches++; | |
| 53 } | |
| 54 } else { | |
| 55 if (expectedValue.toUpperCase() == actual[j]) { | |
| 56 matches++; | |
| 57 } | |
| 58 } | |
| 59 } else { | |
| 60 if(expectedValue == actual[j]) { | |
| 61 matches++; | |
| 62 } | |
| 63 } | |
| 64 } | |
| 65 if(matches == 0) { | |
| 66 assert(descr + ": No match found for " + expectedValue,false); | |
| 67 } | |
| 68 if(matches > 1) { | |
| 69 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); | |
| 70 } | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 function assertEqualsCollection(descr, expected, actual) { | |
| 75 // | |
| 76 // if they aren't the same size, they aren't equal | |
| 77 assertEquals(descr, expected.length, actual.length); | |
| 78 // | |
| 79 // if there length is the same, then every entry in the expected list | |
| 80 // must appear once and only once in the actual list | |
| 81 var expectedLen = expected.length; | |
| 82 var expectedValue; | |
| 83 var actualLen = actual.length; | |
| 84 var i; | |
| 85 var j; | |
| 86 var matches; | |
| 87 for(i = 0; i < expectedLen; i++) { | |
| 88 matches = 0; | |
| 89 expectedValue = expected[i]; | |
| 90 for(j = 0; j < actualLen; j++) { | |
| 91 if(expectedValue == actual[j]) { | |
| 92 matches++; | |
| 93 } | |
| 94 } | |
| 95 if(matches == 0) { | |
| 96 assert(descr + ": No match found for " + expectedValue,false); | |
| 97 } | |
| 98 if(matches > 1) { | |
| 99 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); | |
| 100 } | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 function assertEqualsListAutoCase(context, descr, expected, actual) { | |
| 105 var minLength = expected.length; | |
| 106 if (actual.length < minLength) { | |
| 107 minLength = actual.length; | |
| 108 } | |
| 109 // | |
| 110 for(var i = 0; i < minLength; i++) { | |
| 111 assertEqualsAutoCase(context, descr, expected[i], actual[i]); | |
| 112 } | |
| 113 // | |
| 114 // if they aren't the same size, they aren't equal | |
| 115 assertEquals(descr, expected.length, actual.length); | |
| 116 } | |
| 117 | |
| 118 function assertEqualsList(descr, expected, actual) { | |
| 119 var minLength = expected.length; | |
| 120 if (actual.length < minLength) { | |
| 121 minLength = actual.length; | |
| 122 } | |
| 123 // | |
| 124 for(var i = 0; i < minLength; i++) { | |
| 125 if(expected[i] != actual[i]) { | |
| 126 assertEquals(descr, expected[i], actual[i]); | |
| 127 } | |
| 128 } | |
| 129 // | |
| 130 // if they aren't the same size, they aren't equal | |
| 131 assertEquals(descr, expected.length, actual.length); | |
| 132 } | |
| 133 | |
| 134 function assertInstanceOf(descr, type, obj) { | |
| 135 if(type == "Attr") { | |
| 136 assertEquals(descr,2,obj.nodeType); | |
| 137 var specd = obj.specified; | |
| 138 } | |
| 139 } | |
| 140 | |
| 141 function assertSame(descr, expected, actual) { | |
| 142 if(expected != actual) { | |
| 143 assertEquals(descr, expected.nodeType, actual.nodeType); | |
| 144 assertEquals(descr, expected.nodeValue, actual.nodeValue); | |
| 145 } | |
| 146 } | |
| 147 | |
| 148 function assertURIEquals(assertID, scheme, path, host, file, name, query, frag
ment, isAbsolute, actual) { | |
| 149 // | |
| 150 // URI must be non-null | |
| 151 assertNotNull(assertID, actual); | |
| 152 | |
| 153 var uri = actual; | |
| 154 | |
| 155 var lastPound = actual.lastIndexOf("#"); | |
| 156 var actualFragment = ""; | |
| 157 if(lastPound != -1) { | |
| 158 // | |
| 159 // substring before pound | |
| 160 // | |
| 161 uri = actual.substring(0,lastPound); | |
| 162 actualFragment = actual.substring(lastPound+1); | |
| 163 } | |
| 164 if(fragment != null) assertEquals(assertID,fragment, actualFragment); | |
| 165 | |
| 166 var lastQuestion = uri.lastIndexOf("?"); | |
| 167 var actualQuery = ""; | |
| 168 if(lastQuestion != -1) { | |
| 169 // | |
| 170 // substring before pound | |
| 171 // | |
| 172 uri = actual.substring(0,lastQuestion); | |
| 173 actualQuery = actual.substring(lastQuestion+1); | |
| 174 } | |
| 175 if(query != null) assertEquals(assertID, query, actualQuery); | |
| 176 | |
| 177 var firstColon = uri.indexOf(":"); | |
| 178 var firstSlash = uri.indexOf("/"); | |
| 179 var actualPath = uri; | |
| 180 var actualScheme = ""; | |
| 181 if(firstColon != -1 && firstColon < firstSlash) { | |
| 182 actualScheme = uri.substring(0,firstColon); | |
| 183 actualPath = uri.substring(firstColon + 1); | |
| 184 } | |
| 185 | |
| 186 if(scheme != null) { | |
| 187 assertEquals(assertID, scheme, actualScheme); | |
| 188 } | |
| 189 | |
| 190 if(path != null) { | |
| 191 assertEquals(assertID, path, actualPath); | |
| 192 } | |
| 193 | |
| 194 if(host != null) { | |
| 195 var actualHost = ""; | |
| 196 if(actualPath.substring(0,2) == "//") { | |
| 197 var termSlash = actualPath.substring(2).indexOf("/") + 2; | |
| 198 actualHost = actualPath.substring(0,termSlash); | |
| 199 } | |
| 200 assertEquals(assertID, host, actualHost); | |
| 201 } | |
| 202 | |
| 203 if(file != null || name != null) { | |
| 204 var actualFile = actualPath; | |
| 205 var finalSlash = actualPath.lastIndexOf("/"); | |
| 206 if(finalSlash != -1) { | |
| 207 actualFile = actualPath.substring(finalSlash+1); | |
| 208 } | |
| 209 if (file != null) { | |
| 210 assertEquals(assertID, file, actualFile); | |
| 211 } | |
| 212 if (name != null) { | |
| 213 var actualName = actualFile; | |
| 214 var finalDot = actualFile.lastIndexOf("."); | |
| 215 if (finalDot != -1) { | |
| 216 actualName = actualName.substring(0, finalDot); | |
| 217 } | |
| 218 assertEquals(assertID, name, actualName); | |
| 219 } | |
| 220 } | |
| 221 | |
| 222 if(isAbsolute != null) { | |
| 223 assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); | |
| 224 } | |
| 225 } | |
| 226 | |
| 227 // size() used by assertSize element | |
| 228 function size(collection) | |
| 229 { | |
| 230 return collection.length; | |
| 231 } | |
| 232 | |
| 233 function same(expected, actual) | |
| 234 { | |
| 235 return expected === actual; | |
| 236 } | |
| 237 | |
| 238 function equalsAutoCase(context, expected, actual) { | |
| 239 if (builder.contentType == "text/html") { | |
| 240 if (context == "attribute") { | |
| 241 return expected.toLowerCase() == actual; | |
| 242 } | |
| 243 return expected.toUpperCase() == actual; | |
| 244 } | |
| 245 return expected == actual; | |
| 246 } | |
| 247 | |
| 248 function createTempURI(scheme) { | |
| 249 if (scheme == "http") { | |
| 250 return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() *
100000) + ".xml"; | |
| 251 } | |
| 252 return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml"; | |
| 253 } | |
| 254 | |
| 255 function EventMonitor() { | |
| 256 this.atEvents = new Array(); | |
| 257 this.bubbledEvents = new Array(); | |
| 258 this.capturedEvents = new Array(); | |
| 259 this.allEvents = new Array(); | |
| 260 } | |
| 261 | |
| 262 EventMonitor.prototype.handleEvent = function(evt) { | |
| 263 switch(evt.eventPhase) { | |
| 264 case 1: | |
| 265 monitor.capturedEvents[monitor.capturedEvents.length] = evt; | |
| 266 break; | |
| 267 | |
| 268 case 2: | |
| 269 monitor.atEvents[monitor.atEvents.length] = evt; | |
| 270 break; | |
| 271 | |
| 272 case 3: | |
| 273 monitor.bubbledEvents[monitor.bubbledEvents.length] = evt; | |
| 274 break; | |
| 275 } | |
| 276 monitor.allEvents[monitor.allEvents.length] = evt; | |
| 277 } | |
| 278 | |
| 279 function DOMErrorImpl(err) { | |
| 280 this.severity = err.severity; | |
| 281 this.message = err.message; | |
| 282 this.type = err.type; | |
| 283 this.relatedException = err.relatedException; | |
| 284 this.relatedData = err.relatedData; | |
| 285 this.location = err.location; | |
| 286 } | |
| 287 | |
| 288 function DOMErrorMonitor() { | |
| 289 this.allErrors = new Array(); | |
| 290 } | |
| 291 | |
| 292 DOMErrorMonitor.prototype.handleError = function(err) { | |
| 293 errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err
); | |
| 294 } | |
| 295 | |
| 296 DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) { | |
| 297 var i; | |
| 298 for (i = 0; i < this.allErrors.length; i++) { | |
| 299 if (this.allErrors[i].severity >= severity) { | |
| 300 assertEquals(id, severity - 1, this.allErrors[i].severity); | |
| 301 } | |
| 302 } | |
| 303 } | |
| 304 | |
| 305 function UserDataNotification(operation, key, data, src, dst) { | |
| 306 this.operation = operation; | |
| 307 this.key = key; | |
| 308 this.data = data; | |
| 309 this.src = src; | |
| 310 this.dst = dst; | |
| 311 } | |
| 312 | |
| 313 function UserDataMonitor() { | |
| 314 this.allNotifications = new Array(); | |
| 315 } | |
| 316 | |
| 317 UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) { | |
| 318 userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] = | |
| 319 new UserDataNotification(operation, key, data, src, dst); | |
| 320 } | |
| 321 | |
| 322 function HTMLBuilder() { | |
| 323 this.contentType = "text/html"; | |
| 324 this.supportedContentTypes = [ "text/html" ]; | |
| 325 | |
| 326 this.supportsAsyncChange = false; | |
| 327 this.async = false; | |
| 328 this.fixedAttributeNames = [ | |
| 329 "validating", "expandEntityReferences", "coalescing", | |
| 330 "signed", "hasNullString", "ignoringElementContentWhitespace", "namespac
eAware", "ignoringComments", "schemaValidating"]; | |
| 331 | |
| 332 this.fixedAttributeValues = [false, true, false, true, true , false, false,
false, false ]; | |
| 333 this.configurableAttributeNames = [ ]; | |
| 334 this.configurableAttributeValues = [ ]; | |
| 335 this.initializationError = null; | |
| 336 this.initializationFatalError = null; | |
| 337 this.skipIncompatibleTests = true; | |
| 338 this.documentURLs = new Array(); | |
| 339 this.documentVarnames = new Array(); | |
| 340 } | |
| 341 | |
| 342 HTMLBuilder.prototype.hasFeature = function(feature, version) { | |
| 343 return document.implementation.hasFeature(feature, version); | |
| 344 } | |
| 345 | |
| 346 HTMLBuilder.prototype.getImplementation = function() { | |
| 347 return document.implementation; | |
| 348 } | |
| 349 | |
| 350 HTMLBuilder.prototype.preload = function(frame, varname, url) { | |
| 351 var i; | |
| 352 this.documentVarnames[this.documentVarnames.length] = varname; | |
| 353 this.documentURLs[this.documentURLs.length] = url; | |
| 354 if (this.documentURLs.length > 1) { | |
| 355 // | |
| 356 // if all the urls are not the same | |
| 357 // | |
| 358 for (i = 1; i < this.documentURLs.length; i++) { | |
| 359 if (this.documentURLs[i] != this.documentURLs[0]) { | |
| 360 throw "Tests with multiple loads of different documents are not cur
rently supported"; | |
| 361 } | |
| 362 } | |
| 363 } | |
| 364 return 1; | |
| 365 } | |
| 366 | |
| 367 HTMLBuilder.prototype.cloneNode = function(srcNode, doc) { | |
| 368 var clone = null; | |
| 369 switch(srcNode.nodeType) { | |
| 370 // | |
| 371 // element | |
| 372 case 1: | |
| 373 clone = doc.createElement(srcNode.nodeName.toLowerCase()); | |
| 374 var attrs = srcNode.attributes; | |
| 375 for(var i = 0; i < attrs.length; i++) { | |
| 376 var srcAttr = attrs.item(i); | |
| 377 clone.setAttribute(srcAttr.nodeName, srcAttr.nodeValue); | |
| 378 } | |
| 379 var srcChild = srcNode.firstChild; | |
| 380 while(srcChild != null) { | |
| 381 var cloneChild = this.cloneNode(srcChild, doc); | |
| 382 if (cloneChild != null) { | |
| 383 clone.appendChild(cloneChild); | |
| 384 } | |
| 385 srcChild = srcChild.nextSibling; | |
| 386 } | |
| 387 break; | |
| 388 | |
| 389 case 3: | |
| 390 clone = doc.createTextNode(srcNode.nodeValue); | |
| 391 break; | |
| 392 | |
| 393 case 4: | |
| 394 clone = doc.createCDATASection(srcNode.nodeValue); | |
| 395 break; | |
| 396 | |
| 397 case 7: | |
| 398 clone = doc.createProcessingInstruction(srcNode.nodeValue); | |
| 399 break; | |
| 400 | |
| 401 case 8: | |
| 402 clone = doc.createComment(srcNode.nodeValue); | |
| 403 break; | |
| 404 } | |
| 405 return clone; | |
| 406 | |
| 407 } | |
| 408 | |
| 409 HTMLBuilder.prototype.load = function(frame, varname, url) { | |
| 410 if (this.documentVarnames[0] == varname) { | |
| 411 return document; | |
| 412 } | |
| 413 // | |
| 414 // | |
| 415 // not a perfect way to do this | |
| 416 // Document.cloneNode is implementation dependent but exists in L1 | |
| 417 // and implemented in IE. The alternative brute force copy | |
| 418 // only works in L2 or higher implementations and can't copy | |
| 419 // entity and notation definitions, etc. | |
| 420 var clone = null; | |
| 421 try { | |
| 422 clone = document.cloneNode(true); | |
| 423 } catch(ex) { | |
| 424 } | |
| 425 if (clone == null) { | |
| 426 clone = document.implementation.createDocument( | |
| 427 document.documentElement.namespaceURI, | |
| 428 document.documentElement.nodeName, | |
| 429 null); | |
| 430 // | |
| 431 // Work-around since | |
| 432 // Safari does not create document element | |
| 433 // create document. | |
| 434 if (clone.documentElement == null) { | |
| 435 clone.appendChild(clone.createElement(document.documentElement.nodeNa
me)); | |
| 436 } | |
| 437 var attrs = document.documentElement.attributes; | |
| 438 for(var i = 0; i < attrs.length; i++) { | |
| 439 var srcAttr = attrs.item(i); | |
| 440 clone.documentElement.setAttribute(srcAttr.nodeName, srcAttr.nodeValue
); | |
| 441 } | |
| 442 | |
| 443 var srcNode = document.firstChild; | |
| 444 while(srcNode != null && srcNode.nodeType != 1) { | |
| 445 if (srcNode.nodeType != 10) { | |
| 446 var cloneNode = this.cloneNode(srcNode, clone); | |
| 447 clone.insertBefore(cloneNode, clone.documentElement); | |
| 448 } | |
| 449 srcNode = srcNode.nextSibling; | |
| 450 } | |
| 451 srcNode = document.documentElement.nextSibling; | |
| 452 while(srcNode != null) { | |
| 453 var cloneNode = this.cloneNode(srcNode, clone); | |
| 454 clone.appendChild(cloneNode); | |
| 455 srcNode = srcNode.nextSibling; | |
| 456 } | |
| 457 srcNode = document.documentElement.firstChild; | |
| 458 while(srcNode != null) { | |
| 459 var cloneNode = this.cloneNode(srcNode, clone); | |
| 460 if (cloneNode != null) { | |
| 461 clone.documentElement.appendChild(cloneNode); | |
| 462 } | |
| 463 srcNode = srcNode.nextSibling; | |
| 464 } | |
| 465 } | |
| 466 return clone; | |
| 467 } | |
| 468 | |
| 469 HTMLBuilder.prototype.getImplementationAttribute = function(attr) { | |
| 470 for (var i = 0; i < this.fixedAttributeNames.length; i++) { | |
| 471 if (this.fixedAttributeNames[i] == attr) { | |
| 472 return this.fixedAttributeValues[i]; | |
| 473 } | |
| 474 } | |
| 475 throw "Unrecognized implementation attribute: " + attr; | |
| 476 } | |
| 477 | |
| 478 HTMLBuilder.prototype.setImplementationAttribute = function(attribute, value) { | |
| 479 var supported = this.getImplementationAttribute(attribute); | |
| 480 if (supported != value) { | |
| 481 this.initializationError = "HTML loader does not support " + attribute +
"=" + value; | |
| 482 } | |
| 483 } | |
| 484 | |
| 485 HTMLBuilder.prototype.canSetImplementationAttribute = function(attribute, value)
{ | |
| 486 var supported = this.getImplementationAttribute(attribute); | |
| 487 return (supported == value); | |
| 488 } | |
| 489 | |
| 490 function createConfiguredBuilder() { | |
| 491 return new HTMLBuilder(); | |
| 492 } | |
| 493 | |
| 494 function catchInitializationError(buildr, ex) { | |
| 495 buildr.initializationError = ex; | |
| 496 buildr.initializationFatalError = ex; | |
| 497 } | |
| 498 | |
| 499 function toLowerArray(src) { | |
| 500 var newArray = new Array(); | |
| 501 var i; | |
| 502 for (i = 0; i < src.length; i++) { | |
| 503 newArray[i] = src[i].toLowerCase(); | |
| 504 } | |
| 505 return newArray; | |
| 506 } | |
| 507 | |
| 508 function checkFeature(feature, version) | |
| 509 { | |
| 510 if (!builder.hasFeature(feature, version)) | |
| 511 { | |
| 512 // | |
| 513 // don't throw exception so that users can select to ignore the preconditi
on | |
| 514 // | |
| 515 builder.initializationError = "builder does not support feature " + feature
+ " version " + version; | |
| 516 } | |
| 517 } | |
| 518 | |
| 519 function setResult(resultType, message) { | |
| 520 var testName = getTargetURI(); | |
| 521 document.open(); | |
| 522 document.writeln("<html><head>"); | |
| 523 document.writeln("<meta HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET
=utf-8'>"); | |
| 524 document.write("<title>"); | |
| 525 document.write(testName + ":" + resultType); | |
| 526 document.write("</title></head><body><table width='100%' border='1' style='co
lor:"); | |
| 527 if (resultType == null) { | |
| 528 document.writeln("green'><tr><td>Test:</td><td>" + testName + "</td></tr><
tr><td>Status:</td><td>Success</td></tr>"); | |
| 529 } else { | |
| 530 if (resultType == "skip") { | |
| 531 document.writeln("blue'><tr><td>Test:</td><td>" + testName + "</td></t
r><tr><td>Status:</td><td>Skipped</td></tr>"); | |
| 532 } else { | |
| 533 document.writeln("red'><tr><td>Test:</td><td>" + testName + "</td><td></
tr><tr><td>Status:</td><td>" + resultType + "</td></tr>"); | |
| 534 } | |
| 535 } | |
| 536 if (message != null) { | |
| 537 document.writeln("<tr><td>Detail:</td><td>" + message + "</td></tr>")
; | |
| 538 } | |
| 539 document.write("</table></body></html>"); | |
| 540 document.close(); | |
| 541 if (parent != window) { | |
| 542 parent.setResult(testName, resultType, message); | |
| 543 } | |
| 544 } | |
| 545 | |
| 546 function checkInitialization(buildr, testname) { | |
| 547 return buildr.initializationError; | |
| 548 } | |
| 549 | |
| 550 function preload(docRef, varname, href) { | |
| 551 return builder.preload(docRef, varname, href); | |
| 552 } | |
| 553 | |
| 554 function load(docRef, varname, href) { | |
| 555 return builder.load(docRef, varname, href); | |
| 556 } | |
| 557 | |
| 558 function getImplementationAttribute(attr) { | |
| 559 return builder.getImplementationAttribute(attr); | |
| 560 } | |
| 561 | |
| 562 function setImplementationAttribute(attribute, value) { | |
| 563 builder.setImplementationAttribute(attribute, value); | |
| 564 } | |
| 565 | |
| 566 function createXPathEvaluator(doc) { | |
| 567 try { | |
| 568 return doc.getFeature("XPath", null); | |
| 569 } | |
| 570 catch(ex) { | |
| 571 } | |
| 572 return doc; | |
| 573 } | |
| 574 | |
| 575 function getImplementation() { | |
| 576 return builder.getImplementation(); | |
| 577 } | |
| 578 | |
| 579 function assertEquals(id, expected, actual) { | |
| 580 var myActual; | |
| 581 if (expected != actual) { | |
| 582 myActual = actual; | |
| 583 if (actual == null) { | |
| 584 myActual = "null"; | |
| 585 } | |
| 586 throw "failure:" + id + ": assertEquals failed, actual " + myActual + ",
expected " + expected + "."; | |
| 587 } | |
| 588 } | |
| 589 | |
| 590 function assertNull(id, actual) { | |
| 591 if (actual != null) { | |
| 592 throw "failure:" + id + ": assertNull failed, actual " + actual; | |
| 593 } | |
| 594 } | |
| 595 | |
| 596 function assertTrue(id, actual) { | |
| 597 if (!actual) { | |
| 598 throw "failure:" + id + ": assertTrue failed"; | |
| 599 } | |
| 600 } | |
| 601 | |
| 602 function assertFalse(id, actual) { | |
| 603 if (actual) { | |
| 604 throw "failure:" + id + ": assertTrue failed"; | |
| 605 } | |
| 606 } | |
| 607 | |
| 608 function assertNotNull(id, actual) { | |
| 609 if (actual == null) { | |
| 610 throw "failure:" + id + ": assertNotNull failed"; | |
| 611 } | |
| 612 } | |
| 613 | |
| 614 function fail(id) { | |
| 615 throw "failure:" + id + ": fail"; | |
| 616 } | |
| 617 | |
| 618 function getSuffix(contentType) { | |
| 619 switch(contentType) { | |
| 620 case "text/xml": | |
| 621 return ".xml"; | |
| 622 | |
| 623 case "application/xhtml+xml": | |
| 624 return ".xhtml"; | |
| 625 | |
| 626 case "image/svg+xml": | |
| 627 return ".svg"; | |
| 628 | |
| 629 case "text/mathml": | |
| 630 return ".mml"; | |
| 631 } | |
| 632 return ".html"; | |
| 633 } | |
| 634 | |
| 635 function getResourceURI(name, scheme, contentType) { | |
| 636 var base = document.documentURI; | |
| 637 if (base == null) { | |
| 638 base = ""; | |
| 639 } else { | |
| 640 base = base.substring(0, base.lastIndexOf('/') + 1) + "files/"; | |
| 641 } | |
| 642 return base + name + getSuffix(contentType); | |
| 643 } | |
| 644 | |
| 645 function startTest() { | |
| 646 | |
| 647 // | |
| 648 // WebKit modification: 18-August-2005 | |
| 649 // | |
| 650 // Inform the test controller that this test has a text-format result and so sh
ould | |
| 651 // be dumped as text, and also that the dump should not occur automatically. | |
| 652 // | |
| 653 if (window.testRunner) { | |
| 654 testRunner.dumpAsText(); | |
| 655 testRunner.waitUntilDone(); | |
| 656 } | |
| 657 // | |
| 658 // End WebKit modification | |
| 659 // | |
| 660 | |
| 661 // | |
| 662 // invoke test setup | |
| 663 // | |
| 664 setUpPage(); | |
| 665 | |
| 666 try { | |
| 667 runTest(); | |
| 668 if (builder.initializationError == null) { | |
| 669 setResult(null, null); | |
| 670 } else { | |
| 671 setResult("skip", builder.initializationError); | |
| 672 } | |
| 673 } catch(ex) { | |
| 674 if (typeof(ex.substring) != 'undefined' && ex.substring(0, 8) == "failur
e:") { | |
| 675 setResult("failure", ex.substring(8)); | |
| 676 } else { | |
| 677 setResult("error", ex); | |
| 678 } | |
| 679 } | |
| 680 | |
| 681 // | |
| 682 // WebKit modification: 18-August-2005 | |
| 683 // | |
| 684 // Inform the test controller that this test is complete, so it's time to dump. | |
| 685 // | |
| 686 if (window.testRunner) { | |
| 687 testRunner.notifyDone(); | |
| 688 } | |
| 689 // | |
| 690 // End WebKit modification | |
| 691 // | |
| 692 | |
| 693 } | |
| OLD | NEW |