The web-platform-tests Project

The web-platform-tests Project is a W3C-coordinated attempt to build a cross-browser test suite for the Web-platform stack.  Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations.  This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors. 

Setting Up the Repo

Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune (or git fetch -p && git merge). 

Running the Tests

The tests are designed to be run from your local computer.  The test environment requires Python 2.7+ (but not Python 3.x). 

If you are behind a proxy, you also need to make sure the domains above are excluded from your proxy lookups. 

Running Tests Manually

The test server can be started using

./wpt serve

On Windows: You will need to precede the prior command with python or the path to the python binary. 

python wpt serve

This will start HTTP servers on two ports and a websockets server on one port.  By default the web servers start on ports 8000 and 8443 and the other ports are randomly-chosen free ports.  Tests must be loaded from the first HTTP server in the output.  To change the ports, create a config.json file in the wpt root directory, and add port definitions of your choice e.g.:

{
"ports": {
"http": [1234, "auto"],
"https":[5678]
}
}

After your hosts file is configured, the servers will be locally accessible at:

Running Tests Automatically

Tests can be run automatically in a browser using the run command of the wpt script in the root of the checkout.  This requires the hosts file setup documented above, but you must not have the test server already running when calling wpt run.  The basic command line syntax is:

./wpt run product [tests]

On Windows: You will need to precede the prior command with python or the path to the python binary. 

python wpt run product [tests]

where product is currently firefox or chrome and [tests] is a list of paths to tests.  This will attempt to automatically locate a browser instance and install required dependencies.  The command is very configurable; for example to specify a particular binary use wpt run --binary=path product.  The full range of options can be see with wpt run --help and wpt run --wptrunner-help. 

Not all dependencies can be automatically installed; in particular the certutil tool required to run https tests with Firefox must be installed using a system package manager or similar. 

On Debian/Ubuntu certutil may be installed using:

sudo apt install libnss3-tools

And on macOS with homebrew using:

brew install nss

On other platforms, download the firefox archive and common.tests.tar.gz archive for your platform from Mozilla CI. 

Then extract certutil[.exe] from the tests.tar.gz package and libnss3[.so|.dll|.dynlib] and put the former on your path and the latter on your library path. 

Command Line Tools

The wpt command provides a frontend to a variety of tools for working with and running web-platform-tests.  Some of the most useful commands are:

Publication

Pull requests are automatically mirrored except those that modify sensitive resources (such as .py).  The latter require someone with merge access to comment with “LGTM” or “w3c-test:mirror” to indicate the pull request has been checked. 

Finding Things

Each top-level directory matches the shortname used by a standard, with some exceptions. ( Typically the shortname is from the standard's corresponding GitHub repository.) 

For some of the specifications, the tree under the top-level directory represents the sections of the respective documents, using the section IDs for directory names, with a maximum of three levels deep. 

So if you're looking for tests in HTML for “The History interface”, they will be under html/browsers/history/the-history-interface/.

Various resources that tests depend on are in common, images, and fonts. 

Branches

In the vast majority of cases the only upstream branch that you should need to care about is master.  If you see other branches in the repository, you can generally safely ignore them. 

Contributing

Save the Web, Write Some Tests! 

Absolutely everyone is welcome (and even encouraged) to contribute to test development, so long as you fulfill the contribution requirements detailed in the Contributing Guidelines.  No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser. 

The way to contribute is just as usual:

Fork this repository (and make sure you're still relatively in sync with it if you forked a while ago). 

Create a branch for your changes: git checkout -b topic. 

Make your changes. 

Run the lint script described below. 

Commit locally and push that to your repo. 

Send in a pull request based on the above. 

Issues with web-platform-tests

If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue.  Thank you! 

Lint tool

We have a lint tool for catching common mistakes in test files.  You can run it manually by starting the lint executable from the root of your local web-platform-tests working directory like this:

./wpt lint

The lint tool is also run automatically for every submitted pull request, and reviewers will not merge branches with tests that have lint errors, so you must fix any errors the lint tool reports. 

In the unusual case of error reports for things essential to a certain test or that for other exceptional reasons shouldn't prevent a merge of a test, update and commit the lint.whitelist file in the web-platform-tests root directory to suppress the error reports.