blob: 21950b472cc884692d3195bd714686ff9a3bc7cb [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/mojo-helpers.js"></script>
<script src="resources/mock-imagecapture.js"></script>
<body>
<canvas id='canvas' width=10 height=10/>
</body>
<script>
// This test verifies that ImageCapture can takePhoto()s, with a mock Mojo
// interface implementation.
async_test(function(t) {
var canvas = document.getElementById('canvas');
var context = canvas.getContext("2d");
context.fillStyle = "red";
context.fillRect(0, 0, 10, 10);
var stream = canvas.captureStream();
mockImageCaptureReady
.then(mock => {
return new ImageCapture(stream.getVideoTracks()[0]);
},
error => {
assert_unreached("Error creating MockImageCapture: " + error);
})
.then(capturer => {
return capturer.takePhoto();
})
.then(blob => {
// JS Blob is almost-opaque, can only check |type| and |size|.
assert_equals(blob.type, 'image/cat');
assert_equals(blob.size, 2);
t.done();
})
.catch(error => {
assert_unreached("Error during takePhoto(): " + error.message);
});
}, 'exercises ImageCapture.takePhoto()');
</script>