blob: e1913cd0f5df92805cdba68c07bc2e9c95197b7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title>Bug 1378826 : Removing last video track from recorder stream crashes.</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script type="text/javascript">
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function boom() {
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext('2d');
ctx.fillRect(10, 10, 100, 100);
let stream = canvas.captureStream();
let rec = new MediaRecorder(stream);
// At the time of fixing this bug onstop would fire, but this may change in
// future. As such defensively listen for onerror too to prevent this test
// timing out.
let stoppedPromise = new Promise(y => (rec.onstop = y,
rec.onerror = e => y));
rec.onstart = () => {
// Remove the video track from the stream we're recording
stream.removeTrack(stream.getTracks()[0]);
// Recorder should stop or error in response to the above
return stoppedPromise
.then(() => {
// Little wait to help get bad writes if they're going to happen
wait(100)
.then(() => {
// Didn't crash, finish
document.documentElement.removeAttribute("class");
});
});
};
rec.start();
}
window.onload = boom;
</script>
</body>
</html>
|