• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

resources/H03-May-2022-10,32010,308

META.ymlH A D31-Mar-2022120 87

README.mdH A D31-Mar-20222.7 KiB5843

a-element-origin-xhtml.xhtmlH A D31-Mar-2022448 1614

a-element-xhtml.xhtmlH A D31-Mar-2022441 1614

README.md

1## urltestdata.json
2
3These tests are for browsers, but the data for
4`a-element.html`, `url-constructor.html`, `a-element-xhtml.xhtml`, and `failure.html`
5is in `resources/urltestdata.json` and can be re-used by non-browser implementations.
6This file contains a JSON array of comments as strings and test cases as objects.
7The keys for each test case are:
8
9* `base`: an absolute URL as a string whose [parsing] without a base of its own must succeed.
10  This key is always present,
11  and may have a value like `"about:blank"` when `input` is an absolute URL.
12* `input`: an URL as a string to be [parsed][parsing] with `base` as its base URL.
13* Either:
14  * `failure` with the value `true`, indicating that parsing `input` should return failure,
15  * or `href`, `origin`, `protocol`, `username`, `password`, `host`, `hostname`, `port`,
16    `pathname`, `search`, and `hash` with string values;
17    indicating that parsing `input` should return an URL record
18    and that the getters of each corresponding attribute in that URL’s [API]
19    should return the corresponding value.
20
21    The `origin` key may be missing.
22    In that case, the API’s `origin` attribute is not tested.
23
24In addition to testing that parsing `input` against `base` gives the result, a test harness for the
25`URL` constructor (or similar APIs) should additionally test the following pattern: if `failure` is
26true, parsing `about:blank` against `input` must give failure. This tests that the logic for
27converting base URLs into strings properly fails the whole parsing algorithm if the base URL cannot
28be parsed.
29
30## setters_tests.json
31
32`resources/setters_tests.json` is self-documented.
33
34## toascii.json
35
36`resources/toascii.json` is a JSON resource containing an array where each item is an object
37consisting of an optional `comment` field and mandatory `input` and `output` fields. `input` is the
38domain to be parsed according to the rules of UTS #46 (as stipulated by the URL Standard). `output`
39gives the expected output of the parser after serialization. An `output` of `null` means parsing is
40expected to fail.
41
42## URL parser's encoding argument
43
44Tests in `/encoding` and `/html/infrastructure/urls/resolving-urls/query-encoding/` cover the
45encoding argument to the URL parser.
46
47There's also limited coverage in `resources/percent-encoding.json` for percent-encode after encoding
48with _percentEncodeSet_ set to special-query percent-encode set and _spaceAsPlus_ set to false.
49(Improvements to expand coverage here are welcome.)
50
51## Specification
52
53The tests in this directory assert conformance with [the URL Standard][URL].
54
55[parsing]: https://url.spec.whatwg.org/#concept-basic-url-parser
56[API]: https://url.spec.whatwg.org/#api
57[URL]: https://url.spec.whatwg.org/
58