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-invalidation.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<title>Canvas.drawElementImage: changed nested canvases should repaint</title>
<link rel="match" href="nested-canvas-invalidation-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<canvas id="canvas" layoutsubtree="true" width="100" height="100">
<canvas id="nested" width="100" height="100"></canvas>
</canvas>
<script>
onload = async function() {
const outerCtx = canvas.getContext('2d');
const nestedCtx = nested.getContext('2d');
nestedCtx.clearRect(0, 0, 100, 100);
nestedCtx.fillStyle = 'red';
nestedCtx.fillRect(0, 0, 100, 100);
await waitForCanvasPaint(canvas);
outerCtx.drawElementImage(nested, 0, 0);
nestedCtx.fillStyle = 'green';
nestedCtx.fillRect(0, 0, 100, 100);
await waitForCanvasPaint(canvas);
outerCtx.drawElementImage(nested, 0, 0);
takeScreenshot();
}();
</script>
</html>