Source code

Revision control

Other Tools

Test Info: Warnings

  • This test gets skipped with pattern: (os == "win" && processor == "aarch64")
<title>Bug 951008 Test MediaRecorder Record has start event</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
function startTest(test, token) {
var element = document.createElement('audio');
var hasonstart = false;
var hasondataavailable = false;
var mMediaRecorder;
element.token = token;
element.src =;
element.test = test; = element.mozCaptureStream();
mMediaRecorder = new MediaRecorder(;
is(mMediaRecorder.mimeType, '', 'Expected MediaRecorder mimetype');
mMediaRecorder.onwarning = function() {
ok(false, 'onwarning unexpectedly fired');
mMediaRecorder.onerror = function() {
ok(false, 'onerror unexpectedly fired');
mMediaRecorder.onstart = function() {
info('onstart fired successfully');
hasonstart = true;
is(mMediaRecorder.mimeType, 'audio/ogg; codecs=opus',
"MediaRecorder mimetype as expected");
mMediaRecorder.onstop = function() {
info('onstop fired successfully');
ok(hasondataavailable, "should have ondataavailable before onstop");
is(mMediaRecorder.state, 'inactive', 'check recording status is inactive');
mMediaRecorder.ondataavailable = function (e) {
info('ondataavailable fired successfully');
if (mMediaRecorder.state == 'recording') {
hasondataavailable = true;
ok(hasonstart, "should have had start event first");
is(, mMediaRecorder.mimeType,
"blob's mimeType matches the recorder's");
// Start recording once metadata are parsed.
element.onloadedmetadata = function() {
element.oncanplaythrough = null;
is(mMediaRecorder.state, 'recording', 'Media recorder should be recording');
'Media recorder stream = element stream at the start of recording');
manager.runTests(gMediaRecorderTests, startTest);