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 web-platform tests for url #46860

Merged
merged 1 commit into from
Mar 1, 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 @@ -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
Expand Down
9 changes: 5 additions & 4 deletions test/fixtures/wpt/url/failure.html
Original file line number Diff line number Diff line change
Expand Up @@ -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…")

Expand Down Expand Up @@ -41,9 +40,11 @@
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())
Expand Down
45 changes: 45 additions & 0 deletions test/fixtures/wpt/url/resources/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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 changes: 35 additions & 0 deletions test/fixtures/wpt/url/resources/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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 changes: 34 additions & 0 deletions test/fixtures/wpt/url/urlsearchparams-size.any.js
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"path": "streams"
},
"url": {
"commit": "f1ade799d04b72b0ff75c13e988744c2cd873741",
"commit": "1eaeb0e178b14078bd730ffecd62cb7569315523",
"path": "url"
},
"user-timing": {
Expand Down