test: update WPT for url to 2fa965b55c

Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Assisted-by: Grok
PR-URL: https://github.com/nodejs/node/pull/67624
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Yagiz Nizipli authored and Antoine du Hamel committed 2026-11-23 12:34:21 +01:00
1 parent ae38cb5715
commit a5fd90f595
11 files changed
+373 -24

No files matched your search

+8 -1
View File
@@ -29,8 +29,15 @@ function runTests(testData) {
}, "URL's constructor's base argument: " + name)
self.test(() => {
const url = new URL("about:blank")
const original = "http://user:pass@example.com:8080/path?query#fragment"
const url = new URL(original)
assert_throws_js(TypeError, () => url.href = test.input)
const expected = new URL(original)
for (const property of ["href", "origin", "protocol", "username", "password", "host", "hostname", "port", "pathname", "search", "hash"]) {
assert_equals(url[property], expected[property], property)
}
url.hash = "changed"
assert_equals(url.href, "http://user:pass@example.com:8080/path?query#changed")
}, "URL's href: " + name)
// The following use cases resolve the URL input relative to the current
+38 -22
View File
@@ -7048,22 +7048,33 @@
"output": "j"
},
{
"comment": "C1; V7",
"comment": "C1",
"input": "\u10ad\ud8be\udccd\ua868\u05ae\u3002\u10be\u200c\u200c",
"output": null
},
{
"comment": "C1; V7",
"comment": "C1",
"input": "\u2d0d\ud8be\udccd\ua868\u05ae\u3002\u2d1e\u200c\u200c",
"output": null
},
{
"comment": "V7",
"input": "xn--5cb172r175fug38a.xn--mlj",
"output": "xn--5cb172r175fug38a.xn--mlj"
},
{
"comment": "C1; V7",
"input": "\u2d0d\ud8be\udccd\ua868\u05ae.\u2d1e",
"output": "xn--5cb172r175fug38a.xn--mlj"
},
{
"input": "\u10ad\ud8be\udccd\ua868\u05ae.\u10be",
"output": "xn--5cb172r175fug38a.xn--mlj"
},
{
"input": "\u10ad\ud8be\udccd\ua868\u05ae.\u2d1e",
"output": "xn--5cb172r175fug38a.xn--mlj"
},
{
"comment": "C1",
"input": "xn--5cb172r175fug38a.xn--0uga051h",
"output": "xn--5cb172r175fug38a.xn--0uga051h"
},
@@ -8238,67 +8249,67 @@
"output": "xn--ep37b.xn----hec165lho83b"
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b\uff0e\u1baa\u03c2\u10a6\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b.\u1baa\u03c2\u10a6\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b.\u1baa\u03c2\u2d06\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b.\u1baa\u03a3\u10a6\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b.\u1baa\u03c3\u2d06\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b.\u1baa\u03a3\u2d06\u200d",
"output": null
},
{
"comment": "V6; V7",
"comment": "V6",
"input": "xn--nu4s.xn--4xa153j7im",
"output": "xn--nu4s.xn--4xa153j7im"
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "xn--nu4s.xn--4xa153jk8cs1q",
"output": "xn--nu4s.xn--4xa153jk8cs1q"
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "xn--nu4s.xn--3xa353jk8cs1q",
"output": "xn--nu4s.xn--3xa353jk8cs1q"
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b\uff0e\u1baa\u03c2\u2d06\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b\uff0e\u1baa\u03a3\u10a6\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b\uff0e\u1baa\u03c3\u2d06\u200d",
"output": null
},
{
"comment": "C2; V6; V7",
"comment": "C2; V6",
"input": "\ud8bc\udc2b\uff0e\u1baa\u03a3\u2d06\u200d",
"output": null
},
@@ -11936,20 +11947,25 @@
"output": null
},
{
"comment": "V7",
"input": "\ud8ba\udcac\u3002\u0729\u3002\ucbd95",
"output": null
"output": "xn--t92s.xn--znb.xn--5-y88f"
},
{
"comment": "V7",
"input": "\ud8ba\udcac\u3002\u0729\u3002\u110d\u1173\u11ac5",
"output": null
"output": "xn--t92s.xn--znb.xn--5-y88f"
},
{
"comment": "V7",
"input": "xn--t92s.xn--znb.xn--5-y88f",
"output": "xn--t92s.xn--znb.xn--5-y88f"
},
{
"input": "\ud8ba\udcac.\u0729.\ucbd95",
"output": "xn--t92s.xn--znb.xn--5-y88f"
},
{
"input": "\ud8ba\udcac.\u0729.\u110d\u1173\u11ac5",
"output": "xn--t92s.xn--znb.xn--5-y88f"
},
{
"comment": "C2; V6",
"input": "\u17ca.\u200d\ud835\udfee\ud804\udc3f",
+58
View File
@@ -677,6 +677,16 @@
"port": "8080"
}
},
{
"href": "http://example.net:8080",
"new_value": "example.com:0",
"expected": {
"href": "http://example.com:0/",
"host": "example.com:0",
"hostname": "example.com",
"port": "0"
}
},
{
"comment": "Port number is unchanged if not specified",
"href": "http://example.net:8080",
@@ -697,6 +707,16 @@
"host": "example.net"
}
},
{
"href": "http://example.net:8080/path",
"new_value": ":example.com:15",
"expected": {
"href": "http://example.net:8080/path",
"host": "example.net:8080",
"hostname": "example.net",
"port": "8080"
}
},
{
"comment": "The empty host is OK for non-special schemes",
"href": "view-source+http://example.net/foo",
@@ -1066,6 +1086,16 @@
"port": ""
}
},
{
"href": "file:///x",
"new_value": "example.net",
"expected": {
"href": "file://example.net/x",
"host": "example.net",
"hostname": "example.net",
"port": ""
}
},
{
"href": "sc://test@test/",
"new_value": "",
@@ -1519,6 +1549,16 @@
"port": ""
}
},
{
"href": "file:///x",
"new_value": "example.net",
"expected": {
"href": "file://example.net/x",
"host": "example.net",
"hostname": "example.net",
"port": ""
}
},
{
"href": "sc://test@test/",
"new_value": "",
@@ -1693,6 +1733,16 @@
"port": ""
}
},
{
"href": "http://example.net:8080",
"new_value": "0",
"expected": {
"href": "http://example.net:0/",
"host": "example.net:0",
"hostname": "example.net",
"port": "0"
}
},
{
"comment": "Default port number is removed",
"href": "http://example.net:8080",
@@ -2034,6 +2084,14 @@
"pathname": "/home"
}
},
{
"href": "https://example.net/home#nav",
"new_value": "",
"expected": {
"href": "https://example.net/#nav",
"pathname": "/"
}
},
{
"comment": "\\ is a segment delimiter for 'special' URLs",
"href": "http://example.net/home?lang=fr#nav",
@@ -14,5 +14,20 @@
"pathname": "/%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF",
"search": "?%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF",
"hash": ""
},
{
"input": "b/c",
"base": "http://example.com/\uD801/b",
"href": "http://example.com/%EF%BF%BD/b/c",
"origin": "http://example.com",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"port": "",
"pathname": "/%EF%BF%BD/b/c",
"search": "",
"hash": ""
}
]
+113
View File
@@ -3823,6 +3823,43 @@
"search": "",
"hash": ""
},
"Leading and trailing U+007F DELETE are not trimmed",
{
"input": "\u007Fhttp://example.com/",
"base": null,
"failure": true,
"relativeTo": "non-opaque-path-base"
},
{
"input": "\u007Fjavascript:alert(1)",
"base": "http://example.org/foo/bar",
"href": "http://example.org/foo/%7Fjavascript:alert(1)",
"origin": "http://example.org",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.org",
"hostname": "example.org",
"port": "",
"pathname": "/foo/%7Fjavascript:alert(1)",
"search": "",
"hash": ""
},
{
"input": "http://example.com/\u007F",
"base": null,
"href": "http://example.com/%7F",
"origin": "http://example.com",
"protocol": "http:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"port": "",
"pathname": "/%7F",
"search": "",
"hash": ""
},
{
"input": "non-special:opaque ",
"base": null,
@@ -10684,5 +10721,81 @@
"pathname": "blank",
"search": "",
"hash": "#%00%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
},
"# Relative resolution against empty-path and path-only non-special base URLs with query/fragment",
{
"input": "p",
"base": "git://host?q#r",
"href": "git://host/p",
"origin": "null",
"protocol": "git:",
"username": "",
"password": "",
"host": "host",
"hostname": "host",
"port": "",
"pathname": "/p",
"search": "",
"hash": ""
},
{
"input": "?q2",
"base": "git://host?q#r",
"href": "git://host?q2",
"origin": "null",
"protocol": "git:",
"username": "",
"password": "",
"host": "host",
"hostname": "host",
"port": "",
"pathname": "",
"search": "?q2",
"hash": ""
},
{
"input": "#h",
"base": "git://host?q#r",
"href": "git://host?q#h",
"origin": "null",
"protocol": "git:",
"username": "",
"password": "",
"host": "host",
"hostname": "host",
"port": "",
"pathname": "",
"search": "?q",
"hash": "#h"
},
{
"input": "?q2",
"base": "git:/.//a?q#r",
"href": "git:/.//a?q2",
"origin": "null",
"protocol": "git:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//a",
"search": "?q2",
"hash": ""
},
{
"input": "#h",
"base": "git:/.//a?q#r",
"href": "git:/.//a?q#h",
"origin": "null",
"protocol": "git:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//a",
"search": "?q",
"hash": "#h"
}
]
@@ -0,0 +1,44 @@
// Not in setters_tests.json since lone surrogates are not portable JSON.
[{
property: 'pathname',
newValue: '\uDC01\uD802a',
expected: {
href: 'http://example.net/%EF%BF%BD%EF%BF%BDa',
pathname: '/%EF%BF%BD%EF%BF%BDa'
}
},
{
property: 'search',
newValue: '\uDC01\uD802a',
expected: {
href: 'http://example.net/?%EF%BF%BD%EF%BF%BDa',
search: '?%EF%BF%BD%EF%BF%BDa'
}
},
{
property: 'hash',
newValue: '\uDC01\uD802a',
expected: {
href: 'http://example.net/#%EF%BF%BD%EF%BF%BDa',
hash: '#%EF%BF%BD%EF%BF%BDa'
}
},
{
property: 'host',
newValue: 'exa\uDC01\uD802mple.com',
expected: {href: 'http://example.net/', host: 'example.net'}
},
{
property: 'hostname',
newValue: 'exa\uDC01\uD802mple.com',
expected: {href: 'http://example.net/', hostname: 'example.net'}
}].forEach(({property, newValue, expected}) => {
test(() => {
const url = new URL('http://example.net/');
url[property] = newValue;
for (const [key, value] of Object.entries(expected)) {
assert_equals(url[key], value, key);
}
}, `Setting ${property} to a value with lone surrogates`);
});
+21
View File
@@ -121,5 +121,26 @@ for(const scheme of ["https", "wpt++"]) {
}, `Setting ${property} with ${type} ${cpReference} (${scheme}:)`);
}
}
// searchParams has to reflect the resulting query, also when it was obtained before setting
// search
for (const [type, input] of [
["leading", String.fromCodePoint(i) + "test"],
["middle", "te" + String.fromCodePoint(i) + "st"],
["trailing", "test" + String.fromCodePoint(i)]
]) {
for (const searchParamsFirst of [false, true]) {
test(() => {
const expected = stripped ? "test" : input;
const url = urlRecord(scheme);
if (searchParamsFirst) {
url.searchParams;
}
url.search = input;
assert_array_equals([...url.searchParams.keys()], [expected], "keys");
assert_array_equals([...url.searchParams.values()], [""], "values");
}, `Setting search with ${type} ${cpReference} updates ${searchParamsFirst ? "previously obtained " : ""}searchParams (${scheme}:)`);
}
}
}
}
@@ -19,6 +19,15 @@ test(function () {
assert_equals(params.toString(), "a=b")
}, 'URLSearchParams constructor, remove leading "?"')
test(function() {
var params = new URLSearchParams('??a=b')
assert_equals(params.toString(), '%3Fa=b')
params = new URLSearchParams('?')
assert_equals(params.toString(), '')
params = new URLSearchParams('??')
assert_equals(params.toString(), '%3F=')
}, 'URLSearchParams constructor, remove only one leading "?"')
test(() => {
var params = new URLSearchParams(DOMException);
assert_equals(params.toString(), "INDEX_SIZE_ERR=1&DOMSTRING_SIZE_ERR=2&HIERARCHY_REQUEST_ERR=3&WRONG_DOCUMENT_ERR=4&INVALID_CHARACTER_ERR=5&NO_DATA_ALLOWED_ERR=6&NO_MODIFICATION_ALLOWED_ERR=7&NOT_FOUND_ERR=8&NOT_SUPPORTED_ERR=9&INUSE_ATTRIBUTE_ERR=10&INVALID_STATE_ERR=11&SYNTAX_ERR=12&INVALID_MODIFICATION_ERR=13&NAMESPACE_ERR=14&INVALID_ACCESS_ERR=15&VALIDATION_ERR=16&TYPE_MISMATCH_ERR=17&SECURITY_ERR=18&NETWORK_ERR=19&ABORT_ERR=20&URL_MISMATCH_ERR=21&QUOTA_EXCEEDED_ERR=22&TIMEOUT_ERR=23&INVALID_NODE_TYPE_ERR=24&DATA_CLONE_ERR=25")
@@ -130,6 +139,20 @@ test(function() {
assert_equals(newParams.get('query'), testValue);
}, 'Parse encoded +');
test(function() {
var params = new URLSearchParams('a=b%2Bc');
assert_equals(params.get('a'), 'b+c');
params = new URLSearchParams('a%2Bb=c');
assert_equals(params.get('a+b'), 'c');
}, 'Parse %2B');
test(function() {
var params = new URLSearchParams('=');
assert_true(params.has(''));
assert_equals(params.get(''), '');
assert_equals(params.toString(), '=');
}, 'Parse =');
test(function() {
var params = new URLSearchParams('a=b c');
assert_equals(params.get('a'), 'b c');
@@ -196,6 +219,18 @@ test(function() {
assert_throws_js(TypeError, function() { new URLSearchParams([[1,2,3]]); });
}, "Constructor with sequence of sequences of strings");
test(function() {
var params = new URLSearchParams([[1, 2], ['a', 'b']]);
assert_equals(params.toString(), '1=2&a=b');
}, 'Constructor with sequence of sequences of non-strings');
test(function() {
var params = new URLSearchParams({1: 2, 'a': 'b'});
assert_equals(params.toString(), '1=2&a=b');
params = new URLSearchParams({false: true, 0: 'foo'});
assert_equals(params.toString(), '0=foo&false=true');
}, 'Constructor with record of non-strings, in property order');
[
{ "input": {"+": "%C2"}, "output": [["+", "%C2"]], "name": "object with +" },
{ "input": {c: "x", a: "?"}, "output": [["c", "x"], ["a", "?"]], "name": "object with two keys" },
+18
View File
@@ -74,3 +74,21 @@ test(function() {
assert_array_equals(seen, ["param0", "param2"], "param1 should not have been seen by the loop");
assert_equals(String(searchParams), "param1=1", "param1 should remain");
}, "delete every param seen during iteration");
test(function() {
const params = new URLSearchParams('a=1&b=2&c=3');
assert_array_equals([...params.keys()], ['a', 'b', 'c']);
assert_array_equals([...params.values()], ['1', '2', '3']);
const entries = [...params.entries()];
assert_equals(entries.length, 3);
assert_array_equals(entries[0], ['a', '1']);
assert_array_equals(entries[1], ['b', '2']);
assert_array_equals(entries[2], ['c', '3']);
}, 'keys(), values() and entries()');
test(function() {
const params = new URLSearchParams('a=1');
params.forEach(function(value, key, object) {
assert_equals(object, params);
});
}, 'ForEach passes the URLSearchParams object');
@@ -143,3 +143,25 @@ test(() => {
assert_equals(params.toString(), "a%0Ab=c%0Dd&e%0A%0Df=g%0D%0Ah");
}, 'URLSearchParams must not do newline normalization');
test(() => {
for (let i = 0; i <= 0xFF; i++) {
const c = String.fromCodePoint(i);
let expected;
if (c === ' ') {
expected = '+';
} else if (/[*\-._0-9A-Za-z]/.test(c)) {
expected = c;
} else {
expected =
Array
.from(new TextEncoder().encode(c),
b => '%' + b.toString(16).toUpperCase().padStart(2, '0'))
.join('');
}
const params = new URLSearchParams();
params.append(c, c);
assert_equals(params.toString(), `${expected}=${expected}`,
`U+${i.toString(16).toUpperCase().padStart(4, '0')}`);
}
}, 'Serialize U+0000 to U+00FF');
+1 -1
View File
@@ -76,7 +76,7 @@
"path": "streams"
},
"url": {
"commit": "c48d58747e1f211527fb695fd60548a997fae617",
"commit": "2fa965b55c94cbb2f15324aa8a149500fd5f05f9",
"path": "url"
},
"urlpattern": {