-
Notifications
You must be signed in to change notification settings - Fork 4.8k
URL: Use test data from web-platform-tests for isURL spec conformance #20534
Description
The @wordpress/url implementation of isURL is documented as to conform to the URL Standard definition of a valid URL string. There are test cases to verify this behavior, but they are written ad hoc based on our own understanding of what should and should not be considered a valid URL.
However, there is a canonical resource for test data associated with web standards:
https://github.com/web-platform-tests/wpt
Specifically, there is test data provided which can be used to assert whether a given input should be considered valid:
https://github.com/web-platform-tests/wpt/blob/master/url/resources/urltestdata.json
Per #20435 (comment), our current alignment of "valid" only checks whether a parse would fail. In the above data set, this is reflected as the "failure": true object value.
Task: Use urltestdata.json from the above repository as reference data to use in our own isURL tests.
Implementation Notes:
- Note that the URL standard is a living standard, and as such may change over time. Additionally, the web-platform-tests project may seek to add or change the test cases. Based on this, we should anticipate that the test data may need to update to use a more recent copy.
- We could choose to load the file over the network by referencing the repository URL, but we should be mindful to avoid inadvertent test failures caused by network instability.
- We should not want the tests to suddenly fail, thus the test data should be pinned to a specific version that we can update as needed.
- In mind of all of the above, we probably want a local copy of
urltestdata.json, optionally reduced to the minimal set of properties, since we only needinputandfailureproperties for our purposes. For easy updates, we could consider writing an ad hoc script within theurlpackage whose implementation would download and transform the latest version.