tor-browser

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

005.html (1444B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>Popstate event listener registration</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 //this test checks that onpopstate works on the body element
     10 
     11 var readyForPop = false, bodypop = false, inlinepop = false;
     12 setup({explicit_done:true});
     13 
     14 //use a timeout to avoid "popstate fires onload" from setting the variables too early
     15 setTimeout(step1,1000);
     16 function step1() {
     17  readyForPop = true;
     18  test(function () {
     19    history.pushState('','');
     20    history.pushState('','');
     21  }, 'history.pushState support is needed for this testcase');
     22  history.go(-1);
     23  setTimeout(step2,50); //.go is queued to end of thread
     24 }
     25 function step2() {
     26  test(function () {
     27    assert_true( bodypop );
     28  }, '<body onpopstate="..."> should register a listener for the popstate event');
     29  window.onpopstate = function () { inlinepop = true; };
     30  history.go(-1);
     31  setTimeout(step3,50); //.go is queued to end of thread
     32 }
     33 function step3() {
     34  test(function () {
     35    assert_true( inlinepop );
     36  }, 'window.onpopstate should register a listener for the popstate event');
     37  done();
     38 }
     39    </script>
     40  </head>
     41  <body onpopstate="if( readyForPop ) { bodypop = true; }">
     42 
     43    <noscript><p>Enable JavaScript and reload</p></noscript>
     44    <div id="log"></div>
     45 
     46  </body>
     47 </html>