tor-browser

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

visual-scrollIntoView-002.html (1807B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta name="viewport" content="width=device-width,initial-scale=1">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-actions.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <script src="support/action-utils.js"></script>
     10 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1947470">
     11 <link rel="help" href="https://drafts.csswg.org/cssom-view/#perform-a-scroll">
     12 <style>
     13 html {
     14  height: 10000px;
     15 }
     16 body {
     17  margin: 0px;
     18  padding: 0px;
     19 }
     20 #fixed {
     21  position: fixed;
     22  bottom: 0px;
     23  height: 50vh;
     24  width: 100vw;
     25  overflow: scroll;
     26  background-color: gray;
     27 }
     28 input {
     29  height: 20px;
     30 }
     31 </style>
     32 <div id="fixed">
     33  <div style="height: calc(80vh - 40px)"></div>
     34  <input type="text" id="name" />
     35 </div>
     36 <script>
     37 promise_test(async t => {
     38  assert_equals(window.scrollY, 0);
     39  assert_equals(visualViewport.scale, 1.0);
     40  assert_equals(visualViewport.pageTop, 0);
     41 
     42  // Pinch zoom in this document.
     43  await pinch_zoom_action();
     44 
     45  assert_greater_than(visualViewport.scale, 1.0);
     46 
     47  // Scroll the root scroll container.
     48  window.scrollTo(0, 1000);
     49  assert_equals(window.scrollY, 1000);
     50 
     51  const expectedPageTop = visualViewport.pageTop;
     52 
     53  // Now trigger a scrollIntoView call to an element inside a position:fixed element.
     54  scrollPromise =
     55      new Promise(resolve => visualViewport.addEventListener("scroll", resolve));
     56  document.querySelector('#name').scrollIntoView({ behavior: "instant" });
     57  await scrollPromise;
     58 
     59  assert_greater_than(visualViewport.pageTop, expectedPageTop);
     60 }, "Element.scrollIntoView scrolls visually to a position: fixed element with non-zero layout scroll offset");
     61 </script>