Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/draw-element-image/non-opaque-element.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<title>Canvas.drawElementImage: div with transparent background</title>
<link rel="author" href="mailto:schenney@chromium.org">
<link rel="match" href="non-opaque-element-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<style>
#child {
width: 100px;
height: 100px;
background: transparent;
}
#canvas {
background: grey;
}
.grandchild {
background: green;
position: absolute;
width: 20px;
height: 20px;
}
</style>
<canvas id=canvas width="200" height="200" layoutsubtree>
<div id=child>
<div class="grandchild" style="left: 0px; top: 0px"></div>
<div class="grandchild" style="left: 80px; top: 0px"></div>
<div class="grandchild" style="left: 0px; top: 80px"></div>
<div class="grandchild" style="left: 80px; top: 80px"></div>
</div>
</canvas>
<script>
onload = async () => {
await waitForCanvasPaint(canvas);
canvas.getContext("2d").drawElementImage(child, 20, 30);
takeScreenshot();
};
</script>
</html>