Bug 969289 - Add new test_mediarecorder_record_gum_video_timeslice.html test case. r=jsmith
authorBenjamin Chen <bechen@mozilla.com>
Tue, 18 Feb 2014 11:11:18 +0800
changeset 171881 ae8c9202a6ff35760d3577470a566ae9a61ab2a4
parent 171880 74da898d756849acf57c63964e9b46f61a209c21
child 171882 bb92cb22ffb35c69d16f2d836612167df4f851c6
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjsmith
bugs969289
milestone30.0a1
Bug 969289 - Add new test_mediarecorder_record_gum_video_timeslice.html test case. r=jsmith
content/media/test/mochitest.ini
content/media/test/test_mediarecorder_record_gum_video_timeslice.html
testing/mochitest/android.json
testing/mochitest/androidx86.json
testing/mochitest/b2g-debug.json
testing/mochitest/b2g-desktop.json
testing/mochitest/b2g.json
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -382,16 +382,17 @@ support-files =
 [test_decoder_disable.html]
 [test_mediarecorder_record_no_timeslice.html]
 [test_mediarecorder_reload_crash.html]
 [test_mediarecorder_record_immediate_stop.html]
 [test_mediarecorder_record_session.html]
 [test_mediarecorder_record_startstopstart.html]
 [test_mediarecorder_getencodeddata.html]
 [test_mediarecorder_unsupported_src.html]
