tor-browser

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

selection-target.html (1866B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>scroll-padding is respected when typing into an out-of-view textfield</title>
      4 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1701928">
      5 <link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#scroll-padding">
      6 <link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
      7 <link rel="author" href="https://mozilla.org" title="Mozilla">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/resources/testdriver.js"></script>
     11 <script src="/resources/testdriver-vendor.js"></script>
     12 <script src="/resources/testdriver-actions.js"></script>
     13 <style>
     14  body {
     15    margin: 0;
     16  }
     17  :root {
     18    scroll-padding-top: 100px;
     19  }
     20 </style>
     21 <div style="height: 300vh;"></div>
     22 <input type="text">
     23 <div style="height: 300vh;"></div>
     24 <script>
     25 function tick() {
     26  return new Promise(resolve => {
     27    requestAnimationFrame(() => requestAnimationFrame(resolve));
     28  });
     29 }
     30 
     31 promise_test(async function() {
     32  let input = document.querySelector("input");
     33  input.focus();
     34  await tick();
     35  // Scroll out of view.
     36  scrollTo(0, document.scrollingElement.scrollHeight);
     37  await tick();
     38  assert_not_equals(window.scrollY, 0);
     39  assert_true(input.getBoundingClientRect().bottom < 0, "Should be offscreen");
     40  // NOTE(emilio): Using test_driver.Actions() instead of test_driver.send_keys
     41  // because the later scrolls the target into view which would defeat the
     42  // point of the test...
     43  await new test_driver.Actions().keyDown('a').send();
     44  await tick();
     45  // We assert the bottom rather than the top because Gecko scrolls the
     46  // selection bounds into view, not the whole input.
     47  assert_true(input.getBoundingClientRect().bottom > 100, "Scroll-padding should be respected");
     48 }, "Test scrolling into view when typing");
     49 </script>