diff options
Diffstat (limited to 'test/fixtures/wpt/url/url-constructor.any.js')
-rw-r--r-- | test/fixtures/wpt/url/url-constructor.any.js | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/test/fixtures/wpt/url/url-constructor.any.js b/test/fixtures/wpt/url/url-constructor.any.js index 297b8ffd9e..bea06d025b 100644 --- a/test/fixtures/wpt/url/url-constructor.any.js +++ b/test/fixtures/wpt/url/url-constructor.any.js @@ -5,14 +5,13 @@ // META: variant=?include=mailto // META: variant=?exclude=(file|javascript|mailto) -function bURL(url, base) { - return base ? new URL(url, base) : new URL(url) -} +function runURLTests(urlTests) { + for (const expected of urlTests) { + // Skip comments + if (typeof expected === "string") + continue; -function runURLTests(urltests) { - for(var i = 0, l = urltests.length; i < l; i++) { - var expected = urltests[i] - if (typeof expected === "string") continue // skip comments + const base = expected.base !== null ? expected.base : undefined; function getKey(expected) { if (expected.protocol) { @@ -27,12 +26,12 @@ function runURLTests(urltests) { subsetTestByKey(getKey(expected), test, function() { if (expected.failure) { assert_throws_js(TypeError, function() { - bURL(expected.input, expected.base) - }) - return + new URL(expected.input, base); + }); + return; } - var url = bURL(expected.input, expected.base) + const url = new URL(expected.input, base); assert_equals(url.href, expected.href, "href") assert_equals(url.protocol, expected.protocol, "protocol") assert_equals(url.username, expected.username, "username") @@ -47,7 +46,7 @@ function runURLTests(urltests) { assert_equals(url.searchParams.toString(), expected.searchParams, "searchParams") } assert_equals(url.hash, expected.hash, "hash") - }, "Parsing: <" + expected.input + "> against <" + expected.base + ">") + }, `Parsing: <${expected.input}> ${base ? "against <" + base + ">" : "without base"}`) } } |