Skip to content

elementFromPoint() is sometimes incorrect #41227

@webbeef

Description

@webbeef

Use this simplified version of tests/wpt/tests/pointerevents/compat/pointerevent_mouse-pointer-on-scrollbar.html for testing:

<!DOCTYPE html>
<style>
  #target {
    height: 100px;
    width: 100px;
    overflow-y: scroll;
  }
  #spacer {
    background: green;
    height: 200px;
  }
</style>
<div id="target">
  <div id="spacer"></div>
</div>

<script>
  var receivedEvents = [];
  var targetDiv = document.getElementById("target");

  var rect = targetDiv.getBoundingClientRect();
  var x1 = rect.right - 5;
  var y1 = rect.top + 20;

  let hitNode = document.elementFromPoint(x1, y1);
  console.log(`Testing ${x1}, ${y1}`);
  console.log(`hitNode is ${hitNode.getAttribute("id")}`);
  console.log(`targetDiv is ${targetDiv.getAttribute("id")}`);
</script>

Servo's incorrect output is:

Testing 103, 28
hitNode is spacer
targetDiv is target

while Firefox's correct output is:

Testing 103, 28
hitNode is target
targetDiv is target

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions