test: update web-platform tests for url

PR-URL: https://github.com/nodejs/node/pull/46860
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Xuguang Mei authored and GitHub committed 2023-03-01 13:51:47 +00:00
1 parent 37c736f780
commit f652f7baa6
6 files changed
+121 -6

No files matched your search

+1 -1
View File
@@ -28,7 +28,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/fbf1e7d247/resources
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
- url: https://github.com/web-platform-tests/wpt/tree/f1ade799d0/url
- url: https://github.com/web-platform-tests/wpt/tree/1eaeb0e178/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
+5 -4
View File
@@ -5,7 +5,6 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<iframe></iframe>
<script>
promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runTests), "Loading data…")
@@ -41,9 +40,11 @@ function runTests(testData) {
assert_throws_js(TypeError, () => self.navigator.sendBeacon(test.input))
}, "sendBeacon(): " + name)
self.test(() => {
assert_throws_js(self[0].TypeError, () => self[0].location = test.input)
}, "Location's href: " + name)
self.test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.remove());
assert_throws_dom("SyntaxError", frame.contentWindow.DOMException, () => frame.contentWindow.location = test.input);
}, "Location's href: " + name);
self.test(() => {
assert_throws_dom("SyntaxError", () => self.open(test.input).close())
+45
View File
@@ -1592,6 +1592,17 @@
"port": "8080"
}
},
{
"comment": "Setting port to a string that doesn't parse as a number",
"href": "http://example.net:8080/path",
"new_value": "randomstring",
"expected": {
"href": "http://example.net:8080/path",
"host": "example.net:8080",
"hostname": "example.net",
"port": "8080"
}
},
{
"comment": "Port numbers are 16 bit integers, overflowing is an error",
"href": "non-special://example.net:8080/path",
@@ -1650,6 +1661,30 @@
"href": "javascript://x:12/",
"port": "12"
}
},
{
"comment": "Leading u0009 on special scheme",
"href": "https://domain.com:443",
"new_value": "\u00098080",
"expected": {
"port": "8080"
}
},
{
"comment": "Leading u0009 on non-special scheme",
"href": "wpt++://domain.com:443",
"new_value": "\u00098080",
"expected": {
"port": "8080"
}
},
{
"comment": "Should use all ascii prefixed characters as port",
"href": "https://www.google.com:4343",
"new_value": "4wpt",
"expected": {
"port": "4"
}
}
],
"pathname": [
@@ -2205,5 +2240,15 @@
"hash": ""
}
}
],
"href": [
{
"href": "file:///var/log/system.log",
"new_value": "http://0300.168.0xF0",
"expected": {
"href": "http://192.168.0.240/",
"protocol": "http:"
}
}
]
}
+35
View File
@@ -964,6 +964,11 @@
"search": "",
"hash": ""
},
{
"input": "http://[::127.0.0.1.]",
"base": "http://example.org/foo/bar",
"failure": true
},
{
"input": "http://[0:0:0:0:0:0:13.1.68.3]",
"base": "http://example.org/foo/bar",
@@ -3959,11 +3964,21 @@
"base": "http://other.com/",
"failure": true
},
{
"input": "http://[::.1.2]",
"base": "http://other.com/",
"failure": true
},
{
"input": "http://[::1.]",
"base": "http://other.com/",
"failure": true
},
{
"input": "http://[::.1]",
"base": "http://other.com/",
"failure": true
},
{
"input": "http://[::%31]",
"base": "http://other.com/",
@@ -8857,5 +8872,25 @@
"protocol": "non-special:",
"search": "",
"username": ""
},
{
"input": "",
"base": "about:blank",
"failure": true
},
{
"input": "https://example.com/\"quoted\"",
"base": "about:blank",
"hash": "",
"host": "example.com",
"hostname": "example.com",
"href": "https://example.com/%22quoted%22",
"origin": "https://example.com",
"password": "",
"pathname": "/%22quoted%22",
"port": "",
"protocol": "https:",
"search": "",
"username": ""
}
]
+34
View File
@@ -0,0 +1,34 @@
test(() => {
const params = new URLSearchParams("a=1&b=2&a=3");
assert_equals(params.size, 3);
params.delete("a");
assert_equals(params.size, 1);
}, "URLSearchParams's size and deletion");
test(() => {
const params = new URLSearchParams("a=1&b=2&a=3");
assert_equals(params.size, 3);
params.append("b", "4");
assert_equals(params.size, 4);
}, "URLSearchParams's size and addition");
test(() => {
const url = new URL("http://localhost/query?a=1&b=2&a=3");
assert_equals(url.searchParams.size, 3);
url.searchParams.delete("a");
assert_equals(url.searchParams.size, 1);
url.searchParams.append("b", 4);
assert_equals(url.searchParams.size, 2);
}, "URLSearchParams's size when obtained from a URL");
test(() => {
const url = new URL("http://localhost/query?a=1&b=2&a=3");
assert_equals(url.searchParams.size, 3);
url.search = "?";
assert_equals(url.searchParams.size, 0);
}, "URLSearchParams's size when obtained from a URL and using .search");
+1 -1
View File
@@ -72,7 +72,7 @@
"path": "streams"
},
"url": {
"commit": "f1ade799d04b72b0ff75c13e988744c2cd873741",
"commit": "1eaeb0e178b14078bd730ffecd62cb7569315523",
"path": "url"
},
"user-timing": {