Bug 1041362 - Modify testcases because during the oncanplaythrough callback function, the element might not ended but the mediastream is ended. r=roc, a=test-only
authorBenjamin Chen <bechen@mozilla.com>
Wed, 15 Oct 2014 17:34:30 +0800
changeset 225717 c3fa7201e034
parent 225716 915073abfd8b
child 225718 9be2b1620955
push id3988
push userryanvm@gmail.com
push date2014-10-17 01:37 +0000
treeherdermozilla-beta@c3fa7201e034 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, test-only
bugs1041362
milestone34.0
Bug 1041362 - Modify testcases because during the oncanplaythrough callback function, the element might not ended but the mediastream is ended. r=roc, a=test-only
content/media/test/test_mediarecorder_record_immediate_stop.html
content/media/test/test_mediarecorder_record_no_timeslice.html
content/media/test/test_mediarecorder_record_session.html
--- a/content/media/test/test_mediarecorder_record_immediate_stop.html
+++ b/content/media/test/test_mediarecorder_record_immediate_stop.html
@@ -92,32 +92,31 @@ function startTest(test, token) {
         ok(false, 'ondataavailable unexpectedly fired later than onstop');
         manager.finished(token);
       }
     }
   };
 
   // This handler completes a start and stop of recording and verifies
   // respective media recorder state.
-  var canPlayThrough = function() {
-    element.removeEventListener('canplaythrough', canPlayThrough, false);
-
+  element.onloadedmetadata = function () {
+    element.onloadedmetadata = null;
+    element.play();
     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');
 
     mediaRecorder.stop();
     is(mediaRecorder.state, 'inactive',
        'Media recorder is inactive after being stopped');
     is(mediaRecorder.stream, element.stream,
        'Media recorder stream = element stream post recording');
   };
 
-  element.addEventListener('canplaythrough', canPlayThrough, false);
-  element.play();
+  element.preload = "metadata";
 }
 
 manager.runTests(gMediaRecorderTests, startTest);
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_mediarecorder_record_no_timeslice.html
+++ b/content/media/test/test_mediarecorder_record_no_timeslice.html
@@ -79,33 +79,27 @@ function startTest(test, token) {
       // onstop should not have fired before ondataavailable
       if (onStopFired) {
         ok(false, 'ondataavailable unexpectedly fired later than onstop');
         manager.finished(token);
       }
     }
   };
 
-  element.oncanplaythrough = function () {
-    element.oncanplaythrough = null;
-    // If content has ended, skip the test
-    if (element.ended) {
-      ok(true, 'ended fired before canplaythrough, skipping test');
-      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');
-      // Recording will automatically stop when the stream ends.
-    }
+  element.preload = "metadata";
+
+  element.onloadedmetadata = function () {
+    element.onloadedmetadata = null;
+    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');
+
+    element.play();
   }
-
-  element.play();
 }
 
 manager.runTests(gMediaRecorderTests, startTest);
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/test/test_mediarecorder_record_session.html
+++ b/content/media/test/test_mediarecorder_record_session.html
@@ -49,25 +49,27 @@ function startTest(test, token) {
   mediaRecorder.onerror = function(err) {
     ok(false, 'Unexpected error fired with:' + err);
   }
 
   mediaRecorder.onwarning = function() {
     ok(false, 'Unexpected warning fired');
   }
 
-  element.oncanplaythrough = function () {
-    element.oncanplaythrough = null;
+  element.preload = "metadata";
+
+  element.onloadedmetadata = function () {
+    element.onloadedmetadata = null;
+    element.play();
     for (var i = 0; i < mExpectStopCount; i++) {
       mediaRecorder.start(1000);
       mediaRecorder.stop();
     }
   }
 
-  element.play();
 }
 
 manager.runTests(gMediaRecorderTests, startTest);
 
 </script>
 </pre>
 </body>
 </html>