- From: Kris Krueger via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 25 Feb 2010 15:44:18 +0000
- To: public-html-commits@w3.org
Update of /sources/public/html5/tests/submission/Microsoft/htmldom In directory hutz:/tmp/cvs-serv14611/submission/Microsoft/htmldom Added Files: DOMTestCase.js Log Message: Initial add of the js support file needed to run tests. This is a copy of the many usefull 'assert' functions from the original DOMTestCase.js --- NEW FILE: DOMTestCase.js --- /* Copyright (c) 2001-2004 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 contentType() { if ( document.mimeType == "HTML Document" ) { return "text/html"; } } // // These all throw upon assertion failures // function assertTrue(description, state) { var szError = "assertTrue failure\r\n"; if (!state) { throw szError; } } function assertFalse(description, state) { var szError = "assertFalse failure\r\n"; if (state) { throw szError; } } function assertNull(description, actual) { var szError = "assertNull failure: non-null parameter\r\n"; if (description == null || actual != null) { throw szError; } } function assertNotNull(description, actual) { var szError = "assertNotNull failure: null parameter\r\n"; if (description == null || actual == null) { throw szError; } } function assertEquals(description, expected, actual) { var szError = description + " assertEquals failure: \r\n"; if (expected != actual) { szError = szError + "expected=" + expected + " \r\n"; szError = szError + "actual=" + actual + " \r\n"; throw szError; } } function assertSize(descr, expected, actual) { var actualSize; assertNotNull(descr, actual); actualSize = actual.length; assertEquals(descr, expected, actualSize); } 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]) { assertEquals(descr, expected[i], actual[i]); } } // // if they aren't the same size, they aren't equal assertEquals(descr, expected.length, actual.length); } function assertInstanceOf(descr, type, obj) { if(type == "Attr") { assertEquals(descr,2,obj.nodeType); var specd = obj.specified; } } function assertSame(descr, expected, actual) { if(expected != actual) { assertEquals(descr, expected.nodeType, actual.nodeType); assertEquals(descr, expected.nodeValue, actual.nodeValue); } } function assertEqualsAutoCase(context, descr, expected, actual) { if (contentType() == "text/html") { if(context == "attribute") { assertEquals(descr, expected.toLowerCase(), actual.toLowerCase()); } else { assertEquals(descr, expected.toUpperCase(), actual); } } else { assertEquals(descr, expected, actual); } } function assertEqualsCollectionAutoCase(context, descr, expected, actual) { // // if they aren't the same size, they aren't equal assertEquals(descr, expected.length, actual.length); // // 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 (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) { assert(descr + ": No match found for " + expectedValue,false); } if (matches > 1) { assert(descr + ": Multiple matches found for " + expectedValue, false); } } } 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 assertEquals(descr, expected.length, actual.length); } function assertURIEquals(assertID, scheme, path, host, file, name, query, fragment, isAbsolute, actual) { // // URI must be non-null assertNotNull(assertID, actual); 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) assertEquals(assertID,fragment, actualFragment); 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) assertEquals(assertID, query, actualQuery); 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); } if(scheme != null) { assertEquals(assertID, scheme, actualScheme); } if(path != null) { assertEquals(assertID, path, actualPath); } if(host != null) { var actualHost = ""; if(actualPath.substring(0,2) == "//") { var termSlash = actualPath.substring(2).indexOf("/") + 2; actualHost = actualPath.substring(0,termSlash); } assertEquals(assertID, host, actualHost); } if(file != null || name != null) { var actualFile = actualPath; var finalSlash = actualPath.lastIndexOf("/"); if(finalSlash != -1) { actualFile = actualPath.substring(finalSlash+1); } if (file != null) { assertEquals(assertID, file, actualFile); } if (name != null) { var actualName = actualFile; var finalDot = actualFile.lastIndexOf("."); if (finalDot != -1) { actualName = actualName.substring(0, finalDot); } assertEquals(assertID, name, actualName); } } if(isAbsolute != null) { assertEquals(assertID, isAbsolute, actualPath.substring(0,1) == "/"); } } function getImplementation() { return document.implementation; } function checkInitialization() { return; } function load(documentRefrence) { return documentRefrence.document; }
Received on Thursday, 25 February 2010 15:44:20 UTC