Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/draw-element-image/element-image-fractional-size.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<title>ElementImage width and height should be doubles and support fractional values</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
<style>
#child {
width: 100.5px;
height: 200.75px;
background: green;
}
</style>
<canvas id="canvas" width="300" height="300" layoutsubtree>
<div id="child"></div>
</canvas>
<script>
'use strict';
promise_test(async t => {
const child = document.getElementById('child');
await waitForCanvasPaint(canvas);
let elementImage = canvas.captureElementImage(child);
assert_approx_equals(elementImage.width, 100.5, 0.001);
assert_approx_equals(elementImage.height, 200.75, 0.001);
}, 'ElementImage width and height should support fractional values');
</script>