Bug 909670 - Test case for for the MediaRecorder::Session. r=jsmith
authorCJKu <cku@mozilla.com>
Thu, 26 Sep 2013 09:40:41 -0400
changeset 148791 704346e888a4b6577119978ce8a1cf057b4989b2
parent 148790 31d46902237220e76898325ee064c80de90d7abc
child 148792 70ec111942ca8da98490698d1d71dce5d6ecbca0
push id1229
push userryanvm@gmail.com
push dateThu, 26 Sep 2013 13:40:46 +0000
treeherderb2g-inbound@70ec111942ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsmith
bugs909670
milestone27.0a1
Bug 909670 - Test case for for the MediaRecorder::Session. r=jsmith
content/media/test/Makefile.in
content/media/test/test_mediarecorder_record_session.html
--- a/content/media/test/Makefile.in
+++ b/content/media/test/Makefile.in
@@ -119,16 +119,17 @@ MOCHITEST_FILES = \
 		test_source_media.html \
 		test_autoplay_contentEditable.html \
 		test_bug448534.html \
 		test_bug463162.xhtml \
 		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_media_selection.html \
 		test_playback.html \
 		test_seekLies.html \
 		test_media_sniffer.html \
 		contentType.sjs \
 		test_streams_srcObject.html \
 		test_reset_src.html \
 		test_streams_autoplay.html \
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_mediarecorder_record_session.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=909670
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Media Recoder recording session</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var manager = new MediaTestManager;
+
+function startTest(test, token) {
+  var element = document.createElement('audio');
+
+  element.token = token;
+  manager.started(token);
+
+  element.src = test.name;
+  element.test = test;
+  element.stream = element.mozCaptureStream();
+
+  var mStopCount = 0;
+  // Start and stop recording session three times continuously.
+  var mExpectStopCount = 3;
+  var mediaRecorder = new MediaRecorder(element.stream);
+
+  // Stop callback.
+  // Suppose to receive mExpectStopCount
+  mediaRecorder.onstop = function stopCallback() {
+    mStopCount++;
+
+    info("MediaRecorder.onstop callback: (" + mStopCount + ")");
+
+    if (mExpectStopCount === mStopCount)
+    {
+      manager.finished(token);
+    }
+  }
+
+  // data avaliable.
+  mediaRecorder.ondataavailable = function(evt) {}
+
+  mediaRecorder.onerror = function(err) {
+    ok(false, 'Unexpected error fired with:' + err);
+  }
+
+  mediaRecorder.onwarning = function() {
+    ok(false, 'Unexpected warning fired');
+  }
+
+  element.oncanplaythrough = function () {
+    for (var i = 0; i < mExpectStopCount; i++) {
+      mediaRecorder.start(1000);
+      mediaRecorder.stop();
+    }
+  }
+
+  element.play();
+}
+
+manager.runTests(gMediaRecorderTests, startTest);
+
+</script>
+</pre>
+</body>
+</html>