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-reset.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<title>Canvas.drawElementImage: outer_ctx.reset() should not clear nested canvas background color</title>
<link rel="match" href="nested-canvas-reset-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<canvas id="outer" width="200" height="200" layoutsubtree>
<div id="outer_target">
<canvas id="inner" width="100" height="100" style="background-color: green;" layoutsubtree>
<div id="inner_target" style="width: 50px; height: 50px;"></div>
</canvas>
</div>
</canvas>
<script>
inner.onpaint = () => {
const inner_ctx = inner.getContext('2d');
inner_ctx.reset();
inner_ctx.drawElementImage(inner_target, 0, 0);
};
outer.onpaint = () => {
const outer_ctx = outer.getContext('2d');
outer_ctx.reset();
outer_ctx.drawElementImage(outer_target, 0, 0);
};
onload = async function() {
await waitForCanvasPaint(outer);
takeScreenshot();
};
</script>
</html>