Bug 943461. Part 6: Fix test to handle automatic stop of MediaRecorder. r=rlin
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 06 Dec 2013 09:59:00 +1300
changeset 162323 7590e388abaffc8b125301b5141a938bb21116b5
parent 162322 08e5578eded873ca3a4ff49abac1984fa4f377c1
child 162324 249b7a7cec009fbb2c2c14bf1b76af5f86416520
push idunknown
push userunknown
push dateunknown
reviewersrlin
bugs943461
milestone29.0a1
Bug 943461. Part 6: Fix test to handle automatic stop of MediaRecorder. r=rlin
content/media/test/test_mediarecorder_record_no_timeslice.html
--- a/content/media/test/test_mediarecorder_record_no_timeslice.html
+++ b/content/media/test/test_mediarecorder_record_no_timeslice.html
@@ -19,17 +19,17 @@ function startTest(test, token) {
   var element = document.createElement('audio');
   var expectedMimeType = test.type.substring(0, test.type.indexOf(';'));
 
   element.token = token;
   manager.started(token);
 
   element.src = test.name;
   element.test = test;
-  element.stream = element.mozCaptureStream();
+  element.stream = element.mozCaptureStreamUntilEnded();
 
   var mediaRecorder = new MediaRecorder(element.stream);
   var onStopFired = false;
   var onDataAvailableFired = false;
 
   mediaRecorder.onerror = function () {
     ok(false, 'Unexpected onerror callback fired');
   };
@@ -42,16 +42,17 @@ function startTest(test, token) {
   mediaRecorder.onstop = function () {
     if (onStopFired) {
       ok(false, 'onstop unexpectedly fired more than once');
     } else {
       onStopFired = true;
 
       // ondataavailable should always fire before onstop
       if (onDataAvailableFired) {
+        ok(true, 'onstop fired after ondataavailable');
         manager.finished(token);
       } else {
         ok(false, 'onstop fired without an ondataavailable event first');
       }
     }
   };
 
   // This handler verifies that only a single ondataavailable event handler
@@ -90,25 +91,17 @@ function startTest(test, token) {
       manager.finished(token);
     } else {
       // If content hasn't ended, start recording
       mediaRecorder.start();
       is(mediaRecorder.state, 'recording',
          'Media recorder should be recording');
       is(mediaRecorder.stream, element.stream,
          'Media recorder stream = element stream at the start of recording');
-
-      // When ended fires, stop recording
-      element.onended = function () {
-        mediaRecorder.stop();
-        is(mediaRecorder.state, 'inactive',
-           'Media recorder is inactive afer being stopped');
-        is(mediaRecorder.stream, element.stream,
-           'Media recorder stream = element stream post recording');
-      }
+      // Recording will automatically stop when the stream ends.
     }
   }
 
   element.play();
 }
 
 manager.runTests(gMediaRecorderTests, startTest);
 </script>