content/media/test/test_mediarecorder_getencodeddata.html

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Bug 957452 Test GetEncodedData problem on asan build</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 </head>
michael@0 8 <body>
michael@0 9 <pre id="test">
michael@0 10 <script class="testbody" type="text/javascript">
michael@0 11 SimpleTest.waitForExplicitFinish();
michael@0 12 SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]},
michael@0 13 function () {
michael@0 14 var ac = new window.AudioContext();
michael@0 15 var dest = ac.createMediaStreamDestination();
michael@0 16 var stream = dest.stream;
michael@0 17 var onErrorFired = false;
michael@0 18 var expectedMimeType = '';
michael@0 19 var ondataavailableFired = false;
michael@0 20 setTimeout(function() {
michael@0 21 var mediaRecorder = new MediaRecorder(stream);
michael@0 22 mediaRecorder.onstop = function(e) {
michael@0 23 is(e.target.state, 'inactive',
michael@0 24 'Media recorder is inactive after being stopped');
michael@0 25 ok(onErrorFired, 'onStop after onError');
michael@0 26 ok(ondataavailableFired, 'ondataavailableFired');
michael@0 27
michael@0 28 SimpleTest.finish();
michael@0 29 }
michael@0 30 mediaRecorder.ondataavailable = function(evt) {
michael@0 31 ondataavailableFired = true;
michael@0 32 ok(evt instanceof BlobEvent,
michael@0 33 'Events fired from ondataavailable should be BlobEvent');
michael@0 34 is(evt.type, 'dataavailable',
michael@0 35 'Event type should dataavailable');
michael@0 36 is(evt.data.size, 0,
michael@0 37 'Blob data size received is equal to zero');
michael@0 38 is(evt.data.type, expectedMimeType,
michael@0 39 'Blob data received should have type = ' + expectedMimeType);
michael@0 40 is(evt.target.mimeType, expectedMimeType,
michael@0 41 'Mime type in ondataavailable = ' + expectedMimeType);
michael@0 42 }
michael@0 43 mediaRecorder.onerror = function(evt) {
michael@0 44 ok(evt instanceof RecordErrorEvent,
michael@0 45 'Events fired from onerror should be RecordErrorEvent');
michael@0 46 is(evt.type, 'error',
michael@0 47 'Event type should onerror');
michael@0 48 is(evt.name, 'GenericError',
michael@0 49 'Event name is GenericError');
michael@0 50 onErrorFired = true;
michael@0 51 }
michael@0 52 mediaRecorder.start(0);
michael@0 53 is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
michael@0 54 is(mediaRecorder.stream, stream,
michael@0 55 'Media recorder stream = element stream at the start of recording');
michael@0 56 mediaRecorder.requestData();
michael@0 57 mediaRecorder.stop();
michael@0 58 }, 100);
michael@0 59 }
michael@0 60 );
michael@0 61 </script>
michael@0 62 </pre>
michael@0 63 </body>
michael@0 64 </html>

mercurial