Skip to content

Commit 465ad2a

Browse files
anonrigtargos
authored andcommitted
test: update url web platform tests
PR-URL: #50264 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 5a52c51 commit 465ad2a

10 files changed

+89
-7
lines changed

test/fixtures/wpt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Last update:
2727
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
2828
- resources: https://github.com/web-platform-tests/wpt/tree/919874f84f/resources
2929
- streams: https://github.com/web-platform-tests/wpt/tree/517e945bbf/streams
30-
- url: https://github.com/web-platform-tests/wpt/tree/84782d9315/url
30+
- url: https://github.com/web-platform-tests/wpt/tree/c2d7e70b52/url
3131
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
3232
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
3333
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi

test/fixtures/wpt/url/failure.html

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
function runTests(testData) {
1212
for (const test of testData) {
13+
14+
// skip comments, inputs we expect to pass and relative URLs
1315
if (typeof test === "string" || !test.failure || test.base !== null) {
1416
continue;
1517
}

test/fixtures/wpt/url/resources/a-element-origin.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function runURLTests(urlTests) {
2121
if (expected.base === null && expected.input.startsWith("#"))
2222
continue;
2323

24+
// HTML special cases data: and javascript: URLs in <base>
25+
if (expected.base !== null && (expected.base.startsWith("data:") || expected.base.startsWith("javascript:")))
26+
continue;
27+
2428
// We cannot use a null base for HTML tests
2529
const base = expected.base === null ? "about:blank" : expected.base;
2630

test/fixtures/wpt/url/resources/a-element.js

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function runURLTests(urlTests) {
2121
if (expected.relativeTo === "any-base")
2222
continue;
2323

24+
// HTML special cases data: and javascript: URLs in <base>
25+
if (expected.base !== null && (expected.base.startsWith("data:") || expected.base.startsWith("javascript:")))
26+
continue;
27+
2428
// We cannot use a null base for HTML tests
2529
const base = expected.base === null ? "about:blank" : expected.base;
2630

test/fixtures/wpt/url/resources/setters_tests.json

+54
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,24 @@
20212021
"href": "sc:/space%20",
20222022
"pathname": "/space%20"
20232023
}
2024+
},
2025+
{
2026+
"comment": "Trailing space should be encoded",
2027+
"href": "http://example.net",
2028+
"new_value": " ",
2029+
"expected": {
2030+
"href": "http://example.net/%20",
2031+
"pathname": "/%20"
2032+
}
2033+
},
2034+
{
2035+
"comment": "Trailing C0 control should be encoded",
2036+
"href": "http://example.net",
2037+
"new_value": "\u0000",
2038+
"expected": {
2039+
"href": "http://example.net/%00",
2040+
"pathname": "/%00"
2041+
}
20242042
}
20252043
],
20262044
"search": [
@@ -2141,6 +2159,24 @@
21412159
"href": "sc:space #fragment",
21422160
"search": ""
21432161
}
2162+
},
2163+
{
2164+
"comment": "Trailing space should be encoded",
2165+
"href": "http://example.net",
2166+
"new_value": " ",
2167+
"expected": {
2168+
"href": "http://example.net/?%20",
2169+
"search": "?%20"
2170+
}
2171+
},
2172+
{
2173+
"comment": "Trailing C0 control should be encoded",
2174+
"href": "http://example.net",
2175+
"new_value": "\u0000",
2176+
"expected": {
2177+
"href": "http://example.net/?%00",
2178+
"search": "?%00"
2179+
}
21442180
}
21452181
],
21462182
"hash": [
@@ -2311,6 +2347,24 @@
23112347
"href": "sc:space ?query",
23122348
"hash": ""
23132349
}
2350+
},
2351+
{
2352+
"comment": "Trailing space should be encoded",
2353+
"href": "http://example.net",
2354+
"new_value": " ",
2355+
"expected": {
2356+
"href": "http://example.net/#%20",
2357+
"hash": "#%20"
2358+
}
2359+
},
2360+
{
2361+
"comment": "Trailing C0 control should be encoded",
2362+
"href": "http://example.net",
2363+
"new_value": "\u0000",
2364+
"expected": {
2365+
"href": "http://example.net/#%00",
2366+
"hash": "#%00"
2367+
}
23142368
}
23152369
],
23162370
"href": [

test/fixtures/wpt/url/resources/urltestdata.json

-1
Original file line numberDiff line numberDiff line change
@@ -7851,7 +7851,6 @@
78517851
"input": "blob:file://host/path",
78527852
"base": null,
78537853
"href": "blob:file://host/path",
7854-
"origin": "null",
78557854
"protocol": "blob:",
78567855
"username": "",
78577856
"password": "",

test/fixtures/wpt/url/url-statics-canparse.any.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
"expected": false
77
},
88
{
9-
"url": "a:b",
9+
"url": "aaa:b",
1010
"base": undefined,
1111
"expected": true
1212
},
1313
{
1414
"url": undefined,
15-
"base": "a:b",
15+
"base": "aaa:b",
1616
"expected": false
1717
},
1818
{
19-
"url": "a:/b",
19+
"url": "aaa:/b",
2020
"base": undefined,
2121
"expected": true
2222
},
2323
{
2424
"url": undefined,
25-
"base": "a:/b",
25+
"base": "aaa:/b",
2626
"expected": true
2727
},
2828
{

test/fixtures/wpt/url/urlsearchparams-delete.any.js

+11
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,14 @@ test(() => {
7070
params.delete('a', 'c');
7171
assert_equals(params.toString(), 'a=b&a=d');
7272
}, "Two-argument delete()");
73+
74+
test(() => {
75+
const params = new URLSearchParams();
76+
params.append('a', 'b');
77+
params.append('a', 'c');
78+
params.append('b', 'c');
79+
params.append('b', 'd');
80+
params.delete('b', 'c');
81+
params.delete('a', undefined);
82+
assert_equals(params.toString(), 'b=d');
83+
}, "Two-argument delete() respects undefined as second arg");

test/fixtures/wpt/url/urlsearchparams-has.any.js

+8
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@ test(() => {
3535
params.delete('a', 'b');
3636
assert_true(params.has('a', 'd'));
3737
}, "Two-argument has()");
38+
39+
test(() => {
40+
const params = new URLSearchParams("a=b&a=d&c&e&");
41+
assert_true(params.has('a', 'b'));
42+
assert_false(params.has('a', 'c'));
43+
assert_true(params.has('a', 'd'));
44+
assert_true(params.has('a', undefined));
45+
}, "Two-argument has() respects undefined as second arg");

test/fixtures/wpt/versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"path": "streams"
6969
},
7070
"url": {
71-
"commit": "84782d931516aa13cfe32dc7eaa1377b4d947d66",
71+
"commit": "c2d7e70b52cbd9a5b938aa32f37078d7a71e0b21",
7272
"path": "url"
7373
},
7474
"user-timing": {

0 commit comments

Comments
 (0)