Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-transforms/hittest-preserve-3d.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
html, body { margin: 0; padding: 0; }
#parent {
width: 300px;
height: 300px;
background-color: rgba(0, 0, 255, 0.5);
transform-style: preserve-3d;
}
#child1 {
width: 200px;
height: 100px;
background-color: red;
transform: translateZ(-10px);
}
#child2 {
width: 200px;
height: 100px;
background-color: green;
transform: translateZ(10px);
}
</style>
</head>
<body>
<div id="parent">
<div id="child1"></div>
<div id="child2"></div>
</div>
<script>
async function hit_test(x, y, target_id) {
const promise = new Promise(resolve => {
document.addEventListener("click", function (event) {
assert_equals(event.target.id, target_id, `Click should be on ${target_id}`);
resolve();
}, { once: true });
});
let click = new test_driver.Actions()
.pointerMove(x, y)
.pointerDown()
.pointerUp();
await click.send();
await promise;
}
promise_test(async () => {
await hit_test(50, 50, "parent");
await hit_test(50, 150, "child2");
await hit_test(50, 250, "parent");
}, "Hit test preserve-3d descendant");
</script>
</body>
</html>