blob: 0c738c556b70e53bea3bdf866ea2d04c6b54a161 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>MediaRecorder start timeSlice option</title>
<link rel="help" href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#mediarecorder">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<canvas id="canvas" width="200" height="200">
</canvas>
<script>
promise_test(async t => {
const video = await navigator.mediaDevices.getUserMedia({ audio : true, video : true });
const recorder = new MediaRecorder(video);
assert_equals(recorder.stream, video);
let promise = new Promise(resolve => recorder.ondataavailable = resolve);
recorder.start(100);
await promise;
promise = new Promise(resolve => recorder.ondataavailable = resolve);
await promise;
}, 'Make sure that MediaRecorder timeSlice triggers regular ondataavailable events');
promise_test(async t => {
const video = await navigator.mediaDevices.getUserMedia({ audio : true, video : true });
const recorder = new MediaRecorder(video);
let isStarted = false;
let promise = new Promise(resolve => recorder.onstart = () => {
isStarted = true;
resolve();
});
// We cover the case of invalid ignored timeSlice value by passing -1 here.
recorder.start(-1);
assert_false(isStarted);
return promise;
}, 'Make sure that MediaRecorder fires onstart on successful start call');
</script>
</body>
</html>