Source code

Revision control

Other Tools

Test Info: Warnings

  • This test gets skipped with pattern: (os == "win" && processor == "aarch64")
<title>Test MediaRecorder Record gUM video with Timeslice</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="gUM_support.js"></script>
<pre id="test">
<div id="content" style="display: none">
<script class="testbody" type="text/javascript">
async function startTest() {
try {
await setupGetUserMediaTestPrefs();
let stream = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
let dataAvailableCount = 0;
let onDataAvailableFirst = false;
const expectedMimeType = 'video/webm; codecs="vp8, opus"';
let mediaRecorder = new MediaRecorder(stream);
is(, stream,
'Media recorder stream = element stream at the start of recording');
mediaRecorder.onwarning = function() {
ok(false, 'onwarning unexpectedly fired');
mediaRecorder.onerror = function() {
ok(false, 'onerror unexpectedly fired');
mediaRecorder.onstop = function() {
ok(false, 'Unexpected onstop callback fired');
mediaRecorder.onstart = function() {
is(mediaRecorder.mimeType, expectedMimeType, 'Expected mime type');
mediaRecorder.ondataavailable = function (evt) {
info('ondataavailable fired');
ok(evt instanceof BlobEvent,
'Events fired from ondataavailable should be BlobEvent');
is(evt.type, 'dataavailable',
'Event type should dataavailable');
ok( >= 0,
'Blob data size ' + + ' received is greater than or equal to zero');
is(, expectedMimeType, 'Expected blob mime type');
// We'll stop recording upon the 1st blob being received
if (dataAvailableCount === 1) {
mediaRecorder.onstop = function (event) {
info('onstop fired');
if (!onDataAvailableFirst) {
ok(false, 'onstop unexpectedly fired before ondataavailable');
ok(true, 'onstop fired successfully');
is(mediaRecorder.state, 'inactive',
'check recording status is inactive');
is(mediaRecorder.state, 'inactive',
'Media recorder is inactive after being stopped');
} else if (dataAvailableCount === 2) {
// Ensure we've received at least two ondataavailable events before
// onstop
onDataAvailableFirst = true;
is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
is(mediaRecorder.mimeType, '', 'Expected mime type');
} catch (err) {
ok(false, 'Unexpected error fired with: ' + err);