Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update url web platform tests #50264

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Last update:
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
- resources: https://github.com/web-platform-tests/wpt/tree/919874f84f/resources
- streams: https://github.com/web-platform-tests/wpt/tree/517e945bbf/streams
- url: https://github.com/web-platform-tests/wpt/tree/84782d9315/url
- url: https://github.com/web-platform-tests/wpt/tree/c2d7e70b52/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/wpt/url/failure.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

function runTests(testData) {
for (const test of testData) {

// skip comments, inputs we expect to pass and relative URLs
if (typeof test === "string" || !test.failure || test.base !== null) {
continue;
}
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/wpt/url/resources/a-element-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function runURLTests(urlTests) {
if (expected.base === null && expected.input.startsWith("#"))
continue;

// HTML special cases data: and javascript: URLs in <base>
if (expected.base !== null && (expected.base.startsWith("data:") || expected.base.startsWith("javascript:")))
continue;

// We cannot use a null base for HTML tests
const base = expected.base === null ? "about:blank" : expected.base;

Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/wpt/url/resources/a-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function runURLTests(urlTests) {
if (expected.relativeTo === "any-base")
continue;

// HTML special cases data: and javascript: URLs in <base>
if (expected.base !== null && (expected.base.startsWith("data:") || expected.base.startsWith("javascript:")))
continue;

// We cannot use a null base for HTML tests
const base = expected.base === null ? "about:blank" : expected.base;

Expand Down
54 changes: 54 additions & 0 deletions test/fixtures/wpt/url/resources/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,24 @@
"href": "sc:/space%20",
"pathname": "/space%20"
}
},
{
"comment": "Trailing space should be encoded",
"href": "http://example.net",
"new_value": " ",
"expected": {
"href": "http://example.net/%20",
"pathname": "/%20"
}
},
{
"comment": "Trailing C0 control should be encoded",
"href": "http://example.net",
"new_value": "\u0000",
"expected": {
"href": "http://example.net/%00",
"pathname": "/%00"
}
}
],
"search": [
Expand Down Expand Up @@ -2141,6 +2159,24 @@
"href": "sc:space #fragment",
"search": ""
}
},
{
"comment": "Trailing space should be encoded",
"href": "http://example.net",
"new_value": " ",
"expected": {
"href": "http://example.net/?%20",
"search": "?%20"
}
},
{
"comment": "Trailing C0 control should be encoded",
"href": "http://example.net",
"new_value": "\u0000",
"expected": {
"href": "http://example.net/?%00",
"search": "?%00"
}
}
],
"hash": [
Expand Down Expand Up @@ -2311,6 +2347,24 @@
"href": "sc:space ?query",
"hash": ""
}
},
{
"comment": "Trailing space should be encoded",
"href": "http://example.net",
"new_value": " ",
"expected": {
"href": "http://example.net/#%20",
"hash": "#%20"
}
},
{
"comment": "Trailing C0 control should be encoded",
"href": "http://example.net",
"new_value": "\u0000",
"expected": {
"href": "http://example.net/#%00",
"hash": "#%00"
}
}
],
"href": [
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/wpt/url/resources/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7851,7 +7851,6 @@
"input": "blob:file://host/path",
"base": null,
"href": "blob:file://host/path",
"origin": "null",
"protocol": "blob:",
"username": "",
"password": "",
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/wpt/url/url-statics-canparse.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
"expected": false
},
{
"url": "a:b",
"url": "aaa:b",
"base": undefined,
"expected": true
},
{
"url": undefined,
"base": "a:b",
"base": "aaa:b",
"expected": false
},
{
"url": "a:/b",
"url": "aaa:/b",
"base": undefined,
"expected": true
},
{
"url": undefined,
"base": "a:/b",
"base": "aaa:/b",
"expected": true
},
{
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/wpt/url/urlsearchparams-delete.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ test(() => {
params.delete('a', 'c');
assert_equals(params.toString(), 'a=b&a=d');
}, "Two-argument delete()");

test(() => {
const params = new URLSearchParams();
params.append('a', 'b');
params.append('a', 'c');
params.append('b', 'c');
params.append('b', 'd');
params.delete('b', 'c');
params.delete('a', undefined);
assert_equals(params.toString(), 'b=d');
}, "Two-argument delete() respects undefined as second arg");
8 changes: 8 additions & 0 deletions test/fixtures/wpt/url/urlsearchparams-has.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ test(() => {
params.delete('a', 'b');
assert_true(params.has('a', 'd'));
}, "Two-argument has()");

test(() => {
const params = new URLSearchParams("a=b&a=d&c&e&");
assert_true(params.has('a', 'b'));
assert_false(params.has('a', 'c'));
assert_true(params.has('a', 'd'));
assert_true(params.has('a', undefined));
}, "Two-argument has() respects undefined as second arg");
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"path": "streams"
},
"url": {
"commit": "84782d931516aa13cfe32dc7eaa1377b4d947d66",
"commit": "c2d7e70b52cbd9a5b938aa32f37078d7a71e0b21",
"path": "url"
},
"user-timing": {
Expand Down
Loading