Skip to content

URL: Use test data from web-platform-tests for isURL spec conformance #20534

@aduth

Description

@aduth

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 need input and failure properties for our purposes. For easy updates, we could consider writing an ad hoc script within the url package whose implementation would download and transform the latest version.

Metadata

Metadata

Assignees

Labels

[Package] Url/packages/url[Status] In ProgressTracking issues with work in progress[Type] Automated TestingTesting infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.[Type] TaskIssues or PRs that have been broken down into an individual action to take

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions