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 70 71 72 73 74 75 76 77 78
<!DOCTYPE HTML>
<html>
<head>
  <title>Bug 957452 Test GetEncodedData problem on asan build</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]},
  function () {
    var ac = new window.AudioContext();
    var dest = ac.createMediaStreamDestination();
    var stream = dest.stream;
    var onErrorFired = false;
    var expectedMimeType = '';
    var ondataavailableFired = false;
    setTimeout(function() {
      var mediaRecorder = new MediaRecorder(stream);
      mediaRecorder.onstop = function(e) {
        is(e.target.state, 'inactive',
           'Media recorder is inactive after being stopped');
        ok(onErrorFired, 'onStop after onError');
        ok(ondataavailableFired, 'ondataavailableFired');

        //Apparently, as soon as the document is unloading, mediaRecorder.ondataavailable
        //fires again, so set it to null to avoid failures
        mediaRecorder.ondataavailable = null;
        SimpleTest.finish();
      };
      mediaRecorder.ondataavailable = function(evt) {
        ondataavailableFired = true;
        ok(evt instanceof BlobEvent,
           'Events fired from ondataavailable should be BlobEvent');
        is(evt.type, 'dataavailable',
           'Event type should dataavailable');
        is(evt.data.size, 0,
           'Blob data size received is equal to zero');
        is(evt.data.type, expectedMimeType,
           'Blob data received should have type = ' + expectedMimeType);
        is(evt.target.mimeType, expectedMimeType,
           'Mime type in ondataavailable = ' + expectedMimeType);
      };
      mediaRecorder.onerror = function(evt) {
        is(evt.target.state, 'inactive',
           'Media recorder is inactive after firing error');
        ok(evt instanceof MediaRecorderErrorEvent,
          'Events fired from onerror should be MediaRecorderErrorEvent');
        is(evt.type, 'error',
           'Event type is error');
        ok(evt.error instanceof DOMException,
          'Events fired from onerror should have a DOMException in their error member');
        is(evt.error.name, 'UnknownError', 'Error name should be UnknownError.');
        is(evt.error.message, 'The operation failed for an unknown transient reason');
        ok(evt.error.stack.includes('test_mediarecorder_getencodeddata.html'),
          'Events fired from onerror should include an error with a stack trace indicating ' +
          'an error in this test');
        try {
          mediaRecorder.requestData();
          ok(false, 'requestdata should fire an exception if called on an inactive recorder');
        } catch (e) {
          ok(e instanceof DOMException, 'requestdata should fire an exception ' +
            'if called on an inactive recorder');
          is(e.name, 'InvalidStateError', 'Exception name should be InvalidStateError');
        }
        onErrorFired = true;
      };
      mediaRecorder.start(0);
    }, 100);
  }
);
</script>
</pre>
</body>
</html>