tor-browser

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

idn-child.sub.https.html (3061B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <script src="/resources/testharness.js"></script>
      5  <script src="/resources/testdriver.js"></script>
      6  <script src="/resources/testdriver-vendor.js"></script>
      7  <script src="/cookies/resources/cookie-test.js"></script>
      8 </head>
      9 <body>
     10  <script>
     11    async function assert_cookie(response, cookie) {
     12      const get = await response.text();
     13      assert_equals(get, cookie);
     14      assert_equals(document.cookie, cookie);
     15    }
     16 
     17    async function assert_no_cookie(response) {
     18      const get = await response.text();
     19      assert_equals(get, "no cookies");
     20      assert_equals(document.cookie, "");
     21    }
     22 
     23    promise_test(async t => {
     24      t.add_cleanup(async () => { await fetch("idn.py?delete-utf8&host={{host}}") });
     25      let response = await fetch("idn.py?set-utf8&host={{host}}");
     26      assert_equals(await response.text(), "set");
     27      response = await fetch("idn.py?get&host={{host}}");
     28      await assert_no_cookie(response);
     29    }, "UTF8-encoded IDN in domain attribute");
     30 
     31    promise_test(async t => {
     32      t.add_cleanup(async () => { await fetch("idn.py?delete-utf8-dot&host={{host}}") });
     33      let response = await fetch("idn.py?set-utf8-dot&host={{host}}");
     34      assert_equals(await response.text(), "set");
     35      response = await fetch("idn.py?get&host={{host}}");
     36      await assert_no_cookie(response);
     37    }, "UTF8-encoded IDN with non-ASCII dot in domain attribute");
     38 
     39    promise_test(async t => {
     40      t.add_cleanup(async () => { await fetch("idn.py?delete-wrong-utf8&host={{host}}") });
     41      let response = await fetch("idn.py?set-wrong-utf8&host={{host}}");
     42      assert_equals(await response.text(), "set");
     43      response = await fetch("idn.py?get&host={{host}}");
     44      await assert_no_cookie(response);
     45    }, "wrong UTF8-encoded IDN in domain attribute");
     46 
     47    promise_test(async t => {
     48      t.add_cleanup(async () => { await fetch("idn.py?delete-punycode&host={{host}}") });
     49      let response = await fetch("idn.py?set-punycode&host={{host}}");
     50      assert_equals(await response.text(), "set");
     51      response = await fetch("idn.py?get&host={{host}}");
     52      await assert_cookie(response, "punycode=set");
     53    }, "punycode IDN in domain attribute");
     54 
     55    promise_test(async t => {
     56      t.add_cleanup(async () => { await fetch("idn.py?delete-wrong-punycode&host={{host}}") });
     57      let response = await fetch("idn.py?set-wrong-punycode&host={{host}}");
     58      assert_equals(await response.text(), "set");
     59      response = await fetch("idn.py?get&host={{host}}");
     60      await assert_no_cookie(response);
     61    }, "wrong punycode IDN in domain attribute");
     62 
     63    promise_test(async t => {
     64      t.add_cleanup(async () => { await fetch("idn.py?delete-invalid-byte&host={{host}}") });
     65      let response = await fetch("idn.py?set-invalid-byte&host={{host}}");
     66      assert_equals(await response.text(), "set");
     67      response = await fetch("idn.py?get&host={{host}}");
     68      await assert_no_cookie(response);
     69    }, "IDN with invalid UTF-8 bytes in domain attribute");
     70  </script>
     71 </body>
     72 </html>