(urlTests)
| 15 | } |
| 16 | |
| 17 | function runURLTests(urlTests) { |
| 18 | for (const expected of urlTests) { |
| 19 | // Skip comments |
| 20 | if (typeof expected === "string") |
| 21 | continue; |
| 22 | |
| 23 | // Fragments are relative against "about:blank" |
| 24 | if (expected.relativeTo === "any-base") |
| 25 | continue; |
| 26 | |
| 27 | // HTML special cases data: and javascript: URLs in <base> |
| 28 | if (expected.base !== null && (expected.base.startsWith("data:") || expected.base.startsWith("javascript:"))) |
| 29 | continue; |
| 30 | |
| 31 | // We cannot use a null base for HTML tests |
| 32 | const base = expected.base === null ? "about:blank" : expected.base; |
| 33 | |
| 34 | function getKey(expected) { |
| 35 | if (expected.protocol) { |
| 36 | return expected.protocol.replace(":", ""); |
| 37 | } |
| 38 | if (expected.failure) { |
| 39 | return expected.input.split(":")[0]; |
| 40 | } |
| 41 | return "other"; |
| 42 | } |
| 43 | |
| 44 | subsetTestByKey(getKey(expected), test, function() { |
| 45 | var url = bURL(expected.input, base) |
| 46 | if(expected.failure) { |
| 47 | if(url.protocol !== ':') { |
| 48 | assert_unreached("Expected URL to fail parsing") |
| 49 | } |
| 50 | assert_equals(url.href, expected.input, "failure should set href to input") |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | assert_equals(url.href, expected.href, "href") |
| 55 | assert_equals(url.protocol, expected.protocol, "protocol") |
| 56 | assert_equals(url.username, expected.username, "username") |
| 57 | assert_equals(url.password, expected.password, "password") |
| 58 | assert_equals(url.host, expected.host, "host") |
| 59 | assert_equals(url.hostname, expected.hostname, "hostname") |
| 60 | assert_equals(url.port, expected.port, "port") |
| 61 | assert_equals(url.pathname, expected.pathname, "pathname") |
| 62 | assert_equals(url.search, expected.search, "search") |
| 63 | assert_equals(url.hash, expected.hash, "hash") |
| 64 | }, "Parsing: <" + expected.input + "> against <" + base + ">") |
| 65 | } |
| 66 | } |
nothing calls this directly
no test coverage detected