Skip to content

Instantly share code, notes, and snippets.

@jeremyroman
Created October 17, 2015 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyroman/9f9cbd38b1bd9b0482ee to your computer and use it in GitHub Desktop.
Save jeremyroman/9f9cbd38b1bd9b0482ee to your computer and use it in GitHub Desktop.
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