tor-browser

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

004.html (2153B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>Final history position for history.go should be calculated when executing the task</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 setup({explicit_done:true});
      9 window.onload = function () {
     10  var hashcount = 0;
     11  if( location.hash && location.hash != '#' ) {
     12    location.href = location.href.replace(/#.*$/,'');
     13    return;
     14  }
     15  setTimeout(add1,100);
     16  function add1() {
     17    location.hash = '#foo';
     18    setTimeout(add2,100);
     19  }
     20  function add2() {
     21    location.hash = '#bar';
     22    setTimeout(add3,100);
     23  }
     24  function add3() {
     25    location.hash = '#baz';
     26    setTimeout(dojumps,100);
     27  }
     28  function dojumps() {
     29    window.onhashchange = function () {
     30      hashcount++;
     31    };
     32    history.go(-2);
     33    test(function () {
     34      //many browsers special-case jumps that only imply hash changes and will do them synchronously - the spec does allow this
     35      assert_equals( hashcount, 0, 'hashchange fired even though the location should not have changed' );
     36      assert_equals( location.hash.replace(/^#/,''), 'baz', 'the browser navigated synchronously' );
     37    }, '.go commands should be queued until the thread has ended');
     38    history.go(-1);
     39    setTimeout(checkjumps,100);
     40  }
     41  function checkjumps() {
     42    test(function () {
     43      assert_true( !!hashcount, 'this testcase requires haschange support; the test cannot be used in this browser' );
     44    }, 'browser needs to support hashchange events for this testcase');
     45    test(function () {
     46      assert_equals( hashcount, 2, 'the wrong number of queued commands were executed' );
     47    }, 'queued .go commands should all be executed when the queue is processed');
     48    test(function () {
     49      assert_equals( location.hash.replace(/^#/,''), '' );
     50    }, 'history position should be calculated when executing, not when calling the .go command');
     51    done();
     52  }
     53 };
     54    </script>
     55  </head>
     56  <body>
     57 
     58    <noscript><p>Enable JavaScript and reload</p></noscript>
     59    <div id="log"></div>
     60 
     61  </body>
     62 </html>