Home | History | Annotate | Download | only in html
      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!DOCTYPE html
      3    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      4    "xhtml1-strict.dtd">
      5 <html xmlns='http://www.w3.org/1999/xhtml'>
      6 <head>
      7 <base href="about:blank"/>
      8 <title>NIST DOM HTML Test - Base</title>
      9 <script type='text/javascript'><![CDATA[/*
     10 Copyright (c) 2001-2005 World Wide Web Consortium, 
     11 (Massachusetts Institute of Technology, European Research Consortium 
     12 for Informatics and Mathematics, Keio University). All 
     13 Rights Reserved. This work is distributed under the W3C(r) Software License [1] in the 
     14 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
     15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
     16 
     17 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
     18 */
     19 
     20   //
     21   //  WebKit modification: 13-May-2007
     22   //
     23   //  Inform the test controller that this test has a text-format result and so should
     24   //  be dumped as text.
     25   //
     26   if (window.layoutTestController)
     27     layoutTestController.dumpAsText();
     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
    249 function size(collection)
    250 {
    251   return collection.length;
    252 }
    253 
    254 function same(expected, actual)
    255 {
    256   return expected === actual;
    257 }
    258 
    259 function 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 
    269 function toLowerArray(src) {
    270    var newArray = new Array();
    271    var i;
    272    for (i = 0; i < src.length; i++) {
    273       newArray[i] = src[i].toLowerCase();
    274    }
    275    return newArray;
    276 }
    277 
    278 function createTempURI(scheme) {
    279    if (scheme == "http") {
    280          return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() * 100000) + ".xml";
    281    }
    282    return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml";
    283 }
    284 
    285 
    286 
    287 function EventMonitor() {
    288   this.atEvents = new Array();
    289   this.bubbledEvents = new Array();
    290   this.capturedEvents = new Array();
    291   this.allEvents = new Array();
    292 }
    293 
    294 EventMonitor.prototype.handleEvent = function(evt) {
    295     switch(evt.eventPhase) {
    296        case 1:
    297        monitor.capturedEvents[monitor.capturedEvents.length] = evt;
    298        break;
    299        
    300        case 2:
    301        monitor.atEvents[monitor.atEvents.length] = evt;
    302        break;
    303 
    304        case 3:
    305        monitor.bubbledEvents[monitor.bubbledEvents.length] = evt;
    306        break;
    307     }
    308     monitor.allEvents[monitor.allEvents.length] = evt;
    309 }
    310 
    311 function DOMErrorImpl(err) {
    312   this.severity = err.severity;
    313   this.message = err.message;
    314   this.type = err.type;
    315   this.relatedException = err.relatedException;
    316   this.relatedData = err.relatedData;
    317   this.location = err.location;
    318 }
    319 
    320 
    321 
    322 function DOMErrorMonitor() {
    323   this.allErrors = new Array();
    324 }
    325 
    326 DOMErrorMonitor.prototype.handleError = function(err) {
    327     errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err);
    328 }
    329 
    330 DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) {
    331     var i;
    332     for (i = 0; i < this.allErrors.length; i++) {
    333         if (this.allErrors[i].severity >= severity) {
    334            assertEquals(id, severity - 1, this.allErrors[i].severity);
    335         }
    336     }
    337 }
    338 
    339 function UserDataNotification(operation, key, data, src, dst) {
    340     this.operation = operation;
    341     this.key = key;
    342     this.data = data;
    343     this.src = src;
    344     this.dst = dst;
    345 }
    346 
    347 function UserDataMonitor() {
    348     this.allNotifications = new Array();
    349 }
    350 
    351 UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) {
    352     userDataMonitor.allNotifications[userDataMonitor.allNotifications.length] =
    353          new UserDataNotification(operation, key, data, src, dst);
    354 }
    355 
    356 
    357 
    358 function HTMLBuilder() {
    359     this.contentType = "application/xhtml+xml";
    360     this.supportedContentTypes = [ "application/xhtml+xml" ];
    361 
    362     this.supportsAsyncChange = false;
    363     this.async = false;
    364     this.fixedAttributeNames = [
    365         "validating",  "expandEntityReferences", "coalescing", 
    366         "signed", "hasNullString", "ignoringElementContentWhitespace", "namespaceAware", "ignoringComments", "schemaValidating"];
    367 
    368     this.fixedAttributeValues = [false,  true, false, true, true , false, true, false, false ];
    369     this.configurableAttributeNames = [ ];
    370     this.configurableAttributeValues = [ ];
    371     this.initializationError = null;
    372     this.initializationFatalError = null;
    373     this.skipIncompatibleTests = true;
    374     this.documentURLs = new Array();
    375     this.documentVarnames = new Array();
    376 }
    377 
    378 HTMLBuilder.prototype.hasFeature = function(feature, version) {
    379     return document.implementation.hasFeature(feature, version);
    380 }
    381 
    382 HTMLBuilder.prototype.getImplementation = function() {
    383   return document.implementation;
    384 }
    385 
    386 HTMLBuilder.prototype.preload = function(frame, varname, url) {
    387   var i;
    388   this.documentVarnames[this.documentVarnames.length] = varname;
    389   this.documentURLs[this.documentURLs.length] = url;
    390   if (this.documentURLs.length > 1) {
    391      //
    392      //   if all the urls are not the same
    393      //
    394      for (i = 1; i < this.documentURLs.length; i++) {
    395          if (this.documentURLs[i] != this.documentURLs[0]) {
    396              throw "Tests with multiple loads of different documents are not currently supported";
    397          }
    398      }
    399   }
    400   return 1;
    401 }
    402 
    403 HTMLBuilder.prototype.cloneNode = function(srcNode, doc) {
    404    var clone = null;
    405    switch(srcNode.nodeType) {
    406       //
    407       //  element
    408       case 1:
    409       clone = doc.createElementNS(srcNode.namespaceURI, srcNode.nodeName);
    410       var attrs = srcNode.attributes;
    411       for(var i = 0; i < attrs.length; i++) {
    412           var srcAttr = attrs.item(i);
    413           clone.setAttributeNS(srcAttr.namespaceURI, srcAttr.nodeName, srcAttr.nodeValue);
    414       }
    415       var srcChild = srcNode.firstChild;
    416       while(srcChild != null) {
    417          var cloneChild = this.cloneNode(srcChild, doc);
    418          if (cloneChild != null) {
    419              clone.appendChild(cloneChild);
    420          }
    421          srcChild = srcChild.nextSibling;
    422       }
    423       break;
    424       
    425       case 3:
    426       clone = doc.createTextNode(srcNode.nodeValue);
    427       break;
    428       
    429       case 4:
    430       clone = doc.createCDATASection(srcNode.nodeValue);
    431       break;
    432       
    433       case 5:
    434       clone = doc.createEntityReference(srcNode.nodeName);
    435       break;
    436                   
    437       case 7:
    438       clone = doc.createProcessingInstruction(srcNode.target, srcNode.data);
    439       break;
    440       
    441       case 8:
    442       clone = doc.createComment(srcNode.nodeValue);
    443       break;
    444    }
    445    return clone;
    446       
    447 }
    448 
    449 
    450 HTMLBuilder.prototype.load = function(frame, varname, url) {
    451   if (this.documentVarnames[0] == varname) {
    452       return document;
    453   }
    454   //
    455   //
    456   //  not a perfect way to do this
    457   //    Document.cloneNode is implementation dependent but exists in L1
    458   //       and implemented in IE.  The alternative brute force copy
    459   //       only works in L2 or higher implementations and can't copy
    460   //       entity and notation definitions, etc.
    461   var clone = null;
    462   try {
    463       clone = document.cloneNode(true);
    464   } catch(ex) {
    465   }
    466   if (clone == null) {
    467       clone = document.implementation.createDocument(
    468           document.documentElement.namespaceURI,
    469           document.documentElement.nodeName,
    470           null);
    471       //
    472       //   Work-around since
    473       //   Safari does not create document element 
    474       //      create document.      
    475       if (clone.documentElement == null) {
    476            clone.appendChild(clone.createElementNS(
    477               document.documentElement.namespaceURI, 
    478               document.documentElement.nodeName));
    479       }
    480       var attrs = document.documentElement.attributes;
    481       for(var i = 0; i < attrs.length; i++) {
    482           var srcAttr = attrs.item(i);
    483           clone.documentElement.setAttributeNS(
    484              srcAttr.namespaceURI, srcAttr.nodeName, srcAttr.nodeValue);
    485       }
    486 
    487       var srcNode = document.firstChild;
    488       while(srcNode != null && srcNode.nodeType != 1) {
    489           if (srcNode.nodeType != 10) {
    490                var cloneNode = this.cloneNode(srcNode, clone);
    491              clone.insertBefore(cloneNode, clone.documentElement);
    492            }
    493            srcNode = srcNode.nextSibling; 
    494       }
    495       srcNode = document.documentElement.nextSibling;
    496       while(srcNode != null) {
    497           var cloneNode = this.cloneNode(srcNode, clone);
    498           clone.appendChild(cloneNode);
    499           srcNode = srcNode.nextSibling;
    500       }
    501       srcNode = document.documentElement.firstChild;
    502       while(srcNode != null) {
    503           var cloneNode = this.cloneNode(srcNode, clone);
    504           if (cloneNode != null) {
    505              clone.documentElement.appendChild(cloneNode);
    506           }
    507           srcNode = srcNode.nextSibling;
    508       }
    509   }
    510   return clone;
    511 }
    512 
    513 HTMLBuilder.prototype.getImplementationAttribute = function(attr) {
    514     for (var i = 0; i < this.fixedAttributeNames.length; i++) {
    515         if (this.fixedAttributeNames[i] == attr) {
    516             return this.fixedAttributeValues[i];
    517         }
    518     }
    519     throw "Unrecognized implementation attribute: " + attr;
    520 }
    521 
    522 
    523 HTMLBuilder.prototype.setImplementationAttribute = function(attribute, value) {
    524     var supported = this.getImplementationAttribute(attribute);
    525     if (supported != value) {
    526         this.initializationError = "HTML loader does not support " + attribute + "=" + value;
    527     }
    528 }
    529 
    530 HTMLBuilder.prototype.canSetImplementationAttribute = function(attribute, value) {
    531     var supported = this.getImplementationAttribute(attribute);
    532     return (supported == value);
    533 }
    534 
    535 
    536 
    537 
    538 function createConfiguredBuilder() {
    539     return new HTMLBuilder();
    540 }
    541 
    542 function catchInitializationError(buildr, ex) {
    543    buildr.initializationError = ex;
    544    buildr.initializationFatalError = ex;
    545 }
    546 
    547 
    548 function checkFeature(feature, version)
    549 {
    550   if (!builder.hasFeature(feature, version))
    551   {
    552     //
    553     //   don't throw exception so that users can select to ignore the precondition
    554     //
    555     builder.initializationError = "builder does not support feature " + feature + " version " + version;
    556   }
    557 }
    558 
    559 function setResult(resultType, message) {
    560    var testName = getTargetURI();
    561    document.title = testName + ":" + resultType;
    562    var xhtmlNS = "http://www.w3.org/1999/xhtml"; 
    563    var newBody = document.createElementNS(xhtmlNS, "body");
    564    var newTable = document.createElementNS(xhtmlNS, "table");
    565    newTable.width = "100%";
    566    newTable.border = "1";
    567    newBody.appendChild(newTable);
    568    var testRow = newTable.insertRow(-1);
    569    var testDiv1 = testRow.insertCell(-1);
    570    testDiv1.appendChild(document.createTextNode("Test"));
    571    var testDiv2 = testRow.insertCell(-1);
    572    testDiv2.appendChild(document.createTextNode(testName));
    573    var statusRow = newTable.insertRow(-1);
    574    var statusDiv1 = statusRow.insertCell(-1);
    575    statusDiv1.appendChild(document.createTextNode("Status"));
    576    var statusDiv2 = statusRow.insertCell(-1);
    577    var style = "color:green";
    578    if (resultType == null) {
    579            statusDiv2.appendChild(document.createTextNode("Success"));
    580    } else {
    581            statusDiv2.appendChild(document.createTextNode(resultType));
    582            if (resultType == "skip") {
    583                style = "color:blue";
    584            } else {
    585                style = "color:red";
    586            }
    587    }
    588    newTable.setAttributeNS(null, "style", style);
    589    if (message != null) {
    590       var messageRow = newTable.insertRow(-1);
    591          var messageDiv1 = messageRow.insertCell(-1);
    592       messageDiv1.appendChild(document.createTextNode("Message"));
    593       var messageDiv2 = messageRow.insertCell(-1);
    594       messageDiv2.appendChild(document.createTextNode(message));
    595    }
    596    document.body.parentNode.replaceChild(newBody, document.body);
    597    if (parent != window && typeof(parent.setResult) != 'undefined') {
    598        parent.setResult(testName, resultType, message);
    599    }   
    600 }
    601 
    602 function checkInitialization(buildr, testname) {
    603    return buildr.initializationError;
    604 }
    605 
    606 function preload(docRef, varname, href) {
    607    return builder.preload(docRef, varname, href);
    608 }
    609 
    610 
    611 function load(docRef, varname, href) {
    612    return builder.load(docRef, varname, href);
    613 }
    614 
    615 
    616 function getImplementationAttribute(attr) {
    617     return builder.getImplementationAttribute(attr);
    618 }
    619 
    620 
    621 function setImplementationAttribute(attribute, value) {
    622     builder.setImplementationAttribute(attribute, value);
    623 }
    624 
    625 function createXPathEvaluator(doc) {
    626     try {
    627         return doc.getFeature("XPath", null);
    628     }
    629     catch(ex) {
    630     }
    631     return doc;
    632 }
    633 
    634 
    635 function getImplementation() {
    636     return builder.getImplementation();
    637 }
    638 
    639 function assertEquals(id, expected, actual) {
    640    var myActual;
    641    if (expected != actual) {
    642        myActual = actual;
    643        if (actual == null) {
    644           myActual = "null";
    645        }
    646        throw "failure:" + id + ": assertEquals failed, actual " + actual + ", expected " + expected + "."; 
    647    }
    648 }
    649 
    650 function assertNull(id, actual) {
    651    if (actual != null) {
    652        throw "failure:" + id + ": assertNull failed, actual " + actual;
    653    }
    654 }
    655 
    656 
    657 function assertTrue(id, actual) {
    658    if (!actual) {
    659        throw "failure:" + id + ": assertTrue failed";
    660    }
    661 }
    662 
    663 
    664 function assertFalse(id, actual) {
    665    if (actual) {
    666        throw "failure:" + id +  ": assertTrue failed";
    667    }
    668 }
    669 
    670 function assertNotNull(id, actual) {
    671    if (actual == null) {
    672        throw "failure:" + id + ": assertNotNull failed";
    673    }
    674 }
    675 
    676 function fail(id) {
    677     throw "failure:" + id +  ": fail";
    678 }
    679 
    680 
    681 
    682 function getSuffix(contentType) {
    683     switch(contentType) {
    684         case "text/html":
    685         return ".html";
    686 
    687         case "text/xml":
    688         return ".xml";
    689 
    690         case "image/svg+xml":
    691         return ".svg";
    692 
    693         case "text/mathml":
    694         return ".mml";
    695     }
    696     return ".xhtml";
    697 }
    698 
    699 
    700 function getResourceURI(name, scheme, contentType) {
    701     var base = document.documentURI;
    702     if (base == null) {
    703        base = "";
    704     } else {
    705        base = base.substring(0, base.lastIndexOf('/') + 1) + "files/";
    706     }
    707     return base + name + getSuffix(contentType);
    708 }
    709 
    710 
    711 
    712 function startTest() {
    713     //
    714     //   invoke test setup
    715     //
    716     setUpPage();
    717 
    718     try {
    719         runTest();
    720         if (builder.initializationError == null) {
    721            setResult(null, null);
    722         } else {
    723            setResult("skip", builder.initializationError);
    724         }
    725     } catch(ex) {
    726         if (typeof(ex.substring) != 'undefined' && ex.substring(0, 8) == "failure:") {
    727             setResult("failure", ex.substring(8));
    728         } else {
    729             setResult("error", ex);
    730         }
    731     }
    732 }]]></script><script charset='UTF-8' type='text/javascript'>
    733 /*
    734 Copyright  2001-2004 World Wide Web Consortium, 
    735 (Massachusetts Institute of Technology, European Research Consortium 
    736 for Informatics and Mathematics, Keio University). All 
    737 Rights Reserved. This work is distributed under the W3C Software License [1] in the 
    738 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
    739 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    740 
    741 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
    742 */
    743 
    744 
    745 
    746    /**
    747     *  Gets URI that identifies the test.
    748     *  @return uri identifier of test
    749     */
    750 function getTargetURI() {
    751       return "http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLBaseElement01";
    752    }
    753 
    754 var docsLoaded = -1000000;
    755 var builder = null;
    756 
    757 //
    758 //   This function is called by the testing framework before
    759 //      running the test suite.
    760 //
    761 //   If there are no configuration exceptions, asynchronous
    762 //        document loading is started.  Otherwise, the status
    763 //        is set to complete and the exception is immediately
    764 //        raised when entering the body of the test.
    765 //
    766 function setUpPage() {
    767    setUpPageStatus = 'running';
    768    try {
    769      //
    770      //   creates test document builder, may throw exception
    771      //
    772      builder = createConfiguredBuilder();
    773 
    774       docsLoaded = 0;
    775       
    776       var docRef = null;
    777       if (typeof(this.doc) != 'undefined') {
    778         docRef = this.doc;
    779       }
    780       docsLoaded += preload(docRef, "doc", "base");
    781         
    782        if (docsLoaded == 1) {
    783           setUpPageStatus = 'complete';
    784        }
    785     } catch(ex) {
    786         catchInitializationError(builder, ex);
    787         setUpPageStatus = 'complete';
    788     }
    789 }
    790 
    791 
    792 
    793 //
    794 //   This method is called on the completion of 
    795 //      each asychronous load started in setUpTests.
    796 //
    797 //   When every synchronous loaded document has completed,
    798 //      the page status is changed which allows the
    799 //      body of the test to be executed.
    800 function loadComplete() {
    801     if (++docsLoaded == 1) {
    802         setUpPageStatus = 'complete';
    803     }
    804 }
    805 
    806 
    807 /**
    808 * 
    809     The href attribute specifies the base URI. 
    810 
    811     Retrieve the href attribute and examine its value.  
    812 
    813 * @author NIST
    814 * @author Mary Brady
    815 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-65382887
    816 */
    817 function HTMLBaseElement01() {
    818    var success;
    819     if(checkInitialization(builder, "HTMLBaseElement01") != null) return;
    820     var nodeList;
    821       var testNode;
    822       var vhref;
    823       var doc;
    824       
    825       var docRef = null;
    826       if (typeof(this.doc) != 'undefined') {
    827         docRef = this.doc;
    828       }
    829       doc = load(docRef, "doc", "base");
    830       nodeList = doc.getElementsByTagName("base");
    831       assertSize("Asize",1,nodeList);
    832 testNode = nodeList.item(0);
    833       vhref = testNode.href;
    834 
    835       assertEquals("hrefLink","about:blank",vhref);
    836        
    837 }
    838 
    839 
    840 
    841 
    842 function runTest() {
    843    HTMLBaseElement01();
    844 }
    845 </script><script type='text/javascript'>function loadComplete() { startTest(); }</script></head>
    846 <body onload="loadComplete()">
    847 <p>Some Text</p>
    848 </body>
    849 </html>
    850