/* Distributed under both the W3C Test Suite License [1] and the W3C 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the policies and contribution forms [3]. [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license [3] http://www.w3.org/2004/10/27-testcases */ /* * == Introduction == * * This file provides a framework for writing testcases. It is intended to * provide a convenient API for making common assertions, and to work both * for testing synchronous and asynchronous DOM features in a way that * promotes clear, robust, tests. * * == Basic Usage == * * To use this file, import the script and the testharnessreport script into * the test document: * * * * Within each file one may define one or more tests. Each test is atomic * in the sense that a single test has a single result (pass/fail/timeout). * Within each test one may have a number of asserts. The test fails at the * first failing assert, and the remainder of the test is (typically) not run. * * If the file containing the tests is a HTML file with an element of id "log" * this will be populated with a table containing the test results after all * the tests have run. * * NOTE: By default tests must be created before the load event fires. For ways * to create tests after the load event, see "Determining when all tests * are complete", below * * == Synchronous Tests == * * To create a synchronous test use the test() function: * * test(test_function, name, properties) * * test_function is a function that contains the code to test. For example a * trivial passing test would be: * * test(function() {assert_true(true)}, "assert_true with true") * * The function passed in is run in the test() call. * * properties is an object that overrides default test properties. The * recognised properties are: * timeout - the test timeout in ms * * e.g. * test(test_function, "Sample test", {timeout:1000}) * * would run test_function with a timeout of 1s. * * Additionally, test-specific metadata can be passed in the properties. These * are used when the individual test has different metadata from that stored * in the
. * The recognized metadata properties are: * * help - The url of the part of the specification being tested * * assert - A human readable description of what the test is attempting * to prove * * author - Name and contact information for the author of the test in the * format: "NameResult | Test Name | " + (assertions ? "Assertion | " : "") + "Message |
---|---|---|---|
' + escape_html(status_text[tests[i].status]) + " | " + escape_html(tests[i].name) + " | " + (assertions ? escape_html(get_assertion(tests[i])) + " | " : "") + escape_html(tests[i].message ? tests[i].message : " ") + " |