tor-browser

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

location.sub.html (1715B)


      1 <!doctype html>
      2 <meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
      3 <meta name=variant content="?encoding=windows-1252">
      4 <meta name=variant content="?encoding=x-cp1251">
      5 <meta name=variant content="?encoding=utf8">
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <div id=log></div>
      9 <script>
     10 function expected(encoding) {
     11  return "?" + {
     12    "UTF-8": "%C3%BF",
     13    "windows-1251": "%26%23255%3B",
     14    "windows-1252": "%FF"
     15  }[encoding];
     16 }
     17 
     18 [
     19  [(win, input) => { win.location = input; }, "location [PutForwards]"],
     20  [(win, input) => { win.location.assign(input); }, "location.assign()"],
     21  [(win, input) => { win.location.replace(input); }, "location.replace()"],
     22  [(win, input) => { win.location.href = input; }, "location.href"]
     23 ].forEach(([callback, desc]) => {
     24  async_test(t => {
     25    const frame = document.body.appendChild(document.createElement("iframe")),
     26          actualEncoding = document.characterSet
     27    callback(frame.contentWindow, "/common/blank.html?\u00FF");
     28    frame.onload = t.step_func_done(() => {
     29      assert_equals(frame.contentWindow.location.search, expected(actualEncoding));
     30    });
     31  }, desc);
     32 });
     33 
     34 async_test(t => {
     35  const frame = document.body.appendChild(document.createElement("iframe")),
     36        actualEncoding = document.characterSet;
     37  frame.src = "/common/blank.html";
     38  frame.onload = t.step_func(() => {
     39    frame.contentWindow.location.search = "\u00FF";
     40    frame.onload = t.step_func_done(() => {
     41      // location.search always uses UTF-8
     42      assert_equals(frame.contentWindow.location.search, expected("UTF-8"));
     43    });
     44  });
     45 }, "location.search");
     46 </script>