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

URL: run IdnaTestV2.txt in WPT #38080

Merged
merged 8 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ scratch
/css/dist
/css/dist_last
/css/tools/cache
/url/tools/IdnaTestV2.txt
/webaudio/idl/*

# w3c-test.org PR-branch mirroring
Expand Down
27 changes: 27 additions & 0 deletions url/IdnaTestV2.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
promise_test(() => fetch("resources/IdnaTestV2.json").then(res => res.json()).then(runTests), "Loading data…");

function runTests(idnaTests) {
for (const idnaTest of idnaTests) {
if (typeof idnaTest === "string") {
continue // skip comments
}
if (idnaTest.input === "") {
continue // cannot test empty string input through new URL()
}
// Percent-encode the input such that ? and equivalent code points do not end up counting as
// part of the URL, but are parsed through the host parser instead.
const encodedInput = encodeURIComponent(idnaTest.input);
annevk marked this conversation as resolved.
Show resolved Hide resolved

test(() => {
if (idnaTest.output === null) {
assert_throws_js(TypeError, () => new URL(`https://${encodedInput}/x`));
} else {
const url = new URL(`https://${encodedInput}/x`);
assert_equals(url.host, idnaTest.output);
assert_equals(url.hostname, idnaTest.output);
assert_equals(url.pathname, "/x");
assert_equals(url.href, `https://${idnaTest.output}/x`);
}
}, `ToASCII("${idnaTest.input}")${idnaTest.comment ? " " + idnaTest.comment : ""}`);
}
}
13 changes: 13 additions & 0 deletions url/resources/IdnaTestV2-feedback.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
2023-01. Feedback by Anne van Kesteren on

https://unicode.org/Public/idna/latest/IdnaTestV2.txt
Date: 2022-05-26, 22:30:12 GMT

(I have almost exclusively focused on ToASCII cases.)

* VerifyDnsLength is not P4, but rather A4_1 and A4_2.
* Tests that use trailing ASCII digit labels are not useful for browsers as that will trigger the IPv4 parser. This is a problem for a number of the A4_1 and A4_2 tests. And also a large number of tests later on, such as ToASCII("xn--gl0as212a.8.") or ToASCII("1.27").
* Test for ToASCII("$") is marked P1 and V6, not U1. This also effects numerous tests with <, >, and =. If they continue to have multiple statuses that will also make it impossible to filter them in an automated fashion.
* NV8 is not used as a status.
* A3 and X3 do not appear to be used as a status. (These are catered for by P4 presumably.)
* CheckBidi is not V8. V8 does not appear to be used. You'd have to filter out all B1-6 statuses instead.
Loading