tor-browser

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

test_state_size.html (984B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test the max size of the data parameter of push/replaceState</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8  <script>
      9    SimpleTest.waitForExplicitFinish();
     10    function test() {
     11      let tooLarge = SpecialPowers.getIntPref("browser.history.maxStateObjectSize");
     12      let allowed = Math.floor(tooLarge / 2);
     13 
     14      history.pushState(new Array(allowed).join("a"), "");
     15      ok(true, "Adding a state should succeed.");
     16 
     17      try {
     18        history.pushState(new Array(tooLarge).join("a"), "");
     19        ok(false, "Adding a too large state object should fail.");
     20      } catch(ex) {
     21        ok(true, "Adding a too large state object should fail.");
     22      }
     23      SimpleTest.finish();
     24    }
     25  </script>
     26 </head>
     27 <body onload="test()">
     28 <p id="display"></p>
     29 <div id="content" style="display: none"></div>
     30 <pre id="test"></pre>
     31 </body>
     32 </html>