Bug 957841 - Test case for MediaRecorder crash [@ mozilla::dom::MediaRecorder::Session::AfterTracksAdded]. r=jsmith
authorRandy Lin <rlin@mozilla.com>
Wed, 29 Jan 2014 23:09:46 +0800
changeset 182058 82ad4f4311049d455b23278f8e3c75bbdfcd9f92
parent 182057 6440ae81d003cea2430d2c16f30418752c00bdfe
child 182059 5d61348f2589b5d1d98d971bbe1ee99a2af94364
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
bugs957841
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 957841 - Test case for MediaRecorder crash [@ mozilla::dom::MediaRecorder::Session::AfterTracksAdded]. r=jsmith
content/media/test/mochitest.ini
content/media/test/test_mediarecorder_record_startstopstart.html
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -251,16 +251,17 @@ support-files =
 [test_mozHasAudio.html]
 [test_source_media.html]
 [test_autoplay_contentEditable.html]
 [test_decoder_disable.html]
 [test_mediarecorder_record_no_timeslice.html]
 [test_mediarecorder_reload_crash.html]
 [test_mediarecorder_record_immediate_stop.html]
 [test_mediarecorder_record_session.html]
+[test_mediarecorder_record_startstopstart.html]
 [test_mediarecorder_unsupported_src.html]
 [test_playback.html]
 [test_seekLies.html]
 [test_media_sniffer.html]
 [test_streams_srcObject.html]
 [test_reset_src.html]
 [test_streams_autoplay.html]
 [test_streams_element_capture.html]
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_mediarecorder_record_startstopstart.html
@@ -0,0 +1,76 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test MediaRecorder crash on sequence start stop start method</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">
+<div id="content" style="display: none">
+</div>
+<script class="testbody" type="text/javascript">
+
+function startTest() {
+  var ac = new window.AudioContext();
+  var dest = ac.createMediaStreamDestination();
+  var recorder = new MediaRecorder(dest.stream);
+  var stopCount = 0;
+  var dataavailable = 0;
+  // mobile device may produce another format, but not landed.
+  // In audio only case, we should produce opus type.
+  var expectedMimeType = 'audio/ogg';
+  recorder.onstop = function (e) {
+    info('onstop fired');
+    is(recorder.stream, dest.stream,
+       'Media recorder stream = element stream post recording');
+    stopCount++;
+    if (stopCount == 2) {
+      is(2, dataavailable, 'Should has two dataavailable event');
+      SimpleTest.finish();
+    }
+  }
+  recorder.ondataavailable = function (evt) {
+    info('ondataavailable fired');
+    ok(evt instanceof BlobEvent,
+       'Events fired from ondataavailable should be BlobEvent');
+    is(evt.type, 'dataavailable',
+       'Event type should dataavailable');
+    // If script runs slower, it may generate header data in blob from encoder
+    if (evt.data.size > 0) {
+     info('blob size = ' + evt.data.size);
+     is(evt.data.type, expectedMimeType,
+       'Blob data received should have type = ' + expectedMimeType);
+    } else {
+      is(evt.data.type, '',
+         'Blob data received should have empty type');
+    }
+    dataavailable++;
+  }
+  recorder.onerror = function (e) {
+    ok(false, 'it should execute normally without exception');
+  }
+  recorder.onwarning = function() {
+    ok(false, 'onwarning unexpectedly fired');
+  };
+
+  recorder.start(2000);
+  is(recorder.state, 'recording', 'Media recorder should be recording');
+  recorder.stop();
+  is(recorder.state, 'inactive', 'check recording status is inactive');
+  recorder.start(10000); // This bug would crash on this line without this fix.
+  is(recorder.state, 'recording', 'check recording status is recording');
+  // Simulate delay stop, only delay stop no no stop can trigger crash.
+  setTimeout(function() {
+    recorder.stop();
+    is(recorder.state, 'inactive','check recording status is recording');
+  }, 1000);
+}
+
+startTest();
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>
+