Bug 1514016 - Check that all events are fired as expected for MediaRecorder-stop.html. r=jib, a=RyanVM
authorAndreas Pehrson <apehrson@mozilla.com>
Mon, 14 Jan 2019 18:32:58 +0000
changeset 509512 944e9c24989d7a57fd5317dd17f9f4e1c546cca4
parent 509511 c8acac1e463c896b758e5c229bf4b5ac2fc49b01
child 509513 23bab54bf023f373004d35f0417ffe814193fe71
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, RyanVM
bugs1514016
milestone65.0
Bug 1514016 - Check that all events are fired as expected for MediaRecorder-stop.html. r=jib, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D15912
testing/web-platform/tests/mediacapture-record/MediaRecorder-stop.html
--- a/testing/web-platform/tests/mediacapture-record/MediaRecorder-stop.html
+++ b/testing/web-platform/tests/mediacapture-record/MediaRecorder-stop.html
@@ -11,53 +11,71 @@
 </canvas>
 <script>
     function createVideoStream() {
         let canvas = document.getElementById("canvas");
         canvas.getContext('2d');
         return canvas.captureStream();
     }
 
+    function recordEvents(target, events) {
+        let arr = [];
+        for (let ev of events) {
+            target.addEventListener(ev, _ => arr.push(ev));
+        }
+        return arr;
+    }
+
     promise_test(async t => {
         let video = createVideoStream();
         let recorder = new MediaRecorder(video);
+        let events = recordEvents(recorder,
+            ["start", "stop", "dataavailable", "pause", "resume", "error"]);
         assert_equals(video.getVideoTracks().length, 1, "video mediastream starts with one track");
         recorder.start();
         assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
 
         video.getVideoTracks()[0].stop();
         assert_equals(recorder.state, "recording", "MediaRecorder state should be recording immediately following last track ending");
         let event = await new Promise(r => recorder.onstop = r);
 
         assert_equals(event.type, "stop", "the event type should be stop");
         assert_true(event.isTrusted, "isTrusted should be true when the event is created by C++");
         assert_equals(recorder.state, "inactive", "MediaRecorder is inactive after stop event");
 
+        assert_array_equals(events, ["start", "dataavailable", "stop"],
+            "Should have gotten expected events");
+
         recorder.stop();
         await Promise.race([
             new Promise((_, reject) => recorder.onstop =
                 _ => reject(new Error("stop() is idempotent"))),
             new Promise(r => t.step_timeout(r, 0))
         ]);
     }, "MediaRecorder will stop recording and fire a stop event when all tracks are ended");
 
     promise_test(async t => {
         let video = createVideoStream();
         let recorder = new MediaRecorder(video);
+        let events = recordEvents(recorder,
+            ["start", "stop", "dataavailable", "pause", "resume", "error"]);
         recorder.start();
         assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
 
         recorder.stop();
         assert_equals(recorder.state, "inactive", "MediaRecorder state should be inactive immediately following stop() call");
 
         let event = await new Promise (r => recorder.onstop = r);
         assert_equals(event.type, "stop", "the event type should be stop");
         assert_true(event.isTrusted, "isTrusted should be true when the event is created by C++");
         assert_equals(recorder.state, "inactive", "MediaRecorder is inactive after stop event");
 
+        assert_array_equals(events, ["start", "dataavailable", "stop"],
+            "Should have gotten expected events");
+
         recorder.stop();
         await Promise.race([
             new Promise((_, reject) => recorder.onstop =
                 _ => reject(new Error("stop() is idempotent"))),
             new Promise(r => t.step_timeout(r, 0))
         ]);
     }, "MediaRecorder will stop recording and fire a stop event when stop() is called");
 </script>