tor-browser

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

test_load_during_reload.html (1327B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test loading a new page after calling reload()</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8  <script>
      9 
     10    function promiseForLoad() {
     11      return new Promise(resolve => {
     12        addEventListener("message", resolve, { once: true });
     13      });
     14    }
     15 
     16    add_task(async function runTest() {
     17      let win = window.open("file_load_during_reload.html");
     18      await promiseForLoad();
     19 
     20      win.location.reload();
     21      win.location.href = "file_load_during_reload.html?nextpage";
     22      await promiseForLoad();
     23 
     24      ok(win.location.href.includes("nextpage"), "Should have loaded the next page.");
     25      win.close();
     26    });
     27 
     28    add_task(async function runTest2() {
     29      let win = window.open("file_load_during_reload.html");
     30      await promiseForLoad();
     31 
     32      win.history.replaceState("", "", "?1");
     33      win.location.reload();
     34      win.history.pushState("", "", "?2");
     35      win.location.reload();
     36      await promiseForLoad();
     37 
     38      ok(win.location.href.includes("2"), "Should have loaded the second page.");
     39      win.close();
     40    });
     41 
     42  </script>
     43 </head>
     44 <body>
     45 <p id="display"></p>
     46 <div id="content" style="display: none"></div>
     47 <pre id="test"></pre>
     48 </body>
     49 </html>