|
1 | 1 | ## urltestdata.json
|
2 | 2 |
|
3 |
| -These tests are for browsers, but the data for |
4 |
| -`a-element.html`, `url-constructor.html`, `a-element-xhtml.xhtml`, and `failure.html` |
5 |
| -is in `resources/urltestdata.json` and can be re-used by non-browser implementations. |
6 |
| -This file contains a JSON array of comments as strings and test cases as objects. |
7 |
| -The 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 |
| - |
24 |
| -In 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 |
26 |
| -true, parsing `about:blank` against `input` must give failure. This tests that the logic for |
27 |
| -converting base URLs into strings properly fails the whole parsing algorithm if the base URL cannot |
28 |
| -be parsed. |
| 3 | +`resources/urltestdata.json` contains URL parsing tests suitable for any URL parser implementation. |
| 4 | + |
| 5 | +It's used as a source of tests by `a-element.html`, `failure.html`, `url-constructor.any.js`, and |
| 6 | +other test files in this directory. |
| 7 | + |
| 8 | +The format of `resources/urltestdata.json` is a JSON array of comments as strings and test cases as |
| 9 | +objects. The keys for each test case are: |
| 10 | + |
| 11 | +* `input`: a string to be parsed as URL. |
| 12 | +* `base`: null or a serialized URL (i.e., does not fail parsing). |
| 13 | +* Then either |
| 14 | + |
| 15 | + * `failure` whose value is `true`, indicating that parsing `input` relative to `base` returns |
| 16 | + failure |
| 17 | + * `relativeTo` whose value is "`non-opaque-path-base`" (input does parse against a non-null base |
| 18 | + URL without an opaque path) or "`any-base`" (input parses against any non-null base URL), or is |
| 19 | + omitted in its entirety (input never parses successfully) |
| 20 | + |
| 21 | + or `href`, `origin`, `protocol`, `username`, `password`, `host`, `hostname`, `port`, |
| 22 | + `pathname`, `search`, and `hash` with string values; indicating that parsing `input` should return |
| 23 | + an URL record and that the getters of each corresponding attribute in that URL’s [API] should |
| 24 | + return the corresponding value. |
| 25 | + |
| 26 | + The `origin` key may be missing. In that case, the API’s `origin` attribute is not tested. |
29 | 27 |
|
30 | 28 | ## setters_tests.json
|
31 | 29 |
|
|
0 commit comments