Bug 957452 - Test case for capture use-after-free on MediaRecorder::Session::GetEncodedData. r=jsmith
authorRandy Lin <rlin@mozilla.com>
Mon, 10 Feb 2014 16:55:22 +0800
changeset 168137 a21db9070b6012d74b140e7e94a13be873561b87
parent 168136 825f12a34b118b9be2e9e686b8b9948109f9265b
child 168138 93a64959289de32ebc2f2187a0140d7abade7843
push id26197
push userryanvm@gmail.com
push dateTue, 11 Feb 2014 19:57:30 +0000
treeherdermozilla-central@802d87c77e76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsmith
bugs957452
milestone30.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 957452 - Test case for capture use-after-free on MediaRecorder::Session::GetEncodedData. r=jsmith
content/media/test/mochitest.ini
content/media/test/test_mediarecorder_getencodeddata.html
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -253,16 +253,17 @@ support-files =
 [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_getencodeddata.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_getencodeddata.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Bug 957452 Test GetEncodedData problem on asan build</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">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]},
+  function () {
+    var ac = new window.AudioContext();
+    var dest = ac.createMediaStreamDestination();
+    var stream = dest.stream;
+    var onErrorFired = false;
+    var expectedMimeType = '';
+    var ondataavailableFired = false;
+    setTimeout(function() {
+      var mediaRecorder = new MediaRecorder(stream);
+      mediaRecorder.onstop = function(e) {
+        is(e.target.state, 'inactive',
+           'Media recorder is inactive after being stopped');
+        ok(onErrorFired, 'onStop after onError');
+        ok(ondataavailableFired, 'ondataavailableFired');
+
+        SimpleTest.finish();
+      }
+      mediaRecorder.ondataavailable = function(evt) {
+        if (onErrorFired) {
+          ondataavailableFired = true;
+          ok(evt instanceof BlobEvent,
+             'Events fired from ondataavailable should be BlobEvent');
+          is(evt.type, 'dataavailable',
+             'Event type should dataavailable');
+          is(evt.data.size, 0,
+             'Blob data size received is equal to zero');
+          is(evt.data.type, expectedMimeType,
+             'Blob data received should have type = ' + expectedMimeType);
+          is(evt.target.mimeType, expectedMimeType,
+             'Mime type in ondataavailable = ' + expectedMimeType);
+        } else {
+          ok(false, 'should get onError first');
+        }
+      }
+      mediaRecorder.onerror = function(evt) {
+        ok(evt instanceof RecordErrorEvent,
+          'Events fired from onerror should be RecordErrorEvent');
+        is(evt.type, 'error',
+           'Event type should onerror');
+        is(evt.name, 'GenericError',
+           'Event name is GenericError');
+        onErrorFired = true;
+      }
+      mediaRecorder.start(0);
+      is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
+      is(mediaRecorder.stream, stream,
+         'Media recorder stream = element stream at the start of recording');
+      mediaRecorder.requestData();
+      mediaRecorder.stop();
+    }, 100);
+  }
+);
+</script>
+</pre>
+</body>
+</html>