1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 2"http://www.w3.org/TR/html4/frameset.dtd"> 3<HTML> 4<HEAD> 5<BASE HREF="about:blank" TARGET="Frame1"> 6<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8"> 7<TITLE>NIST DOM HTML Test - Base2</TITLE> 8<script type='text/javascript'>/* 9Copyright (c) 2001-2005 World Wide Web Consortium, 10(Massachusetts Institute of Technology, European Research Consortium 11for Informatics and Mathematics, Keio University). All 12Rights Reserved. This work is distributed under the W3C(r) Software License [1] in the 13hope that it will be useful, but WITHOUT ANY WARRANTY; without even 14the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 16[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 17*/ 18 19// 20// Webkit modification: 11-August-2005 21// 22if (window.layoutTestController) 23 layoutTestController.dumpAsText(); 24// 25// End modification 26// 27 28 29 function assertSize(descr, expected, actual) { 30 var actualSize; 31 assertNotNull(descr, actual); 32 actualSize = actual.length; 33 assertEquals(descr, expected, actualSize); 34 } 35 36 function assertEqualsAutoCase(context, descr, expected, actual) { 37 if (builder.contentType == "text/html") { 38 if(context == "attribute") { 39 assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()); 40 } else { 41 assertEquals(descr, expected.toUpperCase(), actual); 42 } 43 } else { 44 assertEquals(descr, expected, actual); 45 } 46 } 47 48 49 function assertEqualsCollectionAutoCase(context, descr, expected, actual) { 50 // 51 // if they aren't the same size, they aren't equal 52 assertEquals(descr, expected.length, actual.length); 53 54 // 55 // if there length is the same, then every entry in the expected list 56 // must appear once and only once in the actual list 57 var expectedLen = expected.length; 58 var expectedValue; 59 var actualLen = actual.length; 60 var i; 61 var j; 62 var matches; 63 for(i = 0; i < expectedLen; i++) { 64 matches = 0; 65 expectedValue = expected[i]; 66 for(j = 0; j < actualLen; j++) { 67 if (builder.contentType == "text/html") { 68 if (context == "attribute") { 69 if (expectedValue.toLowerCase() == actual[j].toLowerCase()) { 70 matches++; 71 } 72 } else { 73 if (expectedValue.toUpperCase() == actual[j]) { 74 matches++; 75 } 76 } 77 } else { 78 if(expectedValue == actual[j]) { 79 matches++; 80 } 81 } 82 } 83 if(matches == 0) { 84 assert(descr + ": No match found for " + expectedValue,false); 85 } 86 if(matches > 1) { 87 assert(descr + ": Multiple matches found for " + expectedValue, false); 88 } 89 } 90 } 91 92 function assertEqualsCollection(descr, expected, actual) { 93 // 94 // if they aren't the same size, they aren't equal 95 assertEquals(descr, expected.length, actual.length); 96 // 97 // if there length is the same, then every entry in the expected list 98 // must appear once and only once in the actual list 99 var expectedLen = expected.length; 100 var expectedValue; 101 var actualLen = actual.length; 102 var i; 103 var j; 104 var matches; 105 for(i = 0; i < expectedLen; i++) { 106 matches = 0; 107 expectedValue = expected[i]; 108 for(j = 0; j < actualLen; j++) { 109 if(expectedValue == actual[j]) { 110 matches++; 111 } 112 } 113 if(matches == 0) { 114 assert(descr + ": No match found for " + expectedValue,false); 115 } 116 if(matches > 1) { 117 assert(descr + ": Multiple matches found for " + expectedValue, false); 118 } 119 } 120 } 121 122 123 function assertEqualsListAutoCase(context, descr, expected, actual) { 124 var minLength = expected.length; 125 if (actual.length < minLength) { 126 minLength = actual.length; 127 } 128 // 129 for(var i = 0; i < minLength; i++) { 130 assertEqualsAutoCase(context, descr, expected[i], actual[i]); 131 } 132 // 133 // if they aren't the same size, they aren't equal 134 assertEquals(descr, expected.length, actual.length); 135 } 136 137 138 function assertEqualsList(descr, expected, actual) { 139 var minLength = expected.length; 140 if (actual.length < minLength) { 141 minLength = actual.length; 142 } 143 // 144 for(var i = 0; i < minLength; i++) { 145 if(expected[i] != actual[i]) { 146 assertEquals(descr, expected[i], actual[i]); 147 } 148 } 149 // 150 // if they aren't the same size, they aren't equal 151 assertEquals(descr, expected.length, actual.length); 152 } 153 154 function assertInstanceOf(descr, type, obj) { 155 if(type == "Attr") { 156 assertEquals(descr,2,obj.nodeType); 157 var specd = obj.specified; 158 } 159 } 160 161 function assertSame(descr, expected, actual) { 162 if(expected != actual) { 163 assertEquals(descr, expected.nodeType, actual.nodeType); 164 assertEquals(descr, expected.nodeValue, actual.nodeValue); 165 } 166 } 167 168 function assertURIEquals(assertID, scheme, path, host, file, name, query, fragment, isAbsolute, actual) { 169 // 170 // URI must be non-null 171 assertNotNull(assertID, actual); 172 173 var uri = actual; 174 175 var lastPound = actual.lastIndexOf("#"); 176 var actualFragment = ""; 177 if(lastPound != -1) { 178 // 179 // substring before pound 180 // 181 uri = actual.substring(0,lastPound); 182 actualFragment = actual.substring(lastPound+1); 183 } 184 if(fragment != null) assertEquals(assertID,fragment, actualFragment); 185 186 var lastQuestion = uri.lastIndexOf("?"); 187 var actualQuery = ""; 188 if(lastQuestion != -1) { 189 // 190 // substring before pound 191 // 192 uri = actual.substring(0,lastQuestion); 193 actualQuery = actual.substring(lastQuestion+1); 194 } 195 if(query != null) assertEquals(assertID, query, actualQuery); 196 197 var firstColon = uri.indexOf(":"); 198 var firstSlash = uri.indexOf("/"); 199 var actualPath = uri; 200 var actualScheme = ""; 201 if(firstColon != -1 && firstColon < firstSlash) { 202 actualScheme = uri.substring(0,firstColon); 203 actualPath = uri.substring(firstColon + 1); 204 } 205 206 if(scheme != null) { 207 assertEquals(assertID, scheme, actualScheme); 208 } 209 210 if(path != null) { 211 assertEquals(assertID, path, actualPath); 212 } 213 214 if(host != null) { 215 var actualHost = ""; 216 if(actualPath.substring(0,2) == "//") { 217 var termSlash = actualPath.substring(2).indexOf("/") + 2; 218 actualHost = actualPath.substring(0,termSlash); 219 } 220 assertEquals(assertID, host, actualHost); 221 } 222 223 if(file != null || name != null) { 224 var actualFile = actualPath; 225 var finalSlash = actualPath.lastIndexOf("/"); 226 if(finalSlash != -1) { 227 actualFile = actualPath.substring(finalSlash+1); 228 } 229 if (file != null) { 230 assertEquals(assertID, file, actualFile); 231 } 232 if (name != null) { 233 var actualName = actualFile; 234 var finalDot = actualFile.lastIndexOf("."); 235 if (finalDot != -1) { 236 actualName = actualName.substring(0, finalDot); 237 } 238 assertEquals(assertID, name, actualName); 239 } 240 } 241 242 if(isAbsolute != null) { 243 assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); 244 } 245 } 246 247 248// size() used by assertSize element 249function size(collection) 250{ 251 return collection.length; 252} 253 254function same(expected, actual) 255{ 256 return expected === actual; 257} 258 259function equalsAutoCase(context, expected, actual) { 260 if (builder.contentType == "text/html") { 261 if (context == "attribute") { 262 return expected.toLowerCase() == actual; 263 } 264 return expected.toUpperCase() == actual; 265 } 266 return expected == actual; 267} 268 269function createTempURI(scheme) { 270 if (scheme == "http") { 271 return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() * 100000) + ".xml"; 272 } 273 return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml"; 274} 275 276 277 278function EventMonitor() { 279 this.atEvents = new Array(); 280 this.bubbledEvents = new Array(); 281 this.capturedEvents = new Array(); 282 this.allEvents = new Array(); 283} 284 285EventMonitor.prototype.handleEvent = function(evt) { 286 switch(evt.eventPhase) { 287 case 1: 288 monitor.capturedEvents[monitor.capturedEvents.length] = evt; 289 break; 290 291 case 2: 292 monitor.atEvents[monitor.atEvents.length] = evt; 293 break; 294 295 case 3: 296 monitor.bubbledEvents[monitor.bubbledEvents.length] = evt; 297 break; 298 } 299 monitor.allEvents[monitor.allEvents.length] = evt; 300} 301 302function DOMErrorImpl(err) { 303 this.severity = err.severity; 304 this.message = err.message; 305 this.type = err.type; 306 this.relatedException = err.relatedException; 307 this.relatedData = err.relatedData; 308 this.location = err.location; 309} 310 311 312 313function DOMErrorMonitor() { 314 this.allErrors = new Array(); 315} 316 317DOMErrorMonitor.prototype.handleError = function(err) { 318 errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err); 319} 320 321DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) { 322 var i; 323 for (i = 0; i < this.allErrors.length; i++) { 324 if (this.allErrors[i].severity >= severity) { 325 assertEquals(id, severity - 1, this.allErrors[i].severity); 326 } 327 } 328} 329 330function UserDataNotification(operation, key, data, src, dst) { 331 this.operation = operation; 332 this.key = key; 333 this.data = data; 334 this.src = src; 335 this.dst = dst; 336} 337 338function UserDataMonitor() { 339 this.allNotifications = new Array(); 340} 341 342UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) { 343 userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] = 344 new UserDataNotification(operation, key, data, src, dst); 345} 346 347 348 349function HTMLBuilder() { 350 this.contentType = "text/html"; 351 this.supportedContentTypes = [ "text/html" ]; 352 353 this.supportsAsyncChange = false; 354 this.async = false; 355 this.fixedAttributeNames = [ 356 "validating", "expandEntityReferences", "coalescing", 357 "signed", "hasNullString", "ignoringElementContentWhitespace", "namespaceAware", "ignoringComments", "schemaValidating"]; 358 359 this.fixedAttributeValues = [false, true, false, true, true , false, false, false, false ]; 360 this.configurableAttributeNames = [ ]; 361 this.configurableAttributeValues = [ ]; 362 this.initializationError = null; 363 this.initializationFatalError = null; 364 this.skipIncompatibleTests = true; 365 this.documentURLs = new Array(); 366 this.documentVarnames = new Array(); 367} 368 369HTMLBuilder.prototype.hasFeature = function(feature, version) { 370 return document.implementation.hasFeature(feature, version); 371} 372 373HTMLBuilder.prototype.getImplementation = function() { 374 return document.implementation; 375} 376 377HTMLBuilder.prototype.preload = function(frame, varname, url) { 378 var i; 379 this.documentVarnames[this.documentVarnames.length] = varname; 380 this.documentURLs[this.documentURLs.length] = url; 381 if (this.documentURLs.length > 1) { 382 // 383 // if all the urls are not the same 384 // 385 for (i = 1; i < this.documentURLs.length; i++) { 386 if (this.documentURLs[i] != this.documentURLs[0]) { 387 throw "Tests with multiple loads of different documents are not currently supported"; 388 } 389 } 390 } 391 return 1; 392} 393 394HTMLBuilder.prototype.cloneNode = function(srcNode, doc) { 395 var clone = null; 396 switch(srcNode.nodeType) { 397 // 398 // element 399 case 1: 400 clone = doc.createElement(srcNode.nodeName.toLowerCase()); 401 var attrs = srcNode.attributes; 402 for(var i = 0; i < attrs.length; i++) { 403 var srcAttr = attrs.item(i); 404 clone.setAttribute(srcAttr.nodeName, srcAttr.nodeValue); 405 } 406 var srcChild = srcNode.firstChild; 407 while(srcChild != null) { 408 var cloneChild = this.cloneNode(srcChild, doc); 409 if (cloneChild != null) { 410 clone.appendChild(cloneChild); 411 } 412 srcChild = srcChild.nextSibling; 413 } 414 break; 415 416 case 3: 417 clone = doc.createTextNode(srcNode.nodeValue); 418 break; 419 420 case 4: 421 clone = doc.createCDATASection(srcNode.nodeValue); 422 break; 423 424 case 7: 425 clone = doc.createProcessingInstruction(srcNode.nodeValue); 426 break; 427 428 case 8: 429 clone = doc.createComment(srcNode.nodeValue); 430 break; 431 } 432 return clone; 433 434} 435 436HTMLBuilder.prototype.load = function(frame, varname, url) { 437 if (this.documentVarnames[0] == varname) { 438 return document; 439 } 440 // 441 // 442 // not a perfect way to do this 443 // Document.cloneNode is implementation dependent but exists in L1 444 // and implemented in IE. The alternative brute force copy 445 // only works in L2 or higher implementations and can't copy 446 // entity and notation definitions, etc. 447 var clone = null; 448 try { 449 clone = document.cloneNode(true); 450 } catch(ex) { 451 } 452 if (clone == null) { 453 clone = document.implementation.createDocument( 454 document.documentElement.namespaceURI, 455 document.documentElement.nodeName, 456 null); 457 // 458 // Work-around since 459 // Safari does not create document element 460 // create document. 461 if (clone.documentElement == null) { 462 clone.appendChild(clone.createElement(document.documentElement.nodeName)); 463 } 464 var attrs = document.documentElement.attributes; 465 for(var i = 0; i < attrs.length; i++) { 466 var srcAttr = attrs.item(i); 467 clone.documentElement.setAttribute(srcAttr.nodeName, srcAttr.nodeValue); 468 } 469 470 var srcNode = document.firstChild; 471 while(srcNode != null && srcNode.nodeType != 1) { 472 if (srcNode.nodeType != 10) { 473 var cloneNode = this.cloneNode(srcNode, clone); 474 clone.insertBefore(cloneNode, clone.documentElement); 475 } 476 srcNode = srcNode.nextSibling; 477 } 478 srcNode = document.documentElement.nextSibling; 479 while(srcNode != null) { 480 var cloneNode = this.cloneNode(srcNode, clone); 481 clone.appendChild(cloneNode); 482 srcNode = srcNode.nextSibling; 483 } 484 srcNode = document.documentElement.firstChild; 485 while(srcNode != null) { 486 var cloneNode = this.cloneNode(srcNode, clone); 487 if (cloneNode != null) { 488 clone.documentElement.appendChild(cloneNode); 489 } 490 srcNode = srcNode.nextSibling; 491 } 492 } 493 return clone; 494} 495 496HTMLBuilder.prototype.getImplementationAttribute = function(attr) { 497 for (var i = 0; i < this.fixedAttributeNames.length; i++) { 498 if (this.fixedAttributeNames[i] == attr) { 499 return this.fixedAttributeValues[i]; 500 } 501 } 502 throw "Unrecognized implementation attribute: " + attr; 503} 504 505 506HTMLBuilder.prototype.setImplementationAttribute = function(attribute, value) { 507 var supported = this.getImplementationAttribute(attribute); 508 if (supported != value) { 509 this.initializationError = "HTML loader does not support " + attribute + "=" + value; 510 } 511} 512 513HTMLBuilder.prototype.canSetImplementationAttribute = function(attribute, value) { 514 var supported = this.getImplementationAttribute(attribute); 515 return (supported == value); 516} 517 518 519 520 521function createConfiguredBuilder() { 522 return new HTMLBuilder(); 523} 524 525function catchInitializationError(buildr, ex) { 526 buildr.initializationError = ex; 527 buildr.initializationFatalError = ex; 528} 529 530function toLowerArray(src) { 531 var newArray = new Array(); 532 var i; 533 for (i = 0; i < src.length; i++) { 534 newArray[i] = src[i].toLowerCase(); 535 } 536 return newArray; 537} 538 539 540function checkFeature(feature, version) 541{ 542 if (!builder.hasFeature(feature, version)) 543 { 544 // 545 // don't throw exception so that users can select to ignore the precondition 546 // 547 builder.initializationError = "builder does not support feature " + feature + " version " + version; 548 } 549} 550 551function setResult(resultType, message) { 552 var testName = getTargetURI(); 553 document.open(); 554 document.writeln("<html><head>"); 555 document.writeln("<meta HTTP-EQUIV='Content-Type' CONTENT='text/html; CHARSET=utf-8'>"); 556 document.write("<title>"); 557 document.write(testName + ":" + resultType); 558 document.write("<\/title><\/head><body><table width='100%' border='1' style='color:"); 559 if (resultType == null) { 560 document.writeln("green'><tr><td>Test:<\/td><td>" + testName + "<\/td><\/tr><tr><td>Status:<\/td><td>Success<\/td><\/tr>"); 561 } else { 562 if (resultType == "skip") { 563 document.writeln("blue'><tr><td>Test:<\/td><td>" + testName + "<\/td><\/tr><tr><td>Status:<\/td><td>Skipped<\/td><\/tr>"); 564 } else { 565 document.writeln("red'><tr><td>Test:<\/td><td>" + testName + "<\/td><td><\/tr><tr><td>Status:<\/td><td>" + resultType + "<\/td><\/tr>"); 566 } 567 } 568 if (message != null) { 569 document.writeln("<tr><td>Detail:<\/td><td>" + message + "<\/td><\/tr>"); 570 } 571 document.write("<\/table><\/body><\/html>"); 572 document.close(); 573 if (parent != window) { 574 parent.setResult(testName, resultType, message); 575 } 576} 577 578function checkInitialization(buildr, testname) { 579 return buildr.initializationError; 580} 581 582function preload(docRef, varname, href) { 583 return builder.preload(docRef, varname, href); 584} 585 586 587function load(docRef, varname, href) { 588 return builder.load(docRef, varname, href); 589} 590 591 592function getImplementationAttribute(attr) { 593 return builder.getImplementationAttribute(attr); 594} 595 596 597function setImplementationAttribute(attribute, value) { 598 builder.setImplementationAttribute(attribute, value); 599} 600 601function createXPathEvaluator(doc) { 602 try { 603 return doc.getFeature("XPath", null); 604 } 605 catch(ex) { 606 } 607 return doc; 608} 609 610 611function getImplementation() { 612 return builder.getImplementation(); 613} 614 615function assertEquals(id, expected, actual) { 616 var myActual; 617 if (expected != actual) { 618 myActual = actual; 619 if (actual == null) { 620 myActual = "null"; 621 } 622 throw "failure:" + id + ": assertEquals failed, actual " + myActual + ", expected " + expected + "."; 623 } 624} 625 626function assertNull(id, actual) { 627 if (actual != null) { 628 throw "failure:" + id + ": assertNull failed, actual " + actual; 629 } 630} 631 632 633function assertTrue(id, actual) { 634 if (!actual) { 635 throw "failure:" + id + ": assertTrue failed"; 636 } 637} 638 639 640function assertFalse(id, actual) { 641 if (actual) { 642 throw "failure:" + id + ": assertTrue failed"; 643 } 644} 645 646function assertNotNull(id, actual) { 647 if (actual == null) { 648 throw "failure:" + id + ": assertNotNull failed"; 649 } 650} 651 652function fail(id) { 653 throw "failure:" + id + ": fail"; 654} 655 656 657 658function getSuffix(contentType) { 659 switch(contentType) { 660 case "text/xml": 661 return ".xml"; 662 663 case "application/xhtml+xml": 664 return ".xhtml"; 665 666 case "image/svg+xml": 667 return ".svg"; 668 669 case "text/mathml": 670 return ".mml"; 671 } 672 return ".html"; 673} 674 675 676function getResourceURI(name, scheme, contentType) { 677 var base = document.documentURI; 678 if (base == null) { 679 base = ""; 680 } else { 681 base = base.substring(0, base.lastIndexOf('/') + 1) + "files/"; 682 } 683 return base + name + getSuffix(contentType); 684} 685 686 687 688function startTest() { 689 // 690 // invoke test setup 691 // 692 setUpPage(); 693 694 try { 695 runTest(); 696 if (builder.initializationError == null) { 697 setResult(null, null); 698 } else { 699 setResult("skip", builder.initializationError); 700 } 701 } catch(ex) { 702 if (typeof(ex.substring) != 'undefined' && ex.substring(0, 8) == "failure:") { 703 setResult("failure", ex.substring(8)); 704 } else { 705 setResult("error", ex); 706 } 707 } 708}</script><script charset='UTF-8' type='text/javascript'> 709/* 710Copyright é 2001-2004 World Wide Web Consortium, 711(Massachusetts Institute of Technology, European Research Consortium 712for Informatics and Mathematics, Keio University). All 713Rights Reserved. This work is distributed under the W3Cî Software License [1] in the 714hope that it will be useful, but WITHOUT ANY WARRANTY; without even 715the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 716 717[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 718*/ 719 720 721 722 /** 723 * Gets URI that identifies the test. 724 * @return uri identifier of test 725 */ 726function getTargetURI() { 727 return "http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLBaseElement02"; 728 } 729 730var docsLoaded = -1000000; 731var builder = null; 732 733// 734// This function is called by the testing framework before 735// running the test suite. 736// 737// If there are no configuration exceptions, asynchronous 738// document loading is started. Otherwise, the status 739// is set to complete and the exception is immediately 740// raised when entering the body of the test. 741// 742function setUpPage() { 743 setUpPageStatus = 'running'; 744 try { 745 // 746 // creates test document builder, may throw exception 747 // 748 builder = createConfiguredBuilder(); 749 750 docsLoaded = 0; 751 752 var docRef = null; 753 if (typeof(this.doc) != 'undefined') { 754 docRef = this.doc; 755 } 756 docsLoaded += preload(docRef, "doc", "base2"); 757 758 if (docsLoaded == 1) { 759 setUpPageStatus = 'complete'; 760 } 761 } catch(ex) { 762 catchInitializationError(builder, ex); 763 setUpPageStatus = 'complete'; 764 } 765} 766 767 768 769// 770// This method is called on the completion of 771// each asychronous load started in setUpTests. 772// 773// When every synchronous loaded document has completed, 774// the page status is changed which allows the 775// body of the test to be executed. 776function loadComplete() { 777 if (++docsLoaded == 1) { 778 setUpPageStatus = 'complete'; 779 } 780} 781 782 783/** 784* 785 The target attribute specifies the default target frame. 786 787 Retrieve the target attribute and examine its value. 788 789* @author NIST 790* @author Rick Rivello 791* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-73844298 792*/ 793function HTMLBaseElement02() { 794 var success; 795 if(checkInitialization(builder, "HTMLBaseElement02") != null) return; 796 var nodeList; 797 var testNode; 798 var vtarget; 799 var doc; 800 801 var docRef = null; 802 if (typeof(this.doc) != 'undefined') { 803 docRef = this.doc; 804 } 805 doc = load(docRef, "doc", "base2"); 806 nodeList = doc.getElementsByTagName("base"); 807 assertSize("Asize",1,nodeList); 808testNode = nodeList.item(0); 809 vtarget = testNode.target; 810 811 assertEquals("targetLink","Frame1",vtarget); 812 813} 814 815 816 817 818function runTest() { 819 HTMLBaseElement02(); 820} 821</script><script type='text/javascript'>function loadComplete() { startTest(); }</script></HEAD> 822<FRAMESET COLS="20, 80" onload="loadComplete()"> 823<FRAMESET ROWS="100, 200"> 824<FRAME MARGINHEIGHT="10" MARGINWIDTH="5" NORESIZE="NORESIZE" NAME="Frame1" FRAMEBORDER="1" SCROLLING="yes"> 825</FRAMESET> 826<FRAME> 827</FRAMESET> 828</HTML> 829