tor-browser

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

force-load-at-top.html (1802B)


      1 <!doctype html>
      2 <title>ForceLoadAtTop blocks scroll on load</title>
      3 <meta charset=utf-8>
      4 <meta name="timeout" content="long">
      5 <link rel="help" href="https://wicg.github.io/ScrollToTextFragment/">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/resources/testdriver.js"></script>
      9 <script src="/resources/testdriver-vendor.js"></script>
     10 <script src="/common/utils.js"></script>
     11 <script src="stash.js"></script>
     12 
     13 <!--See comment in scroll-to-text-fragment.html for why this test has the
     14 structure it has -->
     15 <script>
     16 
     17 let test_cases = [
     18  {
     19    fragment: '#:~:text=target',
     20    type: 'text fragment'
     21  },
     22  {
     23    fragment: '#target:~:text=target',
     24    type: 'text fragment with element fallback'
     25  },
     26  {
     27    fragment: '#target',
     28    type: 'element fragment'
     29  },
     30  {
     31    fragment: '#history',
     32    type: 'history scroll restoration'
     33  },
     34 ];
     35 
     36 let document_policy_value = [
     37  'force-load-at-top',
     38  'no-force-load-at-top'
     39 ];
     40 
     41 for (const value of document_policy_value) {
     42  // If no-force-load-at-top is specified we expect to allow scrolling,
     43  // otherwise scroll on load should be blocked.
     44  const scroll_expected = value == 'no-force-load-at-top';
     45  const block_verb = scroll_expected ? "must not" : "must";
     46 
     47  for (const test_case of test_cases) {
     48    promise_test(t => new Promise((resolve, reject) => {
     49      let key = token();
     50 
     51      test_driver.bless('Open a URL with a text fragment directive', () => {
     52        window.open(`${value}-target.html?key=${key}${test_case.fragment}`, '_blank', 'noopener');
     53      });
     54 
     55      fetchResults(key, resolve, reject);
     56    }).then(data => {
     57      assert_equals(data.scrolled, scroll_expected);
     58    }), `${value} ${block_verb} block scroll on load from ${test_case.type}.`);
     59  }
     60 }
     61 </script>