Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html>
<title>elementFromPoint should respect z-index</title>
<link rel="help" href="https://github.com/WICG/html-in-canvas">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<style>
#canvas {
width: 200px;
height: 200px;
}
div {
width: 100px;
height: 100px;
background: green;
position: absolute;
top: 0;
left: 0;
}
</style>
<canvas id=canvas width="200" height="200" layoutsubtree>
<div id=a></div>
<div id=b></div>
</canvas>
<script>
promise_test(async function() {
a.style.zIndex = 5;
b.style.zIndex = 6;
await waitForCanvasPaint(canvas);
const ctx = canvas.getContext('2d');
ctx.drawElementImage(b, 0, 0);
ctx.drawElementImage(a, 0, 0);
assert_equals(document.elementFromPoint(60, 60), a);
}, 'Draw order trumps z-index in hit testing.');
</script>
</html>