+[test_mediarecorder_record_gum_video_timeslice.html]
 [test_playback.html]
 [test_seekLies.html]
 [test_media_sniffer.html]
 [test_streams_srcObject.html]
 [test_reset_src.html]
 [test_streams_autoplay.html]
 [test_streams_element_capture.html]
 [test_streams_element_capture_reset.html]
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_mediarecorder_record_gum_video_timeslice.html
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test MediaRecorder Record gUM video with Timeslice</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<div id="content" style="display: none">
+</div>
+<script class="testbody" type="text/javascript">
+
+function startTest() {
+  navigator.mozGetUserMedia({audio: true, video: true, fake: true}, function(stream) {
+    var dataAvailableCount = 0;
+    var onDataAvailableFirst = false;
+
+    mediaRecorder = new MediaRecorder(stream);
+    is(mediaRecorder.stream, stream,
+       'Media recorder stream = element stream at the start of recording');
+    mediaRecorder.onwarning = function() {
+      ok(false, 'onwarning unexpectedly fired');
+    };
+
+    mediaRecorder.onerror = function() {
+      ok(false, 'onerror unexpectedly fired');
+    };
+
+    mediaRecorder.onstop = function() {
+      ok(false, 'Unexpected onstop callback fired');
+    };
+
+    mediaRecorder.ondataavailable = function (evt) {
+      info('ondataavailable fired');
+      dataAvailableCount++;
+
+      ok(evt instanceof BlobEvent,
+         'Events fired from ondataavailable should be BlobEvent');
+      is(evt.type, 'dataavailable',
+         'Event type should dataavailable');
+      ok(evt.data.size >= 0,
+         'Blob data size received is greater than or equal to zero');
+
+      is(evt.data.type, 'video/webm',
+         'Blob data received should have type = ' + 'video/webm');
+      is(mediaRecorder.mimeType, 'video/webm',
+         'Mime type in ondataavailable = ' + mediaRecorder.mimeType);
+
+      // We'll stop recording upon the 1st blob being received
+      if (dataAvailableCount === 1) {
+        mediaRecorder.onstop = function (evt) {
+          info('onstop fired');
+
+          if (!onDataAvailableFirst) {
+            ok(false, 'onstop unexpectedly fired before ondataavailable');
+          }
+
+          ok(true, 'onstop fired successfully');
+          is(mediaRecorder.state, 'inactive',
+             'check recording status is inactive');
+          SimpleTest.finish();
+        };
+
+        mediaRecorder.stop();
+        is(mediaRecorder.state, 'inactive',
+           'Media recorder is inactive after being stopped');
+
+      } else if (dataAvailableCount === 2) {
+        // Ensure we've received at least two ondataavailable events before
+        // onstop
+        onDataAvailableFirst = true;
+      }
+    };
+
+    mediaRecorder.start(250);
+    is(mediaRecorder.state, 'recording', 'Media recorder should be recording');
+  }, function(err) {
+    ok(false, 'Unexpected error fired with: ' + err);
+    SimpleTest.finish();
+  });
+}
+
+SimpleTest.waitForExplicitFinish();
+startTest();
+</script>
+</pre>
+</body>
+</html>
--- a/testing/mochitest/android.json
+++ b/testing/mochitest/android.json
@@ -1,11 +1,12 @@
 {
 "runtests": {},
 "excludetests": {
+  "content/media/test/test_mediarecorder_record_gum_video_timeslice.html": "mimetype check, bug 969289",
   "dom/tests/mochitest/dom-level0": "bug 910229",
   "dom/imptests/html/webgl": "WebGL",
   "content/base/test/test_copypaste.xul": "bug 904183",
   "dom/tests/mochitest/dom-level1-core": "bug 910229",
   "dom/tests/mochitest/ajax/offline": "SLOW_DIRECTORY",
   "toolkit/content/tests/widgets/test_contextmenu_nested.xul": "",
   "security/manager/ssl/tests/mochitest/mixedcontent": "TIMED_OUT",
   "dom/browser-element/mochitest/test_browserElement_inproc_AppWindowNamespace.html": "TIMED_OUT, bug 783509",
--- a/testing/mochitest/androidx86.json
+++ b/testing/mochitest/androidx86.json
@@ -1,11 +1,12 @@
 {
 "runtests": {},
 "excludetests": {
+  "content/media/test/test_mediarecorder_record_gum_video_timeslice.html": "mimetype check, bug 969289",
   "dom/tests/mochitest/dom-level0": "bug 910229",
   "dom/imptests/html/webgl": "WebGL",
   "content/base/test/test_copypaste.xul": "bug 904183",
   "dom/tests/mochitest/dom-level1-core": "bug 910229",
   "dom/tests/mochitest/ajax/offline": "SLOW_DIRECTORY",
   "toolkit/content/tests/widgets/test_contextmenu_nested.xul": "",
   "security/manager/ssl/tests/mochitest/mixedcontent": "TIMED_OUT",
   "dom/browser-element/mochitest/test_browserElement_inproc_AppWindowNamespace.html": "TIMED_OUT, bug 783509",
--- a/testing/mochitest/b2g-debug.json
+++ b/testing/mochitest/b2g-debug.json
@@ -38,16 +38,17 @@
     "content/media/test/test_error_on_404.html": "timed out",
     "content/media/test/test_framebuffer.html": "timed out",
     "content/media/test/test_info_leak.html": "2 failures",
     "content/media/test/test_load.html": "Timed out after gizmo.mp4",
     "content/media/test/test_load_candidates.html": "timed out",
     "content/media/test/test_load_same_resource.html": "",
     "content/media/test/test_media_selection.html": "timed out",
     "content/media/test/test_metadata.html": "",
+    "content/media/test/test_mediarecorder_record_gum_video_timeslice.html": "mimetype check, bug 969289",
     "content/media/test/test_mozHasAudio.html": "",
     "content/media/test/test_play_events.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
     "content/media/test/test_play_events_2.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
     "content/media/test/test_playback.html": "Test timed out, bug 668973?",
     "content/media/test/test_playback_rate.html": "",
     "content/media/test/test_playback_rate_playpause.html": "",
     "content/media/test/test_played.html": "",
     "content/media/test/test_progress.html": "bug 901716 - timeouts",
--- a/testing/mochitest/b2g-desktop.json
+++ b/testing/mochitest/b2g-desktop.json
@@ -37,16 +37,17 @@
     "content/media/test/test_delay_load.html": "6 failures",
     "content/media/test/test_error_on_404.html": "timed out",
     "content/media/test/test_framebuffer.html": "timed out",
     "content/media/test/test_info_leak.html": "2 failures",
     "content/media/test/test_load.html": "Timed out after gizmo.mp4",
     "content/media/test/test_load_candidates.html": "timed out",
     "content/media/test/test_load_same_resource.html": "",
     "content/media/test/test_media_selection.html": "timed out",
+    "content/media/test/test_mediarecorder_record_gum_video_timeslice.html": "mimetype check, bug 969289",
     "content/media/test/test_metadata.html": "",
     "content/media/test/test_mozHasAudio.html": "",
     "content/media/test/test_play_events.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
     "content/media/test/test_play_events_2.html": "Last event should be canplaythrough for gizmo.mp4 - got playing, expected canplaythrough",
     "content/media/test/test_playback.html": "Test timed out, bug 668973?",
     "content/media/test/test_playback_rate.html": "",
     "content/media/test/test_playback_rate_playpause.html": "",
     "content/media/test/test_played.html": "",
--- a/testing/mochitest/b2g.json
+++ b/testing/mochitest/b2g.json
@@ -27,16 +27,17 @@
     "content/media/test/test_can_play_type_no_dash.html":"",
     "content/media/test/test_can_play_type_ogg.html":"",
     "content/media/test/test_chaining.html": "timed out",
     "content/media/test/test_delay_load.html": "6 failures",
     "content/media/test/test_framebuffer.html": "timed out",
     "content/media/test/test_info_leak.html": "2 failures",
     "content/media/test/test_media_selection.html": "timed out",
     "content/media/test/test_mediarecorder_record_4ch_audiocontext.html": "",
+    "content/media/test/test_mediarecorder_record_gum_video_timeslice.html": "mimetype check, bug 969289",
     "content/media/test/test_playback.html": "Test timed out, bug 668973?",
     "content/media/test/test_playback_rate.html": "",
     "content/media/test/test_playback_rate_playpause.html": "",
     "content/media/test/test_played.html": "",
     "content/media/test/test_referer.html":"",
     "content/media/test/test_seekable3.html": "timed out",
     "content/media/test/test_seek.html": "",
     "content/media/test/test_streams_element_capture.html": "bug 900172 - timeouts",