tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

IdnaTestV2-removed.window.js (799B)


      1 promise_test(() => fetch("resources/IdnaTestV2-removed.json").then(res => res.json()).then(runTests), "Loading data…");
      2 
      3 function runTests(idnaTests) {
      4  for (const idnaTest of idnaTests) {
      5    if (typeof idnaTest === "string") {
      6      continue // skip comments
      7    }
      8 
      9    test(() => {
     10      if (idnaTest.output === null) {
     11        assert_throws_js(TypeError, () => new URL(`https://${idnaTest.input}/x`));
     12      } else {
     13        const url = new URL(`https://${idnaTest.input}/x`);
     14        assert_equals(url.host, idnaTest.output);
     15        assert_equals(url.hostname, idnaTest.output);
     16        assert_equals(url.pathname, "/x");
     17        assert_equals(url.href, `https://${idnaTest.output}/x`);
     18      }
     19    }, `ToASCII("${idnaTest.input}")${idnaTest.comment ? " " + idnaTest.comment : ""}`);
     20  }
     21 }