servo/tests/wpt/web-platform-tests/resources/test
2019-04-19 00:12:29 -04:00
..
tests Update web-platform-tests to revision e3cf1284464a4a3e46fd15e4138f8e32c6cecdd8 2019-04-19 00:12:29 -04:00
conftest.py Update web-platform-tests to revision e7517084404fca126c4f89eb69217206689adf17 2018-12-22 22:32:34 -05:00
harness.html Update web-platform-tests to revision a46616a5b18e83587ddbbed756c7b96cbb4b015d 2017-10-05 00:42:13 +02:00
idl-helper.js Update web-platform-tests to revision a89693b62066da0e4808c0bc76c581188398e73d 2018-05-24 23:21:05 -04:00
README.md Update web-platform-tests to revision c2b30ef30749b6a8f2cc832761dfe011e63d5e94 2018-10-05 23:00:35 -04:00
tox.ini Update web-platform-tests to revision e7517084404fca126c4f89eb69217206689adf17 2018-12-22 22:32:34 -05:00
variants.js Update web-platform-tests to revision be959408023fe02cf79abe70f6018598a7004a88 2018-06-11 23:36:57 -04:00
wptserver.py Update web-platform-tests to revision 36634cbcf3253dfe8d220990a27ad4eeebf8ec2f 2018-09-27 23:48:13 -04:00

testharness.js test suite

The test suite for the testharness.js testing framework.

Executing Tests

Install the following dependencies:

Make sure geckodriver can be found in your PATH.

Currently, the tests should be run with the latest Firefox Nightly. In order to specify the path to Firefox Nightly, use the following command-line option:

tox -- --binary=/path/to/FirefoxNightly

Automated Script

Alternatively, you may run tools/ci/ci_resources_unittest.sh, which only depends on Python 2. The script will install other dependencies automatically and start tox with the correct arguments.

Authoring Tests

Test cases are expressed as .html files located within the tests/unit/ and tests/functional/ sub-directories. Each test should include the testharness.js library with the following markup:

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

This should be followed by one or more <script> tags that interface with the testharness.js API in some way. For example:

<script>
test(function() {
    1 = 1;
  }, 'This test is expected to fail.');
</script>

Unit tests

The "unit test" type allows for concisely testing the expected behavior of assertion methods. These tests may define any number of sub-tests; the acceptance criteria is simply that all tests executed pass.

Functional tests

Thoroughly testing the behavior of the harness itself requires ensuring a number of considerations which cannot be verified with the "unit testing" strategy. These include:

  • Ensuring that some tests are not run
  • Ensuring conditions that cause test failures
  • Ensuring conditions that cause harness errors

Functional tests allow for these details to be verified. Every functional test must include a summary of the expected results as a JSON string within a <script> tag with an id of "expected", e.g.:

<script type="text/json" id="expected">
{
  "summarized_status": {
    "message": null,
    "stack": null,
    "status_string": "OK"
  },
  "summarized_tests": [
    {
      "message": "ReferenceError: invalid assignment left-hand side",
      "name": "Sample HTML5 API Tests",
      "properties": {},
      "stack": "(implementation-defined)",
      "status_string": "FAIL"
    }
  ],
  "type": "complete"
}
</script>

testharness.js is expected to function consistently in a number of distinct environments. In order to verify this expectation, each functional test may be executed under a number of distinct conditions. These conditions are applied using WPT's "test variants" pattern. The available variants are defined in the variants.js file; this file must be included before testharness.js. Every test must specify at least one variant.