DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (409f3966645a)

VCS Links

Line Code
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
<!DOCTYPE HTML>
<html>
<head>
  <title>Test MediaRecorder Record with media.ogg.enabled = false</title>
  <script type="text/javascript" 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>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">

function startTest() {
  // the expect sequence should be
  // 1. onerror
  // 2. ondataavailable
  // 3. onstop
  var callbackStep = 0;
  var stream = new AudioContext().createMediaStreamDestination().stream;
  var mediaRecorder = new MediaRecorder(stream);

  mediaRecorder.onerror = function (e) {
    is(callbackStep, 0, 'should fired onstop callback');
    is(e.error.name, 'UnknownError', 'error name should be UnknownError');
    ok(e.error.stack.includes('test_mediarecorder_creation_fail.html'),
      'Events fired from onerror should include an error with a stack trace indicating ' +
      'an error in this test');
    is(mediaRecorder.mimeType, '', 'mimetype should be empty');
    is(mediaRecorder.state, 'inactive', 'state is inactive');
    info('onerror callback fired');
    callbackStep = 1;
  };

  mediaRecorder.onwarning = function () {
    ok(false, 'Unexpected onwarning callback fired');
  };

  mediaRecorder.onstop = function () {
    info('onstop callback fired');
    is(mediaRecorder.state, 'inactive', 'state should be inactive');
    is(callbackStep, 2, 'should fired onstop callback');
    SimpleTest.finish();
  };

  // This handler fires every 250ms to generate a blob.
  mediaRecorder.ondataavailable = function (evt) {
    info('ondataavailable callback fired');
    is(callbackStep, 1, 'should fired ondataavailable callback');
    is(evt.data.size, 0, 'data size should be zero');
    ok(evt instanceof BlobEvent,
       'Events fired from ondataavailable should be BlobEvent');
    is(evt.data.type, '', 'encoder start fail, blob miemType should be empty');
    callbackStep = 2;
  };

  // Start recording
  mediaRecorder.start(250);
  is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
  is(mediaRecorder.stream, stream,
     'Media recorder stream = element stream at the start of recording');
}

SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]}, startTest);

</script>
</pre>
</body>
</html>