/* Copyright (c) 2001-2005 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. This program is distributed under the W3C's Software Intellectual Property License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
function assertNull(descr, actual) { return ok(actual === null, descr);
}
function assertNotNull(descr, actual) { return ok(actual !== null, descr);
}
function assertTrue(descr, actual) { return ok(actual === true, descr);
}
function assertFalse(descr, actual) { return ok(actual === false, descr);
}
function assertEquals(descr, expected, actual) { return is(expected, actual, descr);
}
function assertSize(descr, expected, actual) {
ok(actual !== null, descr); /* // Work around too strict checks. if (!actual) { ok(actual, "[assertSize()] 'actual' has a value"); return; }
*/
function assertEqualsCollectionAutoCase(context, descr, expected, actual) { // // if they aren't the same size, they aren't equal
is(actual.length, expected.length, descr);
// // if there length is the same, then every entry in the expected list // must appear once and only once in the actual list var expectedLen = expected.length; var expectedValue; var actualLen = actual.length; var i; var j; var matches; for(i = 0; i < expectedLen; i++) {
matches = 0;
expectedValue = expected[i]; for(j = 0; j < actualLen; j++) { if (builder.contentType == "text/html") { if (context == "attribute") { if (expectedValue.toLowerCase() == actual[j].toLowerCase()) {
matches++;
}
} else { if (expectedValue.toUpperCase() == actual[j]) {
matches++;
}
}
} else { if(expectedValue == actual[j]) {
matches++;
}
}
} if(matches == 0) {
ok(false, descr + ": No match found for " + expectedValue);
} if(matches > 1) {
ok(false, descr + ": Multiple matches found for " + expectedValue);
}
}
}
function assertEqualsCollection(descr, expected, actual) { // // if they aren't the same size, they aren't equal
is(actual.length, expected.length, descr); // // if there length is the same, then every entry in the expected list // must appear once and only once in the actual list var expectedLen = expected.length; var expectedValue; var actualLen = actual.length; var i; var j; var matches; for(i = 0; i < expectedLen; i++) {
matches = 0;
expectedValue = expected[i]; for(j = 0; j < actualLen; j++) { if(expectedValue == actual[j]) {
matches++;
}
} if(matches == 0) {
ok(false, descr + ": No match found for " + expectedValue);
} if(matches > 1) {
ok(false, descr + ": Multiple matches found for " + expectedValue);
}
}
}
function assertEqualsListAutoCase(context, descr, expected, actual) { var minLength = expected.length; if (actual.length < minLength) {
minLength = actual.length;
} // for(var i = 0; i < minLength; i++) {
assertEqualsAutoCase(context, descr, expected[i], actual[i]);
} // // if they aren't the same size, they aren't equal
is(actual.length, expected.length, descr);
}
function assertEqualsList(descr, expected, actual) { var minLength = expected.length; if (actual.length < minLength) {
minLength = actual.length;
} // for(var i = 0; i < minLength; i++) { if(expected[i] != actual[i]) {
is(actual[i], expected[i], descr);
}
} // // if they aren't the same size, they aren't equal
is(actual.length, expected.length, descr);
}
function assertInstanceOf(descr, type, obj) { if(type == "Attr") {
is(2, obj.nodeType, descr); var specd = obj.specified;
} /* else { // Ensure at least one SimpleTest check is reported. (Bug 483992) todo_is(type, "Attr", "[DOMTestCase.assertInstanceOf()] Fake default check."); }
*/
}
function assertURIEquals(assertID, scheme, path, host, file, name, query, fragment, isAbsolute, actual) { // // URI must be non-null
ok(assertID, "[assertURIEquals()] 'assertID' has a value");
ok(actual, "[assertURIEquals()] 'actual' has a value"); /* // Add missing early return. if (!actual) return;
*/
var uri = actual;
var lastPound = actual.lastIndexOf("#"); var actualFragment = ""; if(lastPound != -1) { // // substring before pound //
uri = actual.substring(0,lastPound);
actualFragment = actual.substring(lastPound+1);
} if(fragment != null) is(actualFragment, fragment, assertID);
var lastQuestion = uri.lastIndexOf("?"); var actualQuery = ""; if(lastQuestion != -1) { // // substring before pound //
uri = actual.substring(0,lastQuestion);
actualQuery = actual.substring(lastQuestion+1);
} if(query != null) is(actualQuery, query, assertID);
var firstColon = uri.indexOf(":"); var firstSlash = uri.indexOf("/"); var actualPath = uri; var actualScheme = ""; if(firstColon != -1 && firstColon < firstSlash) {
actualScheme = uri.substring(0,firstColon);
actualPath = uri.substring(firstColon + 1);
}
function checkInitialization(blder, testname) { if (blder.initializationError != null) { // Fake a "warn()" function, as it was missing :-| function warn(msg) {
info("[checkInitialization() warning] " + msg);
}
if (blder.skipIncompatibleTests) {
warn(testname + " not run:" + blder.initializationError); return blder.initializationError;
} else { // // if an exception was thrown // rethrow it and do not run the test if (blder.initializationFatalError != null) { throw blder.initializationFatalError;
} else { // // might be recoverable, warn but continue the test
warn(testname + ": " + blder.initializationError);
}
}
} returnnull;
} function createTempURI(scheme) { if (scheme == "http") { return"http://localhost:8080/webdav/tmp" + Math.floor(Math.random() * 100000) + ".xml";
} return"file:///tmp/domts" + Math.floor(Math.random() * 100000) + ".xml";
}
function EventMonitor() { this.atEvents = new Array(); this.bubbledEvents = new Array(); this.capturedEvents = new Array(); this.allEvents = new Array();
}
function createBuilder(implementation) { if (implementation == null) { returnnew IFrameBuilder();
} switch(implementation) { /* case "msxml3": return new MSXMLBuilder("Msxml2.DOMDocument.3.0"); case "msxml4":
return new MSXMLBuilder("Msxml2.DOMDocument.4.0");*/
case"mozillaXML": returnnew MozillaXMLBuilder(); /* case "svgplugin": return new SVGPluginBuilder();
function checkFeature(feature, version)
{ if (!builder.hasFeature(feature, version))
{ // // don't throw exception so that users can select to ignore the precondition //
builder.initializationError = "builder does not support feature " + feature + " version " + version;
}
}
function createConfiguredBuilder() { var builder = null; var contentType = null; var i; var contentTypeSet = false; var parm = null;
builder = new IFrameBuilder(); return builder;
}
function preload(frame, varname, url) { return builder.preload(frame, varname, url);
}
function load(frame, varname, url) { return builder.load(frame, varname, url);
}
function getImplementationAttribute(attr) { return builder.getImplementationAttribute(attr);
}
function setImplementationAttribute(attribute, value) {
builder.setImplementationAttribute(attribute, value);
}
function setAsynchronous(value) { if (builder.supportsAsyncChange) {
builder.async = value;
} else {
update();
}
}
function toLowerArray(src) { var newArray = new Array(); var i; for (i = 0; i < src.length; i++) {
newArray[i] = src[i].toLowerCase();
} return newArray;
}
function MSXMLBuilder_onreadystatechange() { if (builder.parser.readyState == 4) {
loadComplete();
}
}
// Actual marking code is in overrideSTlR() now. function markTodos() { if (todoTests[docName]) {
isnot(gFailuresAsTodos, 0, "test marked todo should have failed somewhere");
}
}
function runJSUnitTests() {
builder = createConfiguredBuilder(); try { var tests = exposeTestFunctionNames(); for (var i = 0; i < tests.length; i++) {
window[tests[i]]();
}
} catch (ex) { if (todoTests[docName]) {
todo(false, "[failure as todo] Test threw exception: " + ex);
++gFailuresAsTodos;
} else {
ok(false, "Test threw exception: " + ex);
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.