tor-browser

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

block-in-inline-hittest-002.html (1252B)


      1 <html>
      2 <meta name="assert" content="Test list-based hit-testing for block-in-inline">
      3 <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#anonymous-block-level">
      4 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint">
      5 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint">
      6 <link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org" />
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <body>
     10  <div>
     11    <a href="#">
     12      <h3 id="target">
     13        text
     14      </h3>
     15    </a>
     16  </div>
     17 <script>
     18 function ancestors(element) {
     19  const list = [];
     20  for (; element; element = element.parentElement)
     21    list.push(element);
     22  return list;
     23 }
     24 
     25 const target = document.getElementById('target');
     26 const bounds = target.getBoundingClientRect();
     27 const x = bounds.x + bounds.width / 2;
     28 const y = bounds.y + bounds.height / 2;
     29 
     30 test(() => {
     31  const result = document.elementFromPoint(x, y);
     32  assert_equals(result, target);
     33 }, "elementFromPoint");
     34 
     35 test(() => {
     36  const results = document.elementsFromPoint(x, y);
     37  assert_array_equals(results, ancestors(target));
     38 }, "elementsFromPoint");
     39 </script>
     40 </body>
     41 </html>