tor-browser

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

006.html (1746B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>Firing popstate after onload, even if there is no pushed/replaced state</title>
      5    <script type="text/javascript" src="/resources/testharness.js"></script>
      6    <script type="text/javascript" src="/resources/testharnessreport.js"></script>
      7    <script type="text/javascript">
      8 
      9 //spec (25 March 2011 draft) states that popstate must not fire after onload unless there is a pushed/replaced state that is navigated
     10 var popfired = false;
     11 setup({explicit_done:true});
     12 window.addEventListener('popstate',function (e) { popfired = true; },false);
     13 test(function () {
     14  assert_equals( history.state, null );
     15 }, 'history.state should initially be null');
     16 window.onload = function () {
     17  test(function () {
     18    assert_false( popfired );
     19  }, 'popstate event should not fire before onload fires');
     20  test(function () {
     21    assert_equals( history.state, null );
     22  }, 'history.state should still be null onload');
     23  popfired = false;
     24  setTimeout(function () {
     25    test(function () {
     26      assert_false( popfired );
     27    }, 'popstate event should not fire after onload fires');
     28    test(function () {
     29      assert_equals( history.state, null );
     30    }, 'history.state should still be null after onload');
     31    test(function () {
     32      var failed = false, realstate = history.state;
     33      try {
     34        history.state = '';
     35      } catch(e) {
     36        failed = e;
     37      }
     38      assert_equals(history.state,realstate,'property was read/write');
     39      assert_false(failed);
     40    }, 'writing to history.state should be silently ignored and not throw an error');
     41    done();
     42  },100);
     43 };
     44 
     45    </script>
     46  </head>
     47  <body>
     48 
     49    <noscript><p>Enable JavaScript and reload</p></noscript>
     50    <div id="log"></div>
     51 
     52  </body>
     53 </html>