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 /* Begin additions for WebKit layout test framework. */ | 12 /* Begin additions for WebKit layout test framework. */ |
13 if (window.testRunner) | 13 if (window.testRunner) |
14 testRunner.dumpAsText(); | 14 testRunner.dumpAsText(); |
15 /* End additions for WebKit layout test framework. */ | 15 /* End additions for WebKit layout test framework. */ |
16 | 16 |
17 | |
18 function assertSize(descr, expected, actual) { | 17 function assertSize(descr, expected, actual) { |
19 var actualSize; | 18 var actualSize; |
20 actualSize = actual.length; | 19 actualSize = actual.length; |
21 assertEquals(descr, expected, actualSize); | 20 assertEquals(descr, expected, actualSize); |
22 } | 21 } |
23 | 22 |
24 function assertEqualsAutoCase(context, descr, expected, actual) { | 23 function assertEqualsAutoCase(context, descr, expected, actual) { |
25 if (builder.contentType == "text/html") { | 24 if (builder.contentType == "text/html") { |
26 if(context == "attribute") { | 25 if(context == "attribute") { |
27 assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()); | 26 assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()); |
28 } else { | 27 } else { |
29 assertEquals(descr, expected.toUpperCase(), actual); | 28 assertEquals(descr, expected.toUpperCase(), actual); |
30 } | 29 } |
31 } else { | 30 } else { |
32 assertEquals(descr, expected, actual); | 31 assertEquals(descr, expected, actual); |
33 } | 32 } |
34 } | 33 } |
35 | |
36 | 34 |
37 function assertEqualsCollectionAutoCase(context, descr, expected, actual) { | 35 function assertEqualsCollectionAutoCase(context, descr, expected, actual) { |
38 // | 36 // |
39 // if they aren't the same size, they aren't equal | 37 // if they aren't the same size, they aren't equal |
40 assertEquals(descr, expected.length, actual.length); | 38 assertEquals(descr, expected.length, actual.length); |
41 | 39 |
42 // | 40 // |
43 // if there length is the same, then every entry in the expected list | 41 // if there length is the same, then every entry in the expected list |
44 // must appear once and only once in the actual list | 42 // must appear once and only once in the actual list |
45 var expectedLen = expected.length; | 43 var expectedLen = expected.length; |
46 var expectedValue; | 44 var expectedValue; |
47 var actualLen = actual.length; | 45 var actualLen = actual.length; |
48 var i; | 46 var i; |
49 var j; | 47 var j; |
50 var matches; | 48 var matches; |
51 for(i = 0; i < expectedLen; i++) { | 49 for(i = 0; i < expectedLen; i++) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 98 } |
101 if(matches == 0) { | 99 if(matches == 0) { |
102 assert(descr + ": No match found for " + expectedValue,false); | 100 assert(descr + ": No match found for " + expectedValue,false); |
103 } | 101 } |
104 if(matches > 1) { | 102 if(matches > 1) { |
105 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); | 103 assert(descr + ": Multiple matches found for " + expectedValue, fals
e); |
106 } | 104 } |
107 } | 105 } |
108 } | 106 } |
109 | 107 |
110 | |
111 function assertEqualsListAutoCase(context, descr, expected, actual) { | 108 function assertEqualsListAutoCase(context, descr, expected, actual) { |
112 var minLength = expected.length; | 109 var minLength = expected.length; |
113 if (actual.length < minLength) { | 110 if (actual.length < minLength) { |
114 minLength = actual.length; | 111 minLength = actual.length; |
115 } | 112 } |
116 // | 113 // |
117 for(var i = 0; i < minLength; i++) { | 114 for(var i = 0; i < minLength; i++) { |
118 assertEqualsAutoCase(context, descr, expected[i], actual[i]); | 115 assertEqualsAutoCase(context, descr, expected[i], actual[i]); |
119 } | 116 } |
120 // | 117 // |
121 // if they aren't the same size, they aren't equal | 118 // if they aren't the same size, they aren't equal |
122 assertEquals(descr, expected.length, actual.length); | 119 assertEquals(descr, expected.length, actual.length); |
123 } | 120 } |
124 | 121 |
125 | |
126 function assertEqualsList(descr, expected, actual) { | 122 function assertEqualsList(descr, expected, actual) { |
127 var minLength = expected.length; | 123 var minLength = expected.length; |
128 if (actual.length < minLength) { | 124 if (actual.length < minLength) { |
129 minLength = actual.length; | 125 minLength = actual.length; |
130 } | 126 } |
131 // | 127 // |
132 for(var i = 0; i < minLength; i++) { | 128 for(var i = 0; i < minLength; i++) { |
133 if(expected[i] != actual[i]) { | 129 if(expected[i] != actual[i]) { |
134 assertEquals(descr, expected[i], actual[i]); | 130 assertEquals(descr, expected[i], actual[i]); |
135 } | 131 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 221 } |
226 assertEquals(assertID, name, actualName); | 222 assertEquals(assertID, name, actualName); |
227 } | 223 } |
228 } | 224 } |
229 | 225 |
230 if(isAbsolute != null) { | 226 if(isAbsolute != null) { |
231 assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); | 227 assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); |
232 } | 228 } |
233 } | 229 } |
234 | 230 |
235 | |
236 // size() used by assertSize element | 231 // size() used by assertSize element |
237 function size(collection) | 232 function size(collection) |
238 { | 233 { |
239 return collection.length; | 234 return collection.length; |
240 } | 235 } |
241 | 236 |
242 function same(expected, actual) | 237 function same(expected, actual) |
243 { | 238 { |
244 return expected === actual; | 239 return expected === actual; |
245 } | 240 } |
246 | 241 |
247 function getSuffix(contentType) { | 242 function getSuffix(contentType) { |
248 return ".svg"; | 243 return ".svg"; |
249 } | 244 } |
250 | 245 |
251 function equalsAutoCase(context, expected, actual) { | 246 function equalsAutoCase(context, expected, actual) { |
252 if (builder.contentType == "text/html") { | 247 if (builder.contentType == "text/html") { |
253 if (context == "attribute") { | 248 if (context == "attribute") { |
254 return expected.toLowerCase() == actual; | 249 return expected.toLowerCase() == actual; |
255 } | 250 } |
256 return expected.toUpperCase() == actual; | 251 return expected.toUpperCase() == actual; |
257 } | 252 } |
258 return expected == actual; | 253 return expected == actual; |
259 } | 254 } |
260 | 255 |
261 | |
262 function createTempURI(scheme) { | 256 function createTempURI(scheme) { |
263 if (scheme == "http") { | 257 if (scheme == "http") { |
264 return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() *
100000) + ".xml"; | 258 return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() *
100000) + ".xml"; |
265 } | 259 } |
266 return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml"; | 260 return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml"; |
267 } | 261 } |
268 | 262 |
269 | |
270 function EventMonitor() { | 263 function EventMonitor() { |
271 this.atEvents = new Array(); | 264 this.atEvents = new Array(); |
272 this.bubbledEvents = new Array(); | 265 this.bubbledEvents = new Array(); |
273 this.capturedEvents = new Array(); | 266 this.capturedEvents = new Array(); |
274 this.allEvents = new Array(); | 267 this.allEvents = new Array(); |
275 } | 268 } |
276 | 269 |
277 EventMonitor.prototype.handleEvent = function(evt) { | 270 EventMonitor.prototype.handleEvent = function(evt) { |
278 switch(evt.eventPhase) { | 271 switch(evt.eventPhase) { |
279 case 1: | 272 case 1: |
280 monitor.capturedEvents[monitor.capturedEvents.length] = evt; | 273 monitor.capturedEvents[monitor.capturedEvents.length] = evt; |
281 break; | 274 break; |
282 | 275 |
283 case 2: | 276 case 2: |
284 monitor.atEvents[monitor.atEvents.length] = evt; | 277 monitor.atEvents[monitor.atEvents.length] = evt; |
285 break; | 278 break; |
286 | 279 |
287 case 3: | 280 case 3: |
288 monitor.bubbledEvents[monitor.bubbledEvents.length] = evt; | 281 monitor.bubbledEvents[monitor.bubbledEvents.length] = evt; |
289 break; | 282 break; |
290 } | 283 } |
291 monitor.allEvents[monitor.allEvents.length] = evt; | 284 monitor.allEvents[monitor.allEvents.length] = evt; |
292 } | 285 } |
293 | 286 |
294 function DOMErrorImpl(err) { | 287 function DOMErrorImpl(err) { |
295 this.severity = err.severity; | 288 this.severity = err.severity; |
296 this.message = err.message; | 289 this.message = err.message; |
297 this.type = err.type; | 290 this.type = err.type; |
298 this.relatedException = err.relatedException; | 291 this.relatedException = err.relatedException; |
299 this.relatedData = err.relatedData; | 292 this.relatedData = err.relatedData; |
300 this.location = err.location; | 293 this.location = err.location; |
301 } | 294 } |
302 | 295 |
303 | |
304 | |
305 function DOMErrorMonitor() { | 296 function DOMErrorMonitor() { |
306 this.allErrors = new Array(); | 297 this.allErrors = new Array(); |
307 } | 298 } |
308 | 299 |
309 DOMErrorMonitor.prototype.handleError = function(err) { | 300 DOMErrorMonitor.prototype.handleError = function(err) { |
310 errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err
); | 301 errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err
); |
311 } | 302 } |
312 | 303 |
313 DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) { | 304 DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) { |
314 var i; | 305 var i; |
(...skipping 14 matching lines...) Expand all Loading... |
329 | 320 |
330 function UserDataMonitor() { | 321 function UserDataMonitor() { |
331 this.allNotifications = new Array(); | 322 this.allNotifications = new Array(); |
332 } | 323 } |
333 | 324 |
334 UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) { | 325 UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) { |
335 userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] = | 326 userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] = |
336 new UserDataNotification(operation, key, data, src, dst); | 327 new UserDataNotification(operation, key, data, src, dst); |
337 } | 328 } |
338 | 329 |
339 | |
340 function toLowerArray(src) { | 330 function toLowerArray(src) { |
341 var newArray = new Array(); | 331 var newArray = new Array(); |
342 var i; | 332 var i; |
343 for (i = 0; i < src.length; i++) { | 333 for (i = 0; i < src.length; i++) { |
344 newArray[i] = src[i].toLowerCase(); | 334 newArray[i] = src[i].toLowerCase(); |
345 } | 335 } |
346 return newArray; | 336 return newArray; |
347 } | 337 } |
348 | 338 |
349 | |
350 | |
351 function SVGBuilder() { | 339 function SVGBuilder() { |
352 this.contentType = "image/svg+xml"; | 340 this.contentType = "image/svg+xml"; |
353 this.supportedContentTypes = [ "image/svg+xml" ]; | 341 this.supportedContentTypes = [ "image/svg+xml" ]; |
354 | 342 |
355 this.supportsAsyncChange = false; | 343 this.supportsAsyncChange = false; |
356 this.async = false; | 344 this.async = false; |
357 this.fixedAttributeNames = [ | 345 this.fixedAttributeNames = [ |
358 "validating", "expandEntityReferences", "coalescing", | 346 "validating", "expandEntityReferences", "coalescing", |
359 "signed", "hasNullString", "ignoringElementContentWhitespace", "namespac
eAware", "ignoringComments", "schemaValidating"]; | 347 "signed", "hasNullString", "ignoringElementContentWhitespace", "namespac
eAware", "ignoringComments", "schemaValidating"]; |
360 | 348 |
361 this.fixedAttributeValues = [false, true, false, true, true , false, true,
false, false ]; | 349 this.fixedAttributeValues = [false, true, false, true, true , false, true,
false, false ]; |
362 this.configurableAttributeNames = [ ]; | 350 this.configurableAttributeNames = [ ]; |
363 this.configurableAttributeValues = [ ]; | 351 this.configurableAttributeValues = [ ]; |
364 this.initializationError = null; | 352 this.initializationError = null; |
365 this.initializationFatalError = null; | 353 this.initializationFatalError = null; |
366 this.skipIncompatibleTests = true; | 354 this.skipIncompatibleTests = true; |
367 this.documentURLs = new Array(); | 355 this.documentURLs = new Array(); |
368 this.documentVarnames = new Array(); | 356 this.documentVarnames = new Array(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 397 } |
410 var srcChild = srcNode.firstChild; | 398 var srcChild = srcNode.firstChild; |
411 while(srcChild != null) { | 399 while(srcChild != null) { |
412 var cloneChild = this.cloneNode(srcChild, doc); | 400 var cloneChild = this.cloneNode(srcChild, doc); |
413 if (cloneChild != null) { | 401 if (cloneChild != null) { |
414 clone.appendChild(cloneChild); | 402 clone.appendChild(cloneChild); |
415 } | 403 } |
416 srcChild = srcChild.nextSibling; | 404 srcChild = srcChild.nextSibling; |
417 } | 405 } |
418 break; | 406 break; |
419 | 407 |
420 case 3: | 408 case 3: |
421 clone = doc.createTextNode(srcNode.nodeValue); | 409 clone = doc.createTextNode(srcNode.nodeValue); |
422 break; | 410 break; |
423 | 411 |
424 case 4: | 412 case 4: |
425 clone = doc.createCDATASection(srcNode.nodeValue); | 413 clone = doc.createCDATASection(srcNode.nodeValue); |
426 break; | 414 break; |
427 | 415 |
428 case 5: | 416 case 5: |
429 clone = doc.createEntityReference(srcNode.nodeName); | 417 clone = doc.createEntityReference(srcNode.nodeName); |
430 break; | 418 break; |
431 | 419 |
432 case 7: | 420 case 7: |
433 clone = doc.createProcessingInstruction(srcNode.target, srcNode.data); | 421 clone = doc.createProcessingInstruction(srcNode.target, srcNode.data); |
434 break; | 422 break; |
435 | 423 |
436 case 8: | 424 case 8: |
437 clone = doc.createComment(srcNode.nodeValue); | 425 clone = doc.createComment(srcNode.nodeValue); |
438 break; | 426 break; |
439 } | 427 } |
440 return clone; | 428 return clone; |
441 | 429 |
442 } | 430 } |
443 | 431 |
444 | |
445 SVGBuilder.prototype.load = function(frame, varname, url) { | 432 SVGBuilder.prototype.load = function(frame, varname, url) { |
446 req = new XMLHttpRequest; | 433 req = new XMLHttpRequest; |
447 req.open("GET", "resources/" + url + ".xml", false); | 434 req.open("GET", "resources/" + url + ".xml", false); |
448 req.send(null); | 435 req.send(null); |
449 return req.responseXML; | 436 return req.responseXML; |
450 } | 437 } |
451 | 438 |
452 SVGBuilder.prototype.getImplementationAttribute = function(attr) { | 439 SVGBuilder.prototype.getImplementationAttribute = function(attr) { |
453 for (var i = 0; i < this.fixedAttributeNames.length; i++) { | 440 for (var i = 0; i < this.fixedAttributeNames.length; i++) { |
454 if (this.fixedAttributeNames[i] == attr) { | 441 if (this.fixedAttributeNames[i] == attr) { |
455 return this.fixedAttributeValues[i]; | 442 return this.fixedAttributeValues[i]; |
456 } | 443 } |
457 } | 444 } |
458 throw "Unrecognized implementation attribute: " + attr; | 445 throw "Unrecognized implementation attribute: " + attr; |
459 } | 446 } |
460 | 447 |
461 | |
462 SVGBuilder.prototype.setImplementationAttribute = function(attribute, value) { | 448 SVGBuilder.prototype.setImplementationAttribute = function(attribute, value) { |
463 var supported = this.getImplementationAttribute(attribute); | 449 var supported = this.getImplementationAttribute(attribute); |
464 if (supported != value) { | 450 if (supported != value) { |
465 this.initializationError = "SVG loader does not support " + attribute +
"=" + value; | 451 this.initializationError = "SVG loader does not support " + attribute +
"=" + value; |
466 } | 452 } |
467 } | 453 } |
468 | 454 |
469 SVGBuilder.prototype.canSetImplementationAttribute = function(attribute, value)
{ | 455 SVGBuilder.prototype.canSetImplementationAttribute = function(attribute, value)
{ |
470 var supported = this.getImplementationAttribute(attribute); | 456 var supported = this.getImplementationAttribute(attribute); |
471 return (supported == value); | 457 return (supported == value); |
472 } | 458 } |
473 | 459 |
474 | |
475 | |
476 | |
477 function createConfiguredBuilder() { | 460 function createConfiguredBuilder() { |
478 return new SVGBuilder(); | 461 return new SVGBuilder(); |
479 } | 462 } |
480 | 463 |
481 function catchInitializationError(buildr, ex) { | 464 function catchInitializationError(buildr, ex) { |
482 buildr.initializationError = ex; | 465 buildr.initializationError = ex; |
483 buildr.initializationFatalError = ex; | 466 buildr.initializationFatalError = ex; |
484 } | 467 } |
485 | 468 |
486 | |
487 function checkFeature(feature, version) | 469 function checkFeature(feature, version) |
488 { | 470 { |
489 if (!builder.hasFeature(feature, version)) | 471 if (!builder.hasFeature(feature, version)) |
490 { | 472 { |
491 // | 473 // |
492 // don't throw exception so that users can select to ignore the preconditi
on | 474 // don't throw exception so that users can select to ignore the preconditi
on |
493 // | 475 // |
494 builder.initializationError = "builder does not support feature " + feature
+ " version " + version; | 476 builder.initializationError = "builder does not support feature " + feature
+ " version " + version; |
495 } | 477 } |
496 } | 478 } |
497 | 479 |
498 | |
499 function changeColor(color) { | 480 function changeColor(color) { |
500 document.getElementsByTagName("rect").item(0).setAttribute("style", "fill:" +
color); | 481 document.getElementsByTagName("rect").item(0).setAttribute("style", "fill:" +
color); |
501 } | 482 } |
502 | 483 |
503 function addMessage(x, y, msg) { | 484 function addMessage(x, y, msg) { |
504 var textElem = document.createElementNS("http://www.w3.org/2000/svg", "text")
; | 485 var textElem = document.createElementNS("http://www.w3.org/2000/svg", "text")
; |
505 textElem.setAttributeNS(null, "x", x); | 486 textElem.setAttributeNS(null, "x", x); |
506 textElem.setAttributeNS(null, "y", y); | 487 textElem.setAttributeNS(null, "y", y); |
507 textElem.appendChild(document.createTextNode(msg)); | 488 textElem.appendChild(document.createTextNode(msg)); |
508 document.documentElement.appendChild(textElem); | 489 document.documentElement.appendChild(textElem); |
509 } | 490 } |
510 | 491 |
511 function checkInitialization(buildr, testname) { | 492 function checkInitialization(buildr, testname) { |
512 if (buildr.initializationError != null) { | 493 if (buildr.initializationError != null) { |
513 addMessage("0", "160", buildr.initializationError); | 494 addMessage("0", "160", buildr.initializationError); |
514 changeColor("yellow"); | 495 changeColor("yellow"); |
515 } | 496 } |
516 return buildr.initializationError; | 497 return buildr.initializationError; |
517 } | 498 } |
518 | 499 |
519 function preload(docRef, varname, href) { | 500 function preload(docRef, varname, href) { |
520 return builder.preload(docRef, varname, href); | 501 return builder.preload(docRef, varname, href); |
521 } | 502 } |
522 | 503 |
523 | |
524 function load(docRef, varname, href) { | 504 function load(docRef, varname, href) { |
525 return builder.load(docRef, varname, href); | 505 return builder.load(docRef, varname, href); |
526 } | 506 } |
527 | 507 |
528 | |
529 function getImplementationAttribute(attr) { | 508 function getImplementationAttribute(attr) { |
530 return builder.getImplementationAttribute(attr); | 509 return builder.getImplementationAttribute(attr); |
531 } | 510 } |
532 | 511 |
533 | |
534 function setImplementationAttribute(attribute, value) { | 512 function setImplementationAttribute(attribute, value) { |
535 builder.setImplementationAttribute(attribute, value); | 513 builder.setImplementationAttribute(attribute, value); |
536 } | 514 } |
537 | 515 |
538 function createXPathEvaluator(doc) { | 516 function createXPathEvaluator(doc) { |
539 return doc; | 517 return doc; |
540 } | 518 } |
541 | 519 |
542 | |
543 function getImplementation() { | 520 function getImplementation() { |
544 return builder.getImplementation(); | 521 return builder.getImplementation(); |
545 } | 522 } |
546 | 523 |
547 | |
548 function assertEquals(id, expected, actual) { | 524 function assertEquals(id, expected, actual) { |
549 var myActual; | 525 var myActual; |
550 if (expected != actual) { | 526 if (expected != actual) { |
551 myActual = actual; | 527 myActual = actual; |
552 if (actual == null) { | 528 if (actual == null) { |
553 myActual = "null"; | 529 myActual = "null"; |
554 } | 530 } |
555 throw id + ": assertEquals failed, actual " + actual + ", expected " + ex
pected + "."; | 531 throw id + ": assertEquals failed, actual " + actual + ", expected " + ex
pected + "."; |
556 } | 532 } |
557 } | 533 } |
558 | 534 |
559 function assertNull(id, actual) { | 535 function assertNull(id, actual) { |
560 if (actual != null) { | 536 if (actual != null) { |
561 throw id + ": assertNull failed, actual " + actual; | 537 throw id + ": assertNull failed, actual " + actual; |
562 } | 538 } |
563 } | 539 } |
564 | 540 |
565 | |
566 function assertTrue(id, actual) { | 541 function assertTrue(id, actual) { |
567 if (!actual) { | 542 if (!actual) { |
568 throw id + ": assertTrue failed"; | 543 throw id + ": assertTrue failed"; |
569 } | 544 } |
570 } | 545 } |
571 | 546 |
572 function assert(id, actual) { | 547 function assert(id, actual) { |
573 if (!actual) { | 548 if (!actual) { |
574 throw id + ": assert failed"; | 549 throw id + ": assert failed"; |
575 } | 550 } |
576 } | 551 } |
577 | 552 |
578 | |
579 function assertFalse(id, actual) { | 553 function assertFalse(id, actual) { |
580 if (actual) { | 554 if (actual) { |
581 throw id + ": assertFalse failed"; | 555 throw id + ": assertFalse failed"; |
582 } | 556 } |
583 } | 557 } |
584 | 558 |
585 function assertNotNull(id, actual) { | 559 function assertNotNull(id, actual) { |
586 if (actual == null) { | 560 if (actual == null) { |
587 throw id + ": assertNotNull failed"; | 561 throw id + ": assertNotNull failed"; |
588 } | 562 } |
589 } | 563 } |
590 | 564 |
591 function fail(id) { | 565 function fail(id) { |
592 throw id + ": fail"; | 566 throw id + ": fail"; |
593 } | 567 } |
594 | 568 |
595 | |
596 function getSuffix(contentType) { | 569 function getSuffix(contentType) { |
597 switch(contentType) { | 570 switch(contentType) { |
598 case "text/html": | 571 case "text/html": |
599 return ".html"; | 572 return ".html"; |
600 | 573 |
601 case "application/xhtml+xml": | 574 case "application/xhtml+xml": |
602 return ".xhtml"; | 575 return ".xhtml"; |
603 | 576 |
604 case "image/svg+xml": | 577 case "image/svg+xml": |
605 return ".svg"; | 578 return ".svg"; |
606 | 579 |
607 case "text/mathml": | 580 case "text/mathml": |
608 return ".mml"; | 581 return ".mml"; |
609 } | 582 } |
610 return ".xml"; | 583 return ".xml"; |
611 } | 584 } |
612 | 585 |
613 | |
614 function getResourceURI(name, scheme, contentType) { | 586 function getResourceURI(name, scheme, contentType) { |
615 var base = document.documentURI; | 587 var base = document.documentURI; |
616 if (base == null) { | 588 if (base == null) { |
617 base = ""; | 589 base = ""; |
618 } else { | 590 } else { |
619 base = base.substring(0, base.lastIndexOf('/') + 1) + "files/"; | 591 base = base.substring(0, base.lastIndexOf('/') + 1) + "files/"; |
620 } | 592 } |
621 return base + name + getSuffix(contentType); | 593 return base + name + getSuffix(contentType); |
622 } | 594 } |
623 | 595 |
624 function onloadHandler() { | 596 function onloadHandler() { |
625 // | 597 // |
626 // invoke test setup | 598 // invoke test setup |
627 // | 599 // |
628 setUpPage(); | 600 setUpPage(); |
629 | 601 |
630 try { | 602 try { |
631 runTest(); | 603 runTest(); |
632 if (builder.initializationError == null) { | 604 if (builder.initializationError == null) { |
633 changeColor("green"); | 605 changeColor("green"); |
634 addMessage("0", "120", exposeTestFunctionNames()[0] + ": Success"
); | 606 addMessage("0", "120", exposeTestFunctionNames()[0] + ": Success"
); |
635 } else { | 607 } else { |
636 addMessage("0", "120", exposeTestFunctionNames()[0]); | 608 addMessage("0", "120", exposeTestFunctionNames()[0]); |
637 } | 609 } |
638 } catch(ex) { | 610 } catch(ex) { |
639 addMessage("0", "120", exposeTestFunctionNames()[0]); | 611 addMessage("0", "120", exposeTestFunctionNames()[0]); |
640 changeColor("red"); | 612 changeColor("red"); |
641 addMessage("0", "140", ex); | 613 addMessage("0", "140", ex); |
642 } | 614 } |
643 } | 615 } |
644 // Add loader | 616 // Add loader |
645 window.addEventListener('load', onloadHandler, false) | 617 window.addEventListener('load', onloadHandler, false) |
646 | |
OLD | NEW |