content/media/test/test_mediarecorder_creation_fail.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test MediaRecorder Record with media.ogg.enabled = false</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 7 <script type="text/javascript" src="manifest.js"></script>
michael@0 8 </head>
michael@0 9 <body>
michael@0 10 <pre id="test">
michael@0 11 <script class="testbody" type="text/javascript">
michael@0 12
michael@0 13 function startTest() {
michael@0 14 // the expect sequence should be
michael@0 15 // 1. onerror
michael@0 16 // 2. ondataavailable
michael@0 17 // 3. onstop
michael@0 18 var callbackStep = 0;
michael@0 19 var stream = new AudioContext().createMediaStreamDestination().stream;
michael@0 20 var mediaRecorder = new MediaRecorder(stream);
michael@0 21
michael@0 22 mediaRecorder.onerror = function (e) {
michael@0 23 is(callbackStep, 0, 'should fired onstop callback');
michael@0 24 is(e.name, 'GenericError', 'error name should be GenericError');
michael@0 25 is(mediaRecorder.mimeType, '', 'mimetype should be empty');
michael@0 26 is(mediaRecorder.state, 'recording', 'state is recording');
michael@0 27 info('onerror callback fired');
michael@0 28 callbackStep = 1;
michael@0 29 };
michael@0 30
michael@0 31 mediaRecorder.onwarning = function () {
michael@0 32 ok(false, 'Unexpected onwarning callback fired');
michael@0 33 };
michael@0 34
michael@0 35 mediaRecorder.onstop = function () {
michael@0 36 info('onstop callback fired');
michael@0 37 is(mediaRecorder.state, 'inactive', 'state should be inactive');
michael@0 38 is(callbackStep, 2, 'should fired onstop callback');
michael@0 39 SimpleTest.finish();
michael@0 40 };
michael@0 41
michael@0 42 // This handler fires every 250ms to generate a blob.
michael@0 43 mediaRecorder.ondataavailable = function (evt) {
michael@0 44 info('ondataavailable callback fired');
michael@0 45 is(callbackStep, 1, 'should fired ondataavailable callback');
michael@0 46 is(evt.data.size, 0, 'data size should be zero');
michael@0 47 ok(evt instanceof BlobEvent,
michael@0 48 'Events fired from ondataavailable should be BlobEvent');
michael@0 49 is(evt.data.type, '', 'encoder start fail, blob miemType should be empty');
michael@0 50 callbackStep = 2;
michael@0 51 };
michael@0 52
michael@0 53 // Start recording
michael@0 54 mediaRecorder.start(250);
michael@0 55 is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
michael@0 56 is(mediaRecorder.stream, stream,
michael@0 57 'Media recorder stream = element stream at the start of recording');
michael@0 58 }
michael@0 59
michael@0 60 SimpleTest.waitForExplicitFinish();
michael@0 61 SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]}, startTest);
michael@0 62
michael@0 63 </script>
michael@0 64 </pre>
michael@0 65 </body>
michael@0 66 </html>

mercurial