mirror of
https://github.com/servo/servo.git
synced 2025-08-23 14:25:33 +01:00
dom: getElementsFromPoint does the hit testing on viewport coordinates.
We got this wrong, I was just writing a test for #12777 when I found this.
This commit is contained in:
parent
3c7de6b821
commit
f9c0f2df13
4 changed files with 56 additions and 6 deletions
|
@ -6624,6 +6624,12 @@
|
|||
"url": "/_mozilla/mozilla/global.html"
|
||||
}
|
||||
],
|
||||
"mozilla/hit_test_pos_fixed.html": [
|
||||
{
|
||||
"path": "mozilla/hit_test_pos_fixed.html",
|
||||
"url": "/_mozilla/mozilla/hit_test_pos_fixed.html"
|
||||
}
|
||||
],
|
||||
"mozilla/htmlcollection.html": [
|
||||
{
|
||||
"path": "mozilla/htmlcollection.html",
|
||||
|
|
42
tests/wpt/mozilla/tests/mozilla/hit_test_pos_fixed.html
Normal file
42
tests/wpt/mozilla/tests/mozilla/hit_test_pos_fixed.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Hit-test of an element with position: fixed should discard scroll offset</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
html, body { margin: 0; padding: 0; }
|
||||
.hitme {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background: blue;
|
||||
}
|
||||
|
||||
.hitme:hover { background: green }
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
background: red;
|
||||
/* Ensure we can scroll */
|
||||
height: 2000px;
|
||||
/* FIXME: Uncomment when servo supports this properly
|
||||
height: calc(100vh + 200px); */
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="hitme"></div>
|
||||
</div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
window.onload = t.step_func(function() {
|
||||
window.scrollTo(0, 200);
|
||||
var elements = document.elementsFromPoint(10, 10);
|
||||
assert_true(elements.length > 0, "Should be elements");
|
||||
assert_true(elements[0].className == "hitme",
|
||||
"should be able to hit the fixed-positioned element");
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue