Bug 926684 - Test Case for MediaRecorder: Assertion failure: mEncoder (CreateEncoder failed). r=jsmith
authorRandy Lin <rlin@mozilla.com>
Thu, 09 Jan 2014 10:52:29 +0800
changeset 178952 528f6a845df674233b7b81ca60a74ec7c0b28a70
parent 178951 b7b3afa4c103fe182456043bb6457a9c669698ea
child 178953 f5e49d0f2e860181183e43c32df8b3cf89ea2686
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsmith
bugs926684
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 926684 - Test Case for MediaRecorder: Assertion failure: mEncoder (CreateEncoder failed). r=jsmith
content/media/test/mochitest.ini
content/media/test/test_mediarecorder_creation_fail.html
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -234,16 +234,17 @@ support-files =
 [test_source.html]
 [test_source_write.html]
 [test_source_null.html]
 [test_standalone.html]
 [test_volume.html]
 [test_video_to_canvas.html]
 [test_audiowrite.html]
 [test_mediarecorder_creation.html]
+[test_mediarecorder_creation_fail.html]
 [test_mediarecorder_avoid_recursion.html]
 [test_mediarecorder_record_timeslice.html]
 [test_mediarecorder_record_audiocontext.html]
 [test_mediarecorder_record_4ch_audiocontext.html]
 [test_mediarecorder_record_stopms.html]
 [test_mediarecorder_record_nosrc.html]
 [test_mozHasAudio.html]
 [test_source_media.html]
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_mediarecorder_creation_fail.html
@@ -0,0 +1,74 @@
+<!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() {
+  var element = document.createElement('audio');
+
+  element.src = 'detodos.opus';
+  element.stream = element.mozCaptureStream();
+  // the expect sequence should be
+  // 1. onerror
+  // 2. ondataavailable
+  // 3. onstop
+  var callbackStep = 0;
+  var mediaRecorder = new MediaRecorder(element.stream);
+
+  mediaRecorder.onerror = function (e) {
+    is(callbackStep, 0, 'should fired onstop callback');
+    is(e.name, 'GenericError', 'error name should be GenericError');
+    is(mediaRecorder.mimeType, '', 'mimetype should be empty');
+    is(mediaRecorder.state, 'recording', 'state is recording');
+    info('onerror callback fired');
+    SpecialPowers.setBoolPref('media.ogg.enabled', true);
+    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 once canplaythrough fires
+  element.oncanplaythrough = function() {
+    SpecialPowers.setBoolPref("media.ogg.enabled", false);
+    mediaRecorder.start(250);
+    is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
+    is(mediaRecorder.stream, element.stream,
+       'Media recorder stream = element stream at the start of recording');
+  };
+
+  element.play();
+}
+
+startTest();
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>