tor-browser

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

url-origin.any.js (761B)


      1 promise_test(() => Promise.all([
      2  fetch("resources/urltestdata.json").then(res => res.json()),
      3  fetch("resources/urltestdata-javascript-only.json").then(res => res.json()),
      4 ]).then((tests) => tests.flat()).then(runURLTests), "Loading data…");
      5 
      6 function runURLTests(urlTests) {
      7  for (const expected of urlTests) {
      8    // Skip comments and tests without "origin" expectation
      9    if (typeof expected === "string" || !("origin" in expected))
     10      continue;
     11 
     12    const base = expected.base !== null ? expected.base : undefined;
     13 
     14    test(() => {
     15      const url = new URL(expected.input, base);
     16      assert_equals(url.origin, expected.origin, "origin");
     17    }, `Origin parsing: <${expected.input}> ${base ? "against <" + base + ">" : "without base"}`);
     18  }
     19 }