1. Introduction
The web-platform-tests project serves as a cross-browser test suite for the Web platform stack. By crafting tests that can run seamlessly across all browsers, browser projects gain assurance that their software aligns with other implementations. This confidence extends to future implementations, ensuring compatibility. Consequently, web authors and developers can trust the Web platform to fulfill its promise of seamless functionality across browsers and devices, eliminating the need for additional layers of abstraction to address gaps introduced by specification editors and implementors.For your information, the Web Platform Test Community operates a dashboard that tracks the pass ratio of tests across major web browsers. The chart below displays the number of failing tests in major browsers over time, with Chrome showing the lowest failure rate.
And, the below chart shows the interoperability of the web platform technology for 2023 among major browsers. The interoperability has been improving.
2. Test Suite Design
The majority of the test suite is made up of HTML pages that are designed to be loaded in a browser. These pages may either generate results programmatically or provide a set of steps for executing the test and obtaining the outcome. Overall, the tests are concise, cross-platform, and self-contained, making them easy to run in any browser.2.1 Test Layout
Most primary directories within the repository are dedicated to tests associated with specific web standards. For W3C specifications, these directories typically use the short name of the spec, which is the name used for snapshot publications under the /TR/ path. For WHATWG specifications, the directories are usually named after the spec’s subdomain, omitting “.spec.whatwg.org” from the URL. Other specifications follow a logical naming convention.The
css/
directory contains test suites specifically designed for the CSS Working Group specifications.Within each specification-specific directory, tests are organized in one of two common ways: a flat structure, sometimes used for shorter specifications, or a nested structure, where each subdirectory corresponds to the ID of a heading within the specification. The nested structure, which provides implicit metadata about the tested section of the specification based on its location in the filesystem, is preferred for larger specifications.
For example, tests related to “The History interface” in HTML can be found in
html/browsers/history/the-history-interface/
.Many directories also include a file named
META.yml
, which may define properties such as:
spec
: a link to the specification covered by the tests in the directorysuggested_reviewers
: a list of GitHub usernames for individuals who are notified when pull requests modify files in the directory
2.2 Test Types
Tests in this project employ various approaches to validate expected behavior, with classifications based on how expectations are expressed:- Rendering Tests:
- Reftests: Compare the graphical rendering of two (or more) web pages, asserting equality in their display (e.g., A.html and B.html must render identically). This can be done manually by users switching between tabs/windows or through automated scripts.
- Visual Tests: Evaluate a page’s appearance, with results determined either by human observation or by comparing it with a saved screenshot specific to the user agent and platform.
- JavaScript Interface Tests (testharness.js tests):
- Ensure that JavaScript interfaces behave as expected. Named after the JavaScript harness used to execute them.
- WebDriver Browser Automation Protocol Tests (wdspec tests):
- Written in Python, these tests validate the WebDriver browser automation protocol.
- Manual Tests rely on a human to run them and determine their result.
3. Web Platform Test in Chromium
The Chromium project conducts web tests utilized by Blink to assess various components, encompassing, but not limited to, layout and rendering. Generally, these web tests entail loading pages in a test renderer (content_shell) and comparing the rendered output or JavaScript output with an expected output file. The Web Tests include “Web platform tests”(WPT) located at web_tests/external/wpt. Other directories are for Chrome-specific tests only. In the web_tests/external/wpt, there are around 50,000 web platform tests currently.3.1 Web Tests in the Chromium development process
Every patch must pass all tests before it can be merged into the main source tree. In Gerrit, trybots execute a wide array of tests, including the Web Test, to ensure this. We can initiate these trybots with a specific patch, and each trybot will then run the scheduled tests using that patch.For example, the linux-rel trybot runs the web tests in the blink_web_tests step as below,