blob: b6b7db47cc95f7d41900731ba6e4eb6c6a7cb59e [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<canvas style="position:absolute; top:40px; left:40px" width="200" height="200"></canvas>
<script src="../resources/js-test.js"></script>
<script>
testRunner.waitUntilDone();
testRunner.dumpAsText();
requestAnimationFrame(() => {
var canvas = document.querySelector("canvas");
var context = canvas.getContext("2d");
context.fillStyle = "red";
context.fillRect(0, 0, 200, 200);
internals.setPageScaleFactor(2);
internals.setVisualViewportOffset(200, 200);
requestAnimationFrame(() => {
testRunner.copyImageAtAndCapturePixelsAsyncThen(0, 0, (width, height, snapshot) => {
try {
if (width !== 200 || height !== 200)
testFailed("The copied image must be 200x200.");
var topleft = new Uint8Array(snapshot).subarray(0, 4);
if (topleft[0] !== 255 || topleft[1] !== 0 || topleft[2] !== 0 || topleft[3] !== 255)
testFailed("The copied image's top left must be red. " + JSON.stringify(topleft));
} catch (e) {
testFailed("" + e);
}
testRunner.notifyDone();
});
});
});
</script>
</body>
</html>