Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 95bbd0f

Browse filesBrowse files
anonrigtargos
authored andcommitted
test: update web-platform tests for url
PR-URL: #46547 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 66016e2 commit 95bbd0f
Copy full SHA for 95bbd0f
Expand file treeCollapse file tree

17 files changed

+10305
-8
lines changed
Open diff view settings
Collapse file

‎test/fixtures/wpt/README.md‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Last update:
2828
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
2929
- resources: https://github.com/web-platform-tests/wpt/tree/fbf1e7d247/resources
3030
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
31-
- url: https://github.com/web-platform-tests/wpt/tree/0a187bc169/url
31+
- url: https://github.com/web-platform-tests/wpt/tree/f1ade799d0/url
3232
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
3333
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
3434
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
Collapse file
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
promise_test(() => fetch("resources/IdnaTestV2.json").then(res => res.json()).then(runTests), "Loading data…");
2+
3+
// Performance impact of this seems negligible (performance.now() diff in WebKit went from 48 to 52)
4+
// and there was a preference to let more non-ASCII hit the parser.
5+
function encodeHostEndingCodePoints(input) {
6+
let output = "";
7+
for (const codePoint of input) {
8+
if ([":", "/", "?", "#", "\\"].includes(codePoint)) {
9+
output += encodeURIComponent(codePoint);
10+
} else {
11+
output += codePoint;
12+
}
13+
}
14+
return output;
15+
}
16+
17+
function runTests(idnaTests) {
18+
for (const idnaTest of idnaTests) {
19+
if (typeof idnaTest === "string") {
20+
continue // skip comments
21+
}
22+
if (idnaTest.input === "") {
23+
continue // cannot test empty string input through new URL()
24+
}
25+
// Percent-encode the input such that ? and equivalent code points do not end up counting as
26+
// part of the URL, but are parsed through the host parser instead.
27+
const encodedInput = encodeHostEndingCodePoints(idnaTest.input);
28+
29+
test(() => {
30+
if (idnaTest.output === null) {
31+
assert_throws_js(TypeError, () => new URL(`https://${encodedInput}/x`));
32+
} else {
33+
const url = new URL(`https://${encodedInput}/x`);
34+
assert_equals(url.host, idnaTest.output);
35+
assert_equals(url.hostname, idnaTest.output);
36+
assert_equals(url.pathname, "/x");
37+
assert_equals(url.href, `https://${idnaTest.output}/x`);
38+
}
39+
}, `ToASCII("${idnaTest.input}")${idnaTest.comment ? " " + idnaTest.comment : ""}`);
40+
}
41+
}
Collapse file

‎test/fixtures/wpt/url/a-element-xhtml.xhtml‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/url/a-element-xhtml.xhtml
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
<html xmlns="http://www.w3.org/1999/xhtml">
44
<head>
55
<title>URL Test</title>
6+
<meta name="variant" content="?include=file"/>
7+
<meta name="variant" content="?include=javascript"/>
8+
<meta name="variant" content="?include=mailto"/>
9+
<meta name="variant" content="?exclude=(file|javascript|mailto)"/>
610
<script src="/resources/testharness.js"></script>
711
<script src="/resources/testharnessreport.js"></script>
12+
<script src="/common/subset-tests-by-key.js"></script>
813
<base id="base"/>
914
</head>
1015
<body>
Collapse file

‎test/fixtures/wpt/url/a-element.html‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/url/a-element.html
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<!doctype html>
22
<meta charset=utf-8>
3+
<meta name="variant" content="?include=file">
4+
<meta name="variant" content="?include=javascript">
5+
<meta name="variant" content="?include=mailto">
6+
<meta name="variant" content="?exclude=(file|javascript|mailto)">
37
<script src=/resources/testharness.js></script>
48
<script src=/resources/testharnessreport.js></script>
9+
<script src="/common/subset-tests-by-key.js"></script>
510
<base id=base>
611
<div id=log></div>
712
<script src=resources/a-element.js></script>
Collapse file

‎test/fixtures/wpt/url/historical.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/url/historical.any.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ test(function() {
2828
assert_equals(URL.domainToUnicode, undefined);
2929
}, "URL.domainToUnicode should be undefined");
3030

31+
test(() => {
32+
assert_throws_dom("DataCloneError", () => self.structuredClone(new URL("about:blank")));
33+
}, "URL: no structured serialize/deserialize support");
34+
35+
test(() => {
36+
assert_throws_dom("DataCloneError", () => self.structuredClone(new URLSearchParams()));
37+
}, "URLSearchParams: no structured serialize/deserialize support");
38+
3139
done();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.