Bug 1514016 - Rework MediaRecorder-stop tests to use async-await. r=jib
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 14 Jan 2019 18:32:55 +0000
changeset 510905 8183cba74edddbea9c6629c1667cbafeb7335c41
parent 510904 3556aa3e0f5855608fa73be0d40151350ba16808
child 510906 b7b6a2978011a99cb8b65deb73b293a52fd13874
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1514016
milestone66.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 1514016 - Rework MediaRecorder-stop tests to use async-await. r=jib Depends on D14891 Differential Revision: https://phabricator.services.mozilla.com/D14892
testing/web-platform/meta/mediacapture-record/MediaRecorder-stop.html.ini
testing/web-platform/tests/mediacapture-record/MediaRecorder-stop.html
--- a/testing/web-platform/meta/mediacapture-record/MediaRecorder-stop.html.ini
+++ b/testing/web-platform/meta/mediacapture-record/MediaRecorder-stop.html.ini
@@ -1,8 +1,8 @@
 [MediaRecorder-stop.html]
   expected: TIMEOUT
   [MediaRecorder will stop recording and fire a stop event when stop() is called]
-    expected: FAIL
+    expected: NOTRUN
 
   [MediaRecorder will stop recording and fire a stop event when all tracks are ended]
     expected: TIMEOUT
 
--- a/testing/web-platform/tests/mediacapture-record/MediaRecorder-stop.html
+++ b/testing/web-platform/tests/mediacapture-record/MediaRecorder-stop.html
@@ -11,40 +11,41 @@
 </canvas>
 <script>
     function createVideoStream() {
         let canvas = document.getElementById("canvas");
         canvas.getContext('2d');
         return canvas.captureStream();
     }
 
-    async_test(t => {
+    promise_test(async t => {
         let video = createVideoStream();
         let recorder = new MediaRecorder(video);
-        recorder.onstop = t.step_func(errorEvent => {
-            assert_equals(errorEvent.type, 'stop', 'the error type should be stop');
-            assert_true(errorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
-            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped when all tracks are ended");
-            t.done();
-        });
         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");
     }, "MediaRecorder will stop recording and fire a stop event when all tracks are ended");
 
-    async_test(t => {
+    promise_test(async t => {
         let video = createVideoStream();
         let recorder = new MediaRecorder(video);
-        recorder.onstop = t.step_func(errorEvent => {
-            assert_equals(errorEvent.type, 'stop', 'the error type should be stop');
-            assert_true(errorEvent.isTrusted, 'isTrusted should be true when the event is created by C++');
-            assert_equals(recorder.state, "inactive", "MediaRecorder has been stopped when stop() is called");
-            t.done();
-        });
         recorder.start();
         assert_equals(recorder.state, "recording", "MediaRecorder has been started successfully");
+
         recorder.stop();
-        assert_equals(recorder.state, "recording", "State should remain the same until stop event is fired");
+        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");
     }, "MediaRecorder will stop recording and fire a stop event when stop() is called");
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>