Skip to content

Commit

Permalink
Update ResourceTiming style guide to explain asserts vs. errors
Browse files Browse the repository at this point in the history
In ResourceTiming Web Platform Tests, we want to use assertion failures
to indicate divergence from the spec but use exceptions to indicate
issues with the test code.

This change updates the style guide to call out this goal.

Bug: 1171767
Change-Id: If9df3b05de75cbb516bc5c9f1ac0897abac0b4ab
GithubIssue: w3c/resource-timing#254
  • Loading branch information
tommckee1 authored and chromium-wpt-export-bot committed Feb 19, 2021
1 parent b55cf43 commit 11b7c59
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions resource-timing/CodingConventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ with recurring patterns.
web performance APIs, in general).
* Prefer [`fetch_tests_from_window`][3] to collect test results from embedded
iframes instead of hand-rolled `postMessage` approaches
* Use the [`assert_*`][4] family of functions to check conformance to the spec
but throw exceptions when the test itself is broken.
* A failed assert indicates "the implementation doesn't conform to the
spec"
* An uncaught exception indicates "the test case itself has a bug"
* Where possible, we want tests to be scalable - adding another test case
should be as simple as calling the tests with new parameters, rather than
copying an existing test and modifying it.

[1]: https://www.w3.org/TR/resource-timing-2/
[2]: https://web-platform-tests.org/writing-tests/testharness-api.html#promise-tests
[3]: https://web-platform-tests.org/writing-tests/testharness-api.html#consolidating-tests-from-other-documents
[4]: https://web-platform-tests.org/writing-tests/testharness-api.html#list-of-assertions

0 comments on commit 11b7c59

Please sign in to comment.