Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: LayoutTests/dom/html/level1/core/selfhtml.js

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

Powered by Google App Engine
This is Rietveld 408576698