-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathIdnaTestV2-removed.any.js
More file actions
23 lines (20 loc) · 823 Bytes
/
IdnaTestV2-removed.any.js
File metadata and controls
23 lines (20 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// META: global=window
promise_test(() => fetch("resources/IdnaTestV2-removed.json").then(res => res.json()).then(runTests), "Loading data…");
function runTests(idnaTests) {
for (const idnaTest of idnaTests) {
if (typeof idnaTest === "string") {
continue // skip comments
}
test(() => {
if (idnaTest.output === null) {
assert_throws_js(TypeError, () => new URL(`https://${idnaTest.input}/x`));
} else {
const url = new URL(`https://${idnaTest.input}/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 : ""}`);
}
}