tor-browser

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

scroll-to-id-top.html (1326B)


      1 <!doctype html>
      2 <title>Fragment Navigation: TOP is a valid element id, which overrides navigating to top of the document</title>
      3 <meta name=timeout content=long>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <body>
      7 <div></div>
      8 <div id="Top" style="position:absolute; top:200px;"></div>
      9 <div style="height:200em; position:relative;"></div>
     10 <script>
     11 var steps = [{
     12    fragid:'Top',
     13    handler: function(){
     14      assert_equals( scrollPosition(), 200 );
     15    }
     16  },{
     17    // scroling to top should work when fragid differs from id by case.
     18    fragid:'top',
     19    handler: function(){
     20      assert_equals( scrollPosition(), 0 );
     21    }
     22  }];
     23 
     24 function scrollPosition(){
     25  return document.documentElement.scrollTop || document.body.scrollTop;
     26 }
     27 
     28 function runNextStep(){
     29    if( steps.length > 0 ) {
     30      var step = steps.shift();
     31      var listener = t.step_func( function(){
     32        step.handler();
     33        runNextStep();
     34      });
     35      scrollToFragmentThenDo( step.fragid, listener );
     36    } else {
     37      t.done();
     38    }
     39 }
     40 
     41 function scrollToFragmentThenDo( fragid, then ){
     42  location.hash = fragid;
     43  setTimeout( then, 1 );
     44 }
     45 
     46 var t = async_test();
     47 t.step( function(){
     48  assert_equals(location.hash, "", "Page must be loaded with no hash");
     49  runNextStep();
     50 })
     51 </script>