dom/tests/mochitest/dom-level2-html/DOMTestCase.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/dom-level2-html/DOMTestCase.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,718 @@
     1.4 +/*
     1.5 +Copyright (c) 2001-2005 World Wide Web Consortium,
     1.6 +(Massachusetts Institute of Technology, Institut National de
     1.7 +Recherche en Informatique et en Automatique, Keio University). All
     1.8 +Rights Reserved. This program is distributed under the W3C's Software
     1.9 +Intellectual Property License. This program is distributed in the
    1.10 +hope that it will be useful, but WITHOUT ANY WARRANTY; without even
    1.11 +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    1.12 +PURPOSE.
    1.13 +See W3C License http://www.w3.org/Consortium/Legal/ for more details.
    1.14 +*/
    1.15 +
    1.16 +function assertNull(descr, actual) {
    1.17 +  return ok(actual === null, descr);
    1.18 +}
    1.19 +
    1.20 +
    1.21 +function assertNotNull(descr, actual) {
    1.22 +  return ok(actual !== null, descr);
    1.23 +}
    1.24 +
    1.25 +function assertTrue(descr, actual) {
    1.26 +  return ok(actual === true, descr);
    1.27 +}
    1.28 +
    1.29 +function assertFalse(descr, actual) {
    1.30 +  return ok(actual === false, descr);
    1.31 +}
    1.32 +
    1.33 +function assertEquals(descr, expected, actual) {
    1.34 +  return is(actual, expected, descr);
    1.35 +}
    1.36 +
    1.37 +  function assertSize(descr, expected, actual) {
    1.38 +    ok(actual !== null, descr);
    1.39 +/*
    1.40 +    // Work around too strict checks.
    1.41 +    if (!actual) {
    1.42 +      ok(actual, "[assertSize()] 'actual' has a value");
    1.43 +      return;
    1.44 +    }
    1.45 +*/
    1.46 +
    1.47 +    is(actual.length, expected, descr);
    1.48 +  }
    1.49 +
    1.50 +  function assertEqualsAutoCase(context, descr, expected, actual) {
    1.51 +  	if (builder.contentType == "text/html") {
    1.52 +  	    if(context == "attribute") {
    1.53 +  	    	is(actual.toLowerCase(), expected.toLowerCase(), descr);
    1.54 +  	    } else {
    1.55 +  	        is(actual, expected.toUpperCase(), descr);
    1.56 +  	    }
    1.57 +  	} else {
    1.58 +  		is(actual, expected, descr); 
    1.59 +  	}
    1.60 +  }
    1.61 +  
    1.62 +
    1.63 +  function assertEqualsCollectionAutoCase(context, descr, expected, actual) {
    1.64 +    //
    1.65 +    //  if they aren't the same size, they aren't equal
    1.66 +    is(actual.length, expected.length, descr);
    1.67 +    
    1.68 +    //
    1.69 +    //  if there length is the same, then every entry in the expected list
    1.70 +    //     must appear once and only once in the actual list
    1.71 +    var expectedLen = expected.length;
    1.72 +    var expectedValue;
    1.73 +    var actualLen = actual.length;
    1.74 +    var i;
    1.75 +    var j;
    1.76 +    var matches;
    1.77 +    for(i = 0; i < expectedLen; i++) {
    1.78 +        matches = 0;
    1.79 +        expectedValue = expected[i];
    1.80 +        for(j = 0; j < actualLen; j++) {
    1.81 +        	if (builder.contentType == "text/html") {
    1.82 +        		if (context == "attribute") {
    1.83 +        			if (expectedValue.toLowerCase() == actual[j].toLowerCase()) {
    1.84 +        				matches++;
    1.85 +        			}
    1.86 +        		} else {
    1.87 +        			if (expectedValue.toUpperCase() == actual[j]) {
    1.88 +        				matches++;
    1.89 +        			}
    1.90 +        		}
    1.91 +        	} else {
    1.92 +            	if(expectedValue == actual[j]) {
    1.93 +                	matches++;
    1.94 +                }
    1.95 +            }
    1.96 +        }
    1.97 +        if(matches == 0) {
    1.98 +            ok(false, descr + ": No match found for " + expectedValue);
    1.99 +        }
   1.100 +        if(matches > 1) {
   1.101 +            ok(false, descr + ": Multiple matches found for " + expectedValue);
   1.102 +        }
   1.103 +    }
   1.104 +  }
   1.105 +
   1.106 +  function assertEqualsCollection(descr, expected, actual) {
   1.107 +    //
   1.108 +    //  if they aren't the same size, they aren't equal
   1.109 +    is(actual.length, expected.length, descr);
   1.110 +    //
   1.111 +    //  if there length is the same, then every entry in the expected list
   1.112 +    //     must appear once and only once in the actual list
   1.113 +    var expectedLen = expected.length;
   1.114 +    var expectedValue;
   1.115 +    var actualLen = actual.length;
   1.116 +    var i;
   1.117 +    var j;
   1.118 +    var matches;
   1.119 +    for(i = 0; i < expectedLen; i++) {
   1.120 +        matches = 0;
   1.121 +        expectedValue = expected[i];
   1.122 +        for(j = 0; j < actualLen; j++) {
   1.123 +            if(expectedValue == actual[j]) {
   1.124 +                matches++;
   1.125 +            }
   1.126 +        }
   1.127 +        if(matches == 0) {
   1.128 +            ok(false, descr + ": No match found for " + expectedValue);
   1.129 +        }
   1.130 +        if(matches > 1) {
   1.131 +            ok(false, descr + ": Multiple matches found for " + expectedValue);
   1.132 +        }
   1.133 +    }
   1.134 +  }
   1.135 +
   1.136 +
   1.137 +  function assertEqualsListAutoCase(context, descr, expected, actual) {
   1.138 +	var minLength = expected.length;
   1.139 +	if (actual.length < minLength) {
   1.140 +	    minLength = actual.length;
   1.141 +	}
   1.142 +    //
   1.143 +    for(var i = 0; i < minLength; i++) {
   1.144 +		assertEqualsAutoCase(context, descr, expected[i], actual[i]);
   1.145 +    }
   1.146 +    //
   1.147 +    //  if they aren't the same size, they aren't equal
   1.148 +    is(actual.length, expected.length, descr);
   1.149 +  }
   1.150 +
   1.151 +
   1.152 +  function assertEqualsList(descr, expected, actual) {
   1.153 +	var minLength = expected.length;
   1.154 +	if (actual.length < minLength) {
   1.155 +	    minLength = actual.length;
   1.156 +	}
   1.157 +    //
   1.158 +    for(var i = 0; i < minLength; i++) {
   1.159 +        if(expected[i] != actual[i]) {
   1.160 +			    is(actual[i], expected[i], descr);
   1.161 +        }
   1.162 +    }
   1.163 +    //
   1.164 +    //  if they aren't the same size, they aren't equal
   1.165 +    is(actual.length, expected.length, descr);
   1.166 +  }
   1.167 +
   1.168 +  function assertInstanceOf(descr, type, obj) {
   1.169 +    if(type == "Attr") {
   1.170 +        is(2, obj.nodeType, descr);
   1.171 +        var specd = obj.specified;
   1.172 +    }
   1.173 +/*
   1.174 +    else {
   1.175 +      // Ensure at least one SimpleTest check is reported. (Bug 483992)
   1.176 +      todo_is(type, "Attr", "[DOMTestCase.assertInstanceOf()] Fake default check.");
   1.177 +    }
   1.178 +*/
   1.179 +  }
   1.180 +
   1.181 +  function assertSame(descr, expected, actual) {
   1.182 +    if(expected != actual) {
   1.183 +        is(expected.nodeType, actual.nodeType, descr);
   1.184 +        is(expected.nodeValue, actual.nodeValue, descr);
   1.185 +    }
   1.186 +/*
   1.187 +    else {
   1.188 +      // Ensure at least one SimpleTest check is reported. (Bug 483992)
   1.189 +      todo_isnot(expected, actual, "[DOMTestCase.assertSame()] Fake default check." +
   1.190 +                                   " (Type=" + actual.nodeType + ", Value=" + actual.nodeValue + ")");
   1.191 +    }
   1.192 +*/
   1.193 +  }
   1.194 +
   1.195 +  function assertURIEquals(assertID, scheme, path, host, file, name, query, fragment, isAbsolute, actual) {
   1.196 +    //
   1.197 +    //  URI must be non-null
   1.198 +    ok(assertID, "[assertURIEquals()] 'assertID' has a value");
   1.199 +    ok(actual, "[assertURIEquals()] 'actual' has a value");
   1.200 +/*
   1.201 +    // Add missing early return.
   1.202 +    if (!actual)
   1.203 +      return;
   1.204 +*/
   1.205 +
   1.206 +    var uri = actual;
   1.207 +
   1.208 +    var lastPound = actual.lastIndexOf("#");
   1.209 +    var actualFragment = "";
   1.210 +    if(lastPound != -1) {
   1.211 +        //
   1.212 +        //   substring before pound
   1.213 +        //
   1.214 +        uri = actual.substring(0,lastPound);
   1.215 +        actualFragment = actual.substring(lastPound+1);
   1.216 +    }
   1.217 +    if(fragment != null) is(actualFragment, fragment, assertID);
   1.218 +
   1.219 +    var lastQuestion = uri.lastIndexOf("?");
   1.220 +    var actualQuery = "";
   1.221 +    if(lastQuestion != -1) {
   1.222 +        //
   1.223 +        //   substring before pound
   1.224 +        //
   1.225 +        uri = actual.substring(0,lastQuestion);
   1.226 +        actualQuery = actual.substring(lastQuestion+1);
   1.227 +    }
   1.228 +    if(query != null) is(actualQuery, query, assertID);
   1.229 +
   1.230 +    var firstColon = uri.indexOf(":");
   1.231 +    var firstSlash = uri.indexOf("/");
   1.232 +    var actualPath = uri;
   1.233 +    var actualScheme = "";
   1.234 +    if(firstColon != -1 && firstColon < firstSlash) {
   1.235 +        actualScheme = uri.substring(0,firstColon);
   1.236 +        actualPath = uri.substring(firstColon + 1);
   1.237 +    }
   1.238 +
   1.239 +    if(scheme != null) {
   1.240 +        is(scheme, actualScheme, assertID);
   1.241 +    }
   1.242 +
   1.243 +    if(path != null) {
   1.244 +        is(path, actualPath, assertID);
   1.245 +    }
   1.246 +
   1.247 +    if(host != null) {
   1.248 +        var actualHost = "";
   1.249 +        if(actualPath.substring(0,2) == "//") {
   1.250 +            var termSlash = actualPath.substring(2).indexOf("/") + 2;
   1.251 +            actualHost = actualPath.substring(0,termSlash);
   1.252 +        }
   1.253 +        is(actualHost, host, assertID);
   1.254 +    }
   1.255 +
   1.256 +    if(file != null || name != null) {
   1.257 +        var actualFile = actualPath;
   1.258 +        var finalSlash = actualPath.lastIndexOf("/");
   1.259 +        if(finalSlash != -1) {
   1.260 +            actualFile = actualPath.substring(finalSlash+1);
   1.261 +        }
   1.262 +        if (file != null) {
   1.263 +            is(actualFile, file, assertID);
   1.264 +        }
   1.265 +        if (name != null) {
   1.266 +            var actualName = actualFile;
   1.267 +            var finalDot = actualFile.lastIndexOf(".");
   1.268 +            if (finalDot != -1) {
   1.269 +                actualName = actualName.substring(0, finalDot);
   1.270 +            }
   1.271 +            is(actualName, name, assertID);
   1.272 +        }
   1.273 +    }
   1.274 +
   1.275 +    if(isAbsolute != null) {
   1.276 +        is(actualPath.substring(0,1) == "/", isAbsolute, assertID);
   1.277 +    }
   1.278 +  }
   1.279 +
   1.280 +
   1.281 +// size() used by assertSize element
   1.282 +function size(collection)
   1.283 +{
   1.284 +  return collection.length;
   1.285 +}
   1.286 +
   1.287 +function same(expected, actual)
   1.288 +{
   1.289 +  return expected === actual;
   1.290 +}
   1.291 +
   1.292 +function getSuffix(contentType) {
   1.293 +    switch(contentType) {
   1.294 +        case "text/html":
   1.295 +        return ".html";
   1.296 +
   1.297 +        case "text/xml":
   1.298 +        return ".xml";
   1.299 +
   1.300 +        case "application/xhtml+xml":
   1.301 +        return ".xhtml";
   1.302 +
   1.303 +        case "image/svg+xml":
   1.304 +        return ".svg";
   1.305 +
   1.306 +        case "text/mathml":
   1.307 +        return ".mml";
   1.308 +    }
   1.309 +    return ".html";
   1.310 +}
   1.311 +
   1.312 +function equalsAutoCase(context, expected, actual) {
   1.313 +	if (builder.contentType == "text/html") {
   1.314 +		if (context == "attribute") {
   1.315 +			return expected.toLowerCase() == actual;
   1.316 +		}
   1.317 +		return expected.toUpperCase() == actual;
   1.318 +	}
   1.319 +	return expected == actual;
   1.320 +}
   1.321 +
   1.322 +function catchInitializationError(blder, ex) {
   1.323 +       if (blder == null) {
   1.324 +          alert(ex);
   1.325 +       } else {
   1.326 +	      blder.initializationError = ex;
   1.327 +	      blder.initializationFatalError = ex;
   1.328 +	   }
   1.329 +}
   1.330 +
   1.331 +function checkInitialization(blder, testname) {
   1.332 +    if (blder.initializationError != null) {
   1.333 +        // Fake a "warn()" function, as it was missing :-|
   1.334 +        function warn(msg) {
   1.335 +          info("[checkInitialization() warning] " + msg);
   1.336 +        }
   1.337 +
   1.338 +        if (blder.skipIncompatibleTests) {
   1.339 +        	warn(testname + " not run:" + blder.initializationError);
   1.340 +        	return blder.initializationError;
   1.341 +        } else {
   1.342 +        	//
   1.343 +        	//   if an exception was thrown
   1.344 +        	//        rethrow it and do not run the test
   1.345 +            if (blder.initializationFatalError != null) {
   1.346 +        		throw blder.initializationFatalError;
   1.347 +        	} else {
   1.348 +        		//
   1.349 +        		//   might be recoverable, warn but continue the test
   1.350 +        		warn(testname + ": " +  blder.initializationError);
   1.351 +        	}
   1.352 +        }
   1.353 +    }
   1.354 +    return null;
   1.355 +}
   1.356 +function createTempURI(scheme) {
   1.357 +   if (scheme == "http") {
   1.358 +   	  return "http://localhost:8080/webdav/tmp" + Math.floor(Math.random() * 100000) + ".xml";
   1.359 +   }
   1.360 +   return "file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml";
   1.361 +}
   1.362 +
   1.363 +
   1.364 +function EventMonitor() {
   1.365 +  this.atEvents = new Array();
   1.366 +  this.bubbledEvents = new Array();
   1.367 +  this.capturedEvents = new Array();
   1.368 +  this.allEvents = new Array();
   1.369 +}
   1.370 +
   1.371 +EventMonitor.prototype.handleEvent = function(evt) {
   1.372 +    switch(evt.eventPhase) {
   1.373 +       case 1:
   1.374 +       monitor.capturedEvents[monitor.capturedEvents.length] = evt;
   1.375 +       break;
   1.376 +       
   1.377 +       case 2:
   1.378 +       monitor.atEvents[monitor.atEvents.length] = evt;
   1.379 +       break;
   1.380 +
   1.381 +       case 3:
   1.382 +       monitor.bubbledEvents[monitor.bubbledEvents.length] = evt;
   1.383 +       break;
   1.384 +    }
   1.385 +    monitor.allEvents[monitor.allEvents.length] = evt;
   1.386 +}
   1.387 +
   1.388 +function DOMErrorImpl(err) {
   1.389 +  this.severity = err.severity;
   1.390 +  this.message = err.message;
   1.391 +  this.type = err.type;
   1.392 +  this.relatedException = err.relatedException;
   1.393 +  this.relatedData = err.relatedData;
   1.394 +  this.location = err.location;
   1.395 +}
   1.396 +
   1.397 +
   1.398 +
   1.399 +function DOMErrorMonitor() {
   1.400 +  this.allErrors = new Array();
   1.401 +}
   1.402 +
   1.403 +DOMErrorMonitor.prototype.handleError = function(err) {
   1.404 +    errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err);
   1.405 +}
   1.406 +
   1.407 +DOMErrorMonitor.prototype.assertLowerSeverity = function(id, severity) {
   1.408 +    var i;
   1.409 +    for (i = 0; i < errorMonitor.allErrors.length; i++) {
   1.410 +        if (errorMonitor.allErrors[i].severity >= severity) {
   1.411 +           assertEquals(id, severity - 1, errorMonitor.allErrors[i].severity);
   1.412 +        }
   1.413 +    }
   1.414 +}
   1.415 +
   1.416 +function UserDataNotification(operation, key, data, src, dst) {
   1.417 +    this.operation = operation;
   1.418 +    this.key = key;
   1.419 +    this.data = data;
   1.420 +    this.src = src;
   1.421 +    this.dst = dst;
   1.422 +}
   1.423 +
   1.424 +function UserDataMonitor() {
   1.425 +	this.allNotifications = new Array();
   1.426 +}
   1.427 +
   1.428 +UserDataMonitor.prototype.handle = function(operation, key, data, src, dst) {
   1.429 +    userDataMonitor.allNotifications[this.allNotifications.length] =
   1.430 +         new UserDataNotification(operation, key, data, src, dst);
   1.431 +}
   1.432 +
   1.433 +
   1.434 +
   1.435 +function IFrameBuilder() {
   1.436 +    this.contentType = "text/html";
   1.437 +    this.supportedContentTypes = [ "text/html", 
   1.438 +        "text/xml",
   1.439 +        "image/svg+xml",
   1.440 +        "application/xhtml+xml" ];    
   1.441 +
   1.442 +    this.supportsAsyncChange = false;
   1.443 +    this.async = true;
   1.444 +    this.fixedAttributeNames = [
   1.445 +        "validating",  "expandEntityReferences", "coalescing", 
   1.446 +        "signed", "hasNullString", "ignoringElementContentWhitespace", "namespaceAware", "ignoringComments", "schemaValidating"];
   1.447 +
   1.448 +    this.fixedAttributeValues = [false,  true, false, true, true , false, false, true, false ];
   1.449 +    this.configurableAttributeNames = [ ];
   1.450 +    this.configurableAttributeValues = [ ];
   1.451 +    this.initializationError = null;
   1.452 +    this.initializationFatalError = null;
   1.453 +    this.skipIncompatibleTests = false;
   1.454 +}
   1.455 +
   1.456 +IFrameBuilder.prototype.hasFeature = function(feature, version) {
   1.457 +    return document.implementation.hasFeature(feature, version);
   1.458 +}
   1.459 +
   1.460 +IFrameBuilder.prototype.getImplementation = function() {
   1.461 +    return document.implementation;
   1.462 +}
   1.463 +
   1.464 +IFrameBuilder.prototype.setContentType = function(contentType) {
   1.465 +    this.contentType = contentType;
   1.466 +    if (contentType == "text/html") {
   1.467 +        this.fixedAttributeValues[6] = false;
   1.468 +    } else {
   1.469 +        this.fixedAttributeValues[6] = true;
   1.470 +    }
   1.471 +}
   1.472 +
   1.473 +
   1.474 +
   1.475 +IFrameBuilder.prototype.preload = function(frame, varname, url) {
   1.476 +  var suffix;
   1.477 +  if (this.contentType == "text/html" || 
   1.478 +      this.contentType == "application/xhtml+xml") {
   1.479 +      if (url.substring(0,5) == "staff" || url == "nodtdstaff" ||
   1.480 +	  url == "datatype_normalization") { 
   1.481 +  	  suffix = ".xml";
   1.482 +      }  
   1.483 +  }
   1.484 +  
   1.485 +  if (!suffix) suffix = getSuffix(this.contentType);
   1.486 +  
   1.487 +  var iframe = document.createElement("iframe");
   1.488 +  var srcname = url + suffix;
   1.489 +  iframe.setAttribute("name", srcname);
   1.490 +  iframe.setAttribute("src", fileBase + srcname);
   1.491 +  //
   1.492 +  //   HTML and XHTML have onload attributes that will invoke loadComplete
   1.493 +  //       
   1.494 +  if (suffix.indexOf("html") < 0) { 
   1.495 +     iframe.addEventListener("load", loadComplete, false);       
   1.496 +  }
   1.497 +  document.getElementsByTagName("body").item(0).appendChild(iframe);
   1.498 +  return 0; 
   1.499 +}
   1.500 +
   1.501 +IFrameBuilder.prototype.load = function(frame, varname, url) {
   1.502 +  	var suffix;
   1.503 +  	if (url.substring(0,5) == "staff" || url == "nodtdstaff" || url == "datatype_normalization") { 
   1.504 +  	  suffix = ".xml";
   1.505 +  	}
   1.506 +  	if (!suffix) suffix = getSuffix(this.contentType);
   1.507 +    var name = url + suffix;
   1.508 +    var iframes = document.getElementsByTagName("iframe");
   1.509 +    for(var i = 0; i < iframes.length; i++) {
   1.510 +       if (iframes.item(i).getAttribute("name") == name) {
   1.511 +           var item = iframes.item(i);
   1.512 +           if (typeof(item.contentDocument) != 'undefined') {
   1.513 +               return item.contentDocument;
   1.514 +           }
   1.515 +           if (typeof(item.document) != 'undefined') {
   1.516 +           	   return item.document;
   1.517 +           }
   1.518 +           return null;
   1.519 +       }
   1.520 +    }
   1.521 +    return null;
   1.522 +}
   1.523 +
   1.524 +IFrameBuilder.prototype.getImplementationAttribute = function(attr) {
   1.525 +    for (var i = 0; i < this.fixedAttributeNames.length; i++) {
   1.526 +        if (this.fixedAttributeNames[i] == attr) {
   1.527 +            return this.fixedAttributeValues[i];
   1.528 +        }
   1.529 +    }
   1.530 +    throw "Unrecognized implementation attribute: " + attr;
   1.531 +}
   1.532 +
   1.533 +
   1.534 +
   1.535 +IFrameBuilder.prototype.setImplementationAttribute = function(attribute, value) {
   1.536 +    var supported = this.getImplementationAttribute(attribute);
   1.537 +    if (supported != value) {
   1.538 +        this.initializationError = "IFrame loader does not support " + attribute + "=" + value;
   1.539 +    }
   1.540 +}
   1.541 +
   1.542 +
   1.543 +IFrameBuilder.prototype.canSetImplementationAttribute = function(attribute, value) {
   1.544 +    var supported = this.getImplementationAttribute(attribute);
   1.545 +    return (supported == value);
   1.546 +}
   1.547 +
   1.548 +
   1.549 +function createBuilder(implementation) {
   1.550 +  if (implementation == null) {
   1.551 +  	return new IFrameBuilder();
   1.552 +  }
   1.553 +  switch(implementation) {
   1.554 +/*    case "msxml3":
   1.555 +    return new MSXMLBuilder("Msxml2.DOMDocument.3.0");
   1.556 +    
   1.557 +    case "msxml4":
   1.558 +    return new MSXMLBuilder("Msxml2.DOMDocument.4.0");*/
   1.559 +
   1.560 +    case "mozillaXML":
   1.561 +    return new MozillaXMLBuilder();
   1.562 +/*
   1.563 +    case "svgplugin":
   1.564 +    return new SVGPluginBuilder();
   1.565 +
   1.566 +    case "dom3ls":
   1.567 +    return new DOM3LSBuilder(); */
   1.568 +    
   1.569 +    case "iframe":
   1.570 +    return new IFrameBuilder();
   1.571 +
   1.572 +    case "xmlhttprequest":
   1.573 +    return new XMLHttpRequestBuilder();
   1.574 +    
   1.575 +    default:
   1.576 +    alert ("unrecognized implementation " + implementation);
   1.577 +  }
   1.578 +  return new IFrameBuilder();
   1.579 +}
   1.580 +
   1.581 +function checkFeature(feature, version)
   1.582 +{
   1.583 +  if (!builder.hasFeature(feature, version))
   1.584 +  {
   1.585 +    //
   1.586 +    //   don't throw exception so that users can select to ignore the precondition
   1.587 +    //
   1.588 +    builder.initializationError = "builder does not support feature " + feature + " version " + version;
   1.589 +  }
   1.590 +}
   1.591 +
   1.592 +function createConfiguredBuilder() {
   1.593 +	var builder = null;
   1.594 +	var contentType = null;
   1.595 +	var i;
   1.596 +	var contentTypeSet = false;
   1.597 +	var parm = null;
   1.598 +	builder = new IFrameBuilder();
   1.599 +	return builder;
   1.600 +}
   1.601 +
   1.602 +
   1.603 +function preload(frame, varname, url) {
   1.604 +  return builder.preload(frame, varname, url);
   1.605 +}
   1.606 +
   1.607 +function load(frame, varname, url) {
   1.608 +    return builder.load(frame, varname, url);
   1.609 +}
   1.610 +
   1.611 +function getImplementationAttribute(attr) {
   1.612 +    return builder.getImplementationAttribute(attr);
   1.613 +}
   1.614 +
   1.615 +
   1.616 +function setImplementationAttribute(attribute, value) {
   1.617 +    builder.setImplementationAttribute(attribute, value);
   1.618 +}
   1.619 +
   1.620 +function setAsynchronous(value) {
   1.621 +    if (builder.supportsAsyncChange) {
   1.622 +      builder.async = value;
   1.623 +    } else {
   1.624 +      update();
   1.625 +    }
   1.626 +}
   1.627 +
   1.628 +
   1.629 +function createXPathEvaluator(doc) {
   1.630 +    try {
   1.631 +        return doc.getFeature("XPath", null);
   1.632 +    }
   1.633 +    catch(ex) {
   1.634 +    }
   1.635 +    return doc;
   1.636 +}
   1.637 +
   1.638 +function toLowerArray(src) {
   1.639 +   var newArray = new Array();
   1.640 +   var i;
   1.641 +   for (i = 0; i < src.length; i++) {
   1.642 +      newArray[i] = src[i].toLowerCase();
   1.643 +   }
   1.644 +   return newArray;
   1.645 +}
   1.646 +
   1.647 +function MSXMLBuilder_onreadystatechange() {
   1.648 +    if (builder.parser.readyState == 4) {
   1.649 +        loadComplete();
   1.650 +    }
   1.651 +}
   1.652 +
   1.653 +
   1.654 +
   1.655 +var fileBase = location.href;
   1.656 +if (fileBase.indexOf('?') != -1) {
   1.657 +   fileBase = fileBase.substring(0, fileBase.indexOf('?'));
   1.658 +}
   1.659 +fileBase = fileBase.substring(0, fileBase.lastIndexOf('/') + 1) + "files/";
   1.660 +
   1.661 +function getResourceURI(name, scheme, contentType) {
   1.662 +    return fileBase + name + getSuffix(contentType);
   1.663 +}
   1.664 +
   1.665 +
   1.666 +function getImplementation() {
   1.667 +    return builder.getImplementation();
   1.668 +}
   1.669 +
   1.670 +/*
   1.671 +// Count of failures overridden as todos.
   1.672 +var gFailuresAsTodos = 0;
   1.673 +
   1.674 +// Override SimpleTest result logger.
   1.675 +var ST_logResult = SimpleTest._logResult;
   1.676 +SimpleTest._logResult = function overrideSTlR(test, passString, failString) {
   1.677 +  if (todoTests[docName] && !test.result && !test.todo) {
   1.678 +    test.name = "[failure as todo] " + test.name;
   1.679 +    test.todo = true;
   1.680 +    failString = "TEST-KNOWN-FAIL";
   1.681 +
   1.682 +    ++gFailuresAsTodos;
   1.683 +  }
   1.684 +
   1.685 +  ST_logResult(test, passString, failString);
   1.686 +}
   1.687 +*/
   1.688 +
   1.689 +window.doc = window;  
   1.690 +SimpleTest.waitForExplicitFinish();
   1.691 +addLoadEvent(function(){ setUpPage(); });
   1.692 +
   1.693 +/*
   1.694 +// Actual marking code is in overrideSTlR() now.
   1.695 +function markTodos() {
   1.696 +  if (todoTests[docName]) {
   1.697 +    isnot(gFailuresAsTodos, 0, "test marked todo should have failed somewhere");
   1.698 +  }
   1.699 +}
   1.700 +*/
   1.701 +
   1.702 +function runJSUnitTests() {
   1.703 +  builder = createConfiguredBuilder();
   1.704 +  try {
   1.705 +    var tests = exposeTestFunctionNames(); 
   1.706 +    for (var i = 0; i < tests.length; i++) {
   1.707 +      window[tests[i]](); 
   1.708 +    }
   1.709 +  } catch (ex) {
   1.710 +/*
   1.711 +    if (todoTests[docName]) {
   1.712 +      todo(false, "[failure as todo] Test threw exception: " + ex);
   1.713 +      ++gFailuresAsTodos;
   1.714 +    } else { 
   1.715 +*/
   1.716 +      ok(false, "Test threw exception: " + ex);
   1.717 +/*
   1.718 +    }
   1.719 +*/
   1.720 +  }
   1.721 +}

mercurial