summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_mediarecorder_record_startstopstart.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/test/test_mediarecorder_record_startstopstart.html')
-rw-r--r--dom/media/test/test_mediarecorder_record_startstopstart.html75
1 files changed, 75 insertions, 0 deletions
diff --git a/dom/media/test/test_mediarecorder_record_startstopstart.html b/dom/media/test/test_mediarecorder_record_startstopstart.html
new file mode 100644
index 0000000000..b4cc62c709
--- /dev/null
+++ b/dom/media/test/test_mediarecorder_record_startstopstart.html
@@ -0,0 +1,75 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test MediaRecorder crash on sequence start stop start method</title>
+ <script 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;
+ var expectedMimeType = 'audio/ogg; codecs=opus';
+ recorder.onstop = function (e) {
+ info('onstop fired');
+ is(recorder.stream, dest.stream,
+ 'Media recorder stream = element stream post recording');
+ stopCount++;
+ if (stopCount == 2) {
+ if (dataavailable >= 2) {
+ SimpleTest.finish();
+ } else {
+ ok(false, 'Should have at least two dataavailable events');
+ }
+ }
+ }
+ 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);
+ }
+ 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);
+}
+
+SimpleTest.requestFlakyTimeout("untriaged");
+startTest();
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>
+