Bug 1395022 - Add test to check only one start event is fired by MediaRecorder when erroring. r=pehrsons
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 04 Sep 2017 10:10:32 +1200
changeset 428556 dfc055f4d93e2875e587927622769aa7e6ccdac5
parent 428555 35a2a0327e51a5952f0a06ebb2cd1ec194269a41
child 428557 fc8ba9723756b65083bcd03817eb6e984af956af
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1395022
milestone57.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 1395022 - Add test to check only one start event is fired by MediaRecorder when erroring. r=pehrsons MozReview-Commit-ID: 1JJY0eQMSDn
dom/media/test/mochitest.ini
dom/media/test/test_mediarecorder_fires_start_event_once_when_erroring.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -820,16 +820,19 @@ tags=msg
 skip-if = toolkit == 'android' # bug 1297432, android(bug 1232305)
 tags=msg
 [test_mediarecorder_creation.html]
 skip-if = android_version == '17' # android(bug 1232305)
 tags=msg capturestream
 [test_mediarecorder_creation_fail.html]
 skip-if = android_version == '17' # android(bug 1232305)
 tags=msg
+[test_mediarecorder_fires_start_event_once_when_erroring.html]
+skip-if = android_version == '17' # android(bug 1232305)
+tags=msg
 [test_mediarecorder_getencodeddata.html]
 skip-if = android_version == '17' # android(bug 1232305)
 tags=msg
 [test_mediarecorder_pause_resume_video.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
 [test_mediarecorder_playback_can_repeat.html]
 skip-if = android_version == '17' || android_version == '22' # android(bug 1232305, bug 1372457)
 tags=msg
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_mediarecorder_fires_start_event_once_when_erroring.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Bug 1395022 - MediaRecorder fires start event when erroring.</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1395022">Mozilla Bug 1395022</a>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+function startTest() {
+  let audioContext = new AudioContext();
+  let destination1 = audioContext.createMediaStreamDestination();
+  let oscilator = audioContext.createOscillator();
+  oscilator.connect(destination1);
+  oscilator.start();
+
+  let destination2 = audioContext.createMediaStreamDestination();
+
+  let rec = new MediaRecorder(destination1.stream);
+
+  let numStartEvents = 0;
+
+  rec.onstart = () => {
+    numStartEvents += 1;
+    is(numStartEvents, 1, "One start event should be fired by the recorder");
+    // Trigger an error in the recorder
+    destination1.stream.addTrack(destination2.stream.getTracks()[0]);
+  };
+
+  rec.onerror = () => {
+    is(numStartEvents, 1, "One start event should have been fired by the recorder");
+    SimpleTest.finish();
+  };
+
+  rec.start();
+}
+
+SimpleTest.waitForExplicitFinish();
+startTest();
+
+</script>
+</head>
+</html>
\ No newline at end of file