Skip to content

Commit 5749dfa

Browse files
anonrigRafaelGSS
authored andcommitted
test: update URL web-platform-tests
PR-URL: #47135 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent c5cd6b7 commit 5749dfa

8 files changed

+594
-19
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/51750bc8d7/streams
30-
- url: https://github.com/web-platform-tests/wpt/tree/1eaeb0e178/url
30+
- url: https://github.com/web-platform-tests/wpt/tree/84caeb6fbd/url
3131
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
3232
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
3333
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// The results of this test are all over the map due to browsers behaving very differently for
2+
// javascript: URLs.
3+
//
4+
// Chromium is pretty close execution-wise, but it parses javascript: URLs incorrectly.
5+
// Gecko navigates to non-string return values of the result of executing a javascript: URL.
6+
// WebKit executes javascript: URLs too early and has a harness error due to URL parsing.
7+
//
8+
// The expectations below should match the HTML and URL standards.
9+
[
10+
{
11+
"description": "javascript: URL that fails to parse due to invalid host",
12+
"input": "javascript://test:test/%0aglobalThis.shouldNotExistA=1",
13+
"property": "shouldNotExistA",
14+
"expected": undefined
15+
},
16+
{
17+
"description": "javascript: URL that fails to parse due to invalid host and has a U+0009 in scheme",
18+
"input": "java\x09script://test:test/%0aglobalThis.shouldNotExistB=1",
19+
"property": "shouldNotExistB",
20+
"expected": undefined
21+
},
22+
{
23+
"description": "javascript: URL without an opaque path",
24+
"input": "javascript://host/1%0a//../0/;globalThis.shouldBeOne=1;/%0aglobalThis.shouldBeOne=2;/..///",
25+
"property": "shouldBeOne",
26+
"expected": 1
27+
},
28+
{
29+
"description": "javascript: URL containing a JavaScript string split over path and query",
30+
// Use ";undefined" to avoid returning a string.
31+
"input": "javascript:globalThis.shouldBeAStringA = \"https://whatsoever.com/?a=b&c=5&x=y\";undefined",
32+
"property": "shouldBeAStringA",
33+
"expected": "https://whatsoever.com/?a=b&c=5&x=y"
34+
},
35+
{
36+
"description": "javascript: URL containing a JavaScript string split over path and query and has a U+000A in scheme",
37+
// Use ";undefined" to avoid returning a string.
38+
"input": "java\x0Ascript:globalThis.shouldBeAStringB = \"https://whatsoever.com/?a=b&c=5&x=y\";undefined",
39+
"property": "shouldBeAStringB",
40+
"expected": "https://whatsoever.com/?a=b&c=5&x=y"
41+
}
42+
].forEach(({ description, input, property, expected }) => {
43+
// Use promise_test so the tests run in sequence. Needed for globalThis.verify below.
44+
promise_test(t => {
45+
const anchor = document.body.appendChild(document.createElement("a"));
46+
t.add_cleanup(() => anchor.remove());
47+
anchor.href = input;
48+
assert_equals(globalThis[property], undefined, "Property is undefined before the click");
49+
anchor.click();
50+
assert_equals(globalThis[property], undefined, "Property is undefined immediately after the click");
51+
52+
// Since we cannot reliably queue a task to run after the task queued as a result of the click()
53+
// above, we do another click() with a new URL.
54+
return new Promise(resolve => {
55+
globalThis.verify = t.step_func(() => {
56+
assert_equals(globalThis[property], expected, `Property is ${expected} once the navigation happened`);
57+
resolve();
58+
});
59+
anchor.href = "javascript:globalThis.verify()";
60+
anchor.click();
61+
});
62+
}, description);
63+
});

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

+72
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,42 @@
10611061
"host": "",
10621062
"hostname": ""
10631063
}
1064+
},
1065+
{
1066+
"href": "https://example.com/",
1067+
"new_value": "a%C2%ADb",
1068+
"expected": {
1069+
"href": "https://ab/",
1070+
"host": "ab",
1071+
"hostname": "ab"
1072+
}
1073+
},
1074+
{
1075+
"href": "https://example.com/",
1076+
"new_value": "\u00AD",
1077+
"expected": {
1078+
"href": "https://example.com/",
1079+
"host": "example.com",
1080+
"hostname": "example.com"
1081+
}
1082+
},
1083+
{
1084+
"href": "https://example.com/",
1085+
"new_value": "%C2%AD",
1086+
"expected": {
1087+
"href": "https://example.com/",
1088+
"host": "example.com",
1089+
"hostname": "example.com"
1090+
}
1091+
},
1092+
{
1093+
"href": "https://example.com/",
1094+
"new_value": "xn--",
1095+
"expected": {
1096+
"href": "https://example.com/",
1097+
"host": "example.com",
1098+
"hostname": "example.com"
1099+
}
10641100
}
10651101
],
10661102
"hostname": [
@@ -1436,6 +1472,42 @@
14361472
"host": "",
14371473
"hostname": ""
14381474
}
1475+
},
1476+
{
1477+
"href": "https://example.com/",
1478+
"new_value": "a%C2%ADb",
1479+
"expected": {
1480+
"href": "https://ab/",
1481+
"host": "ab",
1482+
"hostname": "ab"
1483+
}
1484+
},
1485+
{
1486+
"href": "https://example.com/",
1487+
"new_value": "\u00AD",
1488+
"expected": {
1489+
"href": "https://example.com/",
1490+
"host": "example.com",
1491+
"hostname": "example.com"
1492+
}
1493+
},
1494+
{
1495+
"href": "https://example.com/",
1496+
"new_value": "%C2%AD",
1497+
"expected": {
1498+
"href": "https://example.com/",
1499+
"host": "example.com",
1500+
"hostname": "example.com"
1501+
}
1502+
},
1503+
{
1504+
"href": "https://example.com/",
1505+
"new_value": "xn--",
1506+
"expected": {
1507+
"href": "https://example.com/",
1508+
"host": "example.com",
1509+
"hostname": "example.com"
1510+
}
14391511
}
14401512
],
14411513
"port": [

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

-17
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,6 @@
160160
"input": "a\u00ADb",
161161
"output": "ab"
162162
},
163-
{
164-
"input": "a%C2%ADb",
165-
"output": "ab"
166-
},
167-
{
168-
"comment": "Empty host after domain to ASCII",
169-
"input": "\u00AD",
170-
"output": null
171-
},
172-
{
173-
"input": "%C2%AD",
174-
"output": null
175-
},
176-
{
177-
"input": "xn--",
178-
"output": null
179-
},
180163
{
181164
"comment": "Interesting UseSTD3ASCIIRules=false cases",
182165
"input": "",

0 commit comments

Comments
 (0)