Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
this layout test doesn't work
<!DOCTYPE html>
<canvas id="canvas" width="1" height="1"></canvas>
<script src="../../resources/js-test.js"></script>
<script>
jsTestIsAsync = true;
// Create 1x1 rgba(255, 0, 0, 0.5) image data.
var imageData = new ImageData(new Uint8ClampedArray([255, 0, 0, 127]), 1, 1);
var newImageData;
// Convert it to an image bitmap.
createImageBitmap(imageData).then(imageBitmap => {
// Draw it into a canvas.
var context = document.getElementById("canvas").getContext("2d");
context.drawImage(imageBitmap, 0, 0);
// Read the image data back and examine it.
newImageData = context.getImageData(0, 0, 1, 1);
shouldBe("Array.from(newImageData.data)", "[255, 0, 0, 127]");
finishJSTest();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment