tor-browser

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

scroll-frag-percent-encoded.html (1905B)


      1 <!doctype html>
      2 <title>Fragment Navigation: fragment id should be percent-decoded</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="has two spaces" style="position:absolute; top:100px;"></div>
      9 <div id="escape%20collision" style="position:absolute; top:200px;"></div>
     10 <div id="%20has%20two%20spaces" style="position:absolute; top:300px;"></div>
     11 <div id="escape collision" style="position:absolute; top:400px;"></div>
     12 <div id="do%20not%20go%20here" style="position:absolute; top:400px;"></div>
     13 <div style="height:200em;"></div>
     14 <script>
     15 var steps = [{
     16    fragid:'has%20two%20spaces',
     17      handler: function(){
     18        assert_equals( document.scrollingElement.scrollTop, 100 );
     19      }
     20    },{
     21      fragid:'escape%20collision',
     22      handler: function(){
     23        assert_equals( document.scrollingElement.scrollTop, 200 );
     24        document.getElementById("%20has%20two%20spaces").setAttribute("id", "has%20two%20spaces");
     25      }
     26    },{
     27      fragid:'has%20two%20spaces',
     28      handler: function(){
     29        assert_equals( document.scrollingElement.scrollTop, 300 );
     30      }
     31    },{
     32      fragid:'do%20not%20go%20here',
     33      handler: function(){
     34        // don't move
     35        assert_equals( document.scrollingElement.scrollTop, 400 );
     36      }
     37    }];
     38 
     39 function runNextStep(){
     40    if( steps.length > 0 ) {
     41      var step = steps.shift();
     42      var listener = t.step_func( function(){
     43        step.handler();
     44        runNextStep();
     45      });
     46      scrollToFragmentThenDo( step.fragid, listener );
     47    } else {
     48      t.done();
     49    }
     50 }
     51 
     52 function scrollToFragmentThenDo( fragid, then ){
     53  location.hash = fragid;
     54  setTimeout( then, 1 );
     55 }
     56 
     57 var t = async_test();
     58 t.step( function(){
     59  assert_equals(location.hash, "", "Page must be loaded with no hash");
     60  runNextStep();
     61 })
     62 </script>