11cb0ef41Sopenharmony_ci## urltestdata.json
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci`resources/urltestdata.json` contains URL parsing tests suitable for any URL parser implementation.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciIt's used as a source of tests by `a-element.html`, `failure.html`, `url-constructor.any.js`, and
61cb0ef41Sopenharmony_ciother test files in this directory.
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciThe format of `resources/urltestdata.json` is a JSON array of comments as strings and test cases as
91cb0ef41Sopenharmony_ciobjects. The keys for each test case are:
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci* `input`: a string to be parsed as URL.
121cb0ef41Sopenharmony_ci* `base`: null or a serialized URL (i.e., does not fail parsing).
131cb0ef41Sopenharmony_ci* Then either
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  * `failure` whose value is `true`, indicating that parsing `input` relative to `base` returns
161cb0ef41Sopenharmony_ci    failure
171cb0ef41Sopenharmony_ci  * `relativeTo` whose value is "`non-opaque-path-base`" (input does parse against a non-null base
181cb0ef41Sopenharmony_ci    URL without an opaque path) or "`any-base`" (input parses against any non-null base URL), or is
191cb0ef41Sopenharmony_ci    omitted in its entirety (input never parses successfully)
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  or `href`, `origin`, `protocol`, `username`, `password`, `host`, `hostname`, `port`,
221cb0ef41Sopenharmony_ci  `pathname`, `search`, and `hash` with string values; indicating that parsing `input` should return
231cb0ef41Sopenharmony_ci  an URL record and that the getters of each corresponding attribute in that URL’s [API] should
241cb0ef41Sopenharmony_ci  return the corresponding value.
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci  The `origin` key may be missing. In that case, the API’s `origin` attribute is not tested.
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci## setters_tests.json
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci`resources/setters_tests.json` is self-documented.
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci## toascii.json
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci`resources/toascii.json` is a JSON resource containing an array where each item is an object
351cb0ef41Sopenharmony_ciconsisting of an optional `comment` field and mandatory `input` and `output` fields. `input` is the
361cb0ef41Sopenharmony_cidomain to be parsed according to the rules of UTS #46 (as stipulated by the URL Standard). `output`
371cb0ef41Sopenharmony_cigives the expected output of the parser after serialization. An `output` of `null` means parsing is
381cb0ef41Sopenharmony_ciexpected to fail.
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci## URL parser's encoding argument
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciTests in `/encoding` and `/html/infrastructure/urls/resolving-urls/query-encoding/` cover the
431cb0ef41Sopenharmony_ciencoding argument to the URL parser.
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ciThere's also limited coverage in `resources/percent-encoding.json` for percent-encode after encoding
461cb0ef41Sopenharmony_ciwith _percentEncodeSet_ set to special-query percent-encode set and _spaceAsPlus_ set to false.
471cb0ef41Sopenharmony_ci(Improvements to expand coverage here are welcome.)
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci## Specification
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ciThe tests in this directory assert conformance with [the URL Standard][URL].
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci[parsing]: https://url.spec.whatwg.org/#concept-basic-url-parser
541cb0ef41Sopenharmony_ci[API]: https://url.spec.whatwg.org/#api
551cb0ef41Sopenharmony_ci[URL]: https://url.spec.whatwg.org/
56