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/nested-canvas-scale.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<title>Canvas.drawElementImage: Nested canvas is scaled correctly</title>
<link rel="match" href="nested-canvas-scale-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<style>
#canvas {
background-color: red;
}
</style>
<canvas id="canvas" content="drawable" width="100" height="100">
<canvas id="nested" drawable width="100" height="100"></canvas>
</canvas>
<script>
onload = async function() {
await waitForCanvasPaint(canvas);
const outerCtx = canvas.getContext('2d');
const nestedCtx = nested.getContext('2d');
nestedCtx.clearRect(0, 0, 100, 100);
nestedCtx.fillStyle = 'blue';
nestedCtx.fillRect(0, 0, 100, 100);
outerCtx.drawElementImage(nested, 0, 0);
takeScreenshot();
}();
</script>
</html>