content/media/test/test_mediarecorder_creation_fail.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/test/test_mediarecorder_creation_fail.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test MediaRecorder Record with media.ogg.enabled = false</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +  <script type="text/javascript" src="manifest.js"></script>
    1.11 +</head>
    1.12 +<body>
    1.13 +<pre id="test">
    1.14 +<script class="testbody" type="text/javascript">
    1.15 +
    1.16 +function startTest() {
    1.17 +  // the expect sequence should be
    1.18 +  // 1. onerror
    1.19 +  // 2. ondataavailable
    1.20 +  // 3. onstop
    1.21 +  var callbackStep = 0;
    1.22 +  var stream = new AudioContext().createMediaStreamDestination().stream;
    1.23 +  var mediaRecorder = new MediaRecorder(stream);
    1.24 +
    1.25 +  mediaRecorder.onerror = function (e) {
    1.26 +    is(callbackStep, 0, 'should fired onstop callback');
    1.27 +    is(e.name, 'GenericError', 'error name should be GenericError');
    1.28 +    is(mediaRecorder.mimeType, '', 'mimetype should be empty');
    1.29 +    is(mediaRecorder.state, 'recording', 'state is recording');
    1.30 +    info('onerror callback fired');
    1.31 +    callbackStep = 1;
    1.32 +  };
    1.33 +
    1.34 +  mediaRecorder.onwarning = function () {
    1.35 +    ok(false, 'Unexpected onwarning callback fired');
    1.36 +  };
    1.37 +
    1.38 +  mediaRecorder.onstop = function () {
    1.39 +    info('onstop callback fired');
    1.40 +    is(mediaRecorder.state, 'inactive', 'state should be inactive');
    1.41 +    is(callbackStep, 2, 'should fired onstop callback');
    1.42 +    SimpleTest.finish();
    1.43 +  };
    1.44 +
    1.45 +  // This handler fires every 250ms to generate a blob.
    1.46 +  mediaRecorder.ondataavailable = function (evt) {
    1.47 +    info('ondataavailable callback fired');
    1.48 +    is(callbackStep, 1, 'should fired ondataavailable callback');
    1.49 +    is(evt.data.size, 0, 'data size should be zero');
    1.50 +    ok(evt instanceof BlobEvent,
    1.51 +       'Events fired from ondataavailable should be BlobEvent');
    1.52 +    is(evt.data.type, '', 'encoder start fail, blob miemType should be empty');
    1.53 +    callbackStep = 2;
    1.54 +  };
    1.55 +
    1.56 +  // Start recording
    1.57 +  mediaRecorder.start(250);
    1.58 +  is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
    1.59 +  is(mediaRecorder.stream, stream,
    1.60 +     'Media recorder stream = element stream at the start of recording');
    1.61 +}
    1.62 +
    1.63 +SimpleTest.waitForExplicitFinish();
    1.64 +SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]}, startTest);
    1.65 +
    1.66 +</script>
    1.67 +</pre>
    1.68 +</body>
    1.69 +</html>

mercurial