Skip to content

Commit

Permalink
Bug 1886727 [wpt PR 45248] - URL: tests for URL.parse(), a=testonly
Browse files Browse the repository at this point in the history
Automatic update from web-platform-tests
URL: tests for URL.parse()

For whatwg/url#825.
--

wpt-commits: 0f550ab9f5a07ed293926a306e914866164b346b
wpt-pr: 45248
  • Loading branch information
annevk authored and moz-wptsync-bot committed Mar 28, 2024
1 parent b5ce333 commit 0fe861c
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions testing/web-platform/tests/url/url-statics-parse.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// This intentionally does not use resources/urltestdata.json to preserve resources.
[
{
"url": undefined,
"base": undefined,
"expected": false
},
{
"url": "aaa:b",
"base": undefined,
"expected": true
},
{
"url": undefined,
"base": "aaa:b",
"expected": false
},
{
"url": "aaa:/b",
"base": undefined,
"expected": true
},
{
"url": undefined,
"base": "aaa:/b",
"expected": true
},
{
"url": "https://test:test",
"base": undefined,
"expected": false
},
{
"url": "a",
"base": "https://b/",
"expected": true
}
].forEach(({ url, base, expected }) => {
test(() => {
if (expected == false) {
assert_equals(URL.parse(url, base), null);
} else {
assert_equals(URL.parse(url, base).href, new URL(url, base).href);
}
}, `URL.parse(${url}, ${base})`);
});

test(() => {
assert_not_equals(URL.parse("https://example/"), URL.parse("https://example/"));
}, `URL.parse() should return a unique object`);

0 comments on commit 0fe861c

Please sign in to comment.