tor-browser

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

scrollIntoView-horizontal-partially-visible.html (1677B)


      1 <!doctype html>
      2 <title>CSSOM View - scrollIntoView scrolls partially-visible element in both inline and block directions.</title>
      3 <meta charset="utf-8">
      4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      5 <link rel="author" title="Mozilla" href="https://mozilla.org">
      6 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview">
      7 <link rel="help" href="https://bugs.webkit.org/show_bug.cgi?id=203497">
      8 <link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=916631">
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <style>
     12  #scroller {
     13    width: 200px;
     14    height: 200px;
     15    padding-top: 200px;
     16    padding-left: 200px;
     17    background: purple;
     18    overflow: hidden;
     19  }
     20  #child {
     21    width: 400px;
     22    height: 400px;
     23    background: green;
     24  }
     25 </style>
     26 <div id="scroller">
     27  <div id="child"></div>
     28 </div>
     29 <script>
     30  test(function() {
     31    let scroller = document.getElementById("scroller");
     32    let child = document.getElementById("child");
     33 
     34    scroller.scrollTop = 0;
     35    scroller.scrollLeft = 0;
     36 
     37    assert_equals(scroller.scrollTop, 0, "Precondition");
     38    assert_equals(scroller.scrollLeft, 0, "Precondition");
     39    assert_not_equals(scroller.scrollTopMax, 0, "Precondition")
     40    assert_not_equals(scroller.scrollLeftMax, 0, "Precondition")
     41 
     42    child.scrollIntoView();
     43 
     44    assert_equals(scroller.scrollTop, 200, "Should have scrolled in the block direction");
     45    assert_equals(scroller.scrollLeft, 200, "Should have scrolled in the inline direction");
     46  }, "scrollIntoView scrolls partially-visible child in both axes");
     47 </script>