Skip to content

Commit c0b48cf

Browse files
annevkmoz-wptsync-bot
authored andcommitted
Bug 1886727 [wpt PR 45248] - URL: tests for URL.parse(), a=testonly
Automatic update from web-platform-tests URL: tests for URL.parse() For whatwg/url#825. -- wpt-commits: 0f550ab9f5a07ed293926a306e914866164b346b wpt-pr: 45248
1 parent 8ce9b93 commit c0b48cf

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// This intentionally does not use resources/urltestdata.json to preserve resources.
2+
[
3+
{
4+
"url": undefined,
5+
"base": undefined,
6+
"expected": false
7+
},
8+
{
9+
"url": "aaa:b",
10+
"base": undefined,
11+
"expected": true
12+
},
13+
{
14+
"url": undefined,
15+
"base": "aaa:b",
16+
"expected": false
17+
},
18+
{
19+
"url": "aaa:/b",
20+
"base": undefined,
21+
"expected": true
22+
},
23+
{
24+
"url": undefined,
25+
"base": "aaa:/b",
26+
"expected": true
27+
},
28+
{
29+
"url": "https://test:test",
30+
"base": undefined,
31+
"expected": false
32+
},
33+
{
34+
"url": "a",
35+
"base": "https://b/",
36+
"expected": true
37+
}
38+
].forEach(({ url, base, expected }) => {
39+
test(() => {
40+
if (expected == false) {
41+
assert_equals(URL.parse(url, base), null);
42+
} else {
43+
assert_equals(URL.parse(url, base).href, new URL(url, base).href);
44+
}
45+
}, `URL.parse(${url}, ${base})`);
46+
});
47+
48+
test(() => {
49+
assert_not_equals(URL.parse("https://example/"), URL.parse("https://example/"));
50+
}, `URL.parse() should return a unique object`);

0 commit comments

Comments
 (0)