<!DOCTYPE html>
<title>Verify that paused video element does not play MediaStream.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<canvas width="1" height="1"></canvas>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var canvas = document.querySelector("canvas");
navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
// start preview.
video.srcObject = stream;
}, t.unreached_func);
video.oncanplaythrough = t.step_func_done(function() {
var width = canvas.width;
var height = canvas.height;
var ctx = canvas.getContext("2d");
ctx.fillStyle = "black";
ctx.fillRect(0, 0, width, height);
// paint to canvas.
ctx.drawImage(video, 0, 0, width, height);
var frame = ctx.getImageData(0, 0, width, height);
assert_not_equals(frame, null);
// Video element is paused, so it cannot be playing the stream.
assert_equals(frame.data[0] + frame.data[1] + frame.data[2], 0);
});
});
</script>