Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 6baeb70

Browse files
Pehrsonsmoz-wptsync-bot
authored andcommitted
Fix MediaRecorder-pause-resume.html to avoid start() ambiguities.
The spec allows for MediaRecorder.start() to hold the "start" event until it has collected some actual data. This means "pause" and "resume" events can occur before "start", on the contrary of this testcase. This patch avoids this ambiguity by: 1) Drawing a frame to the canvas so that the track contains some real data. 2) Wait for "start" before pause()ing, to ensure "start" comes first. Note that without 1), 2) could wait indefinitely, resulting in a timeout. Differential Revision: https://phabricator.services.mozilla.com/D46470 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1582407 gecko-commit: d7ab956c296257c99630aa0d4e91d41434c55137 gecko-integration-branch: autoland gecko-reviewers: jib
1 parent 238502b commit 6baeb70

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mediacapture-record/MediaRecorder-pause-resume.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
</canvas>
1212
<script>
1313
function createVideoStream() {
14-
let canvas = document.getElementById("canvas");
15-
canvas.getContext('2d');
14+
const canvas = document.getElementById("canvas");
15+
const ctx = canvas.getContext('2d');
16+
ctx.fillStyle = 'green';
17+
ctx.fillRect(0, 0, canvas.width, canvas.height);
1618
return canvas.captureStream();
1719
}
1820

@@ -32,6 +34,7 @@
3234

3335
recorder.start();
3436
assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
37+
await new Promise(r => recorder.onstart = r);
3538

3639
recorder.pause();
3740
assert_equals(recorder.state, "paused", "MediaRecorder should be paused immediately following pause()");

0 commit comments

Comments
 (0)