diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/mediacapture-image/ImageCapture-grabFrame.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-image/ImageCapture-grabFrame.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-image/ImageCapture-grabFrame.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-image/ImageCapture-grabFrame.html b/testing/web-platform/tests/mediacapture-image/ImageCapture-grabFrame.html new file mode 100644 index 0000000000..bf5e9400a0 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-image/ImageCapture-grabFrame.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> +<canvas id='canvas0' width=10 height=10/> +<canvas id='canvas1' width=10 height=10/> +</body> +<script> + +// This test verifies that ImageCapture can grabFrame()s. + +var test = async_test(function() { + var canvas0 = document.getElementById('canvas0'); + var context0 = canvas0.getContext("2d"); + context0.fillStyle = "red"; + context0.fillRect(0, 0, 10, 10); + + var stream = canvas0.captureStream(); + + var capturer = new ImageCapture(stream.getVideoTracks()[0]); + + capturer.grabFrame() + .then(bitmap => { + assert_equals(canvas0.width, bitmap.width); + assert_equals(canvas0.height, bitmap.height); + + var context1 = document.getElementById('canvas1').getContext("2d"); + context1.drawImage(bitmap, 0, 0); + + var imageData0 = context0.getImageData(0, 0, 10, 10); + var imageData1 = context1.getImageData(0, 0, 10, 10); + + assert_equals(imageData0.width, imageData1.width); + assert_equals(imageData0.height, imageData1.height); + assert_equals(imageData0.data.length, imageData1.data.length); + for (var i = 0; i < imageData0.data.length; i++) + assert_approx_equals(imageData0.data[i], imageData1.data[i], 5); + + this.done(); + }) + .catch(error => { + assert_unreached('Error during grabFrame(): '+ error); + }); +}, 'exercises the ImageCapture API creation and grabFrame().'); + +</script> |