Bug 935774 - Test for record four audio channels audiocontext. r=jsmith
☠☠ backed out by c7cbfa315d46 ☠ ☠
authorRandy Lin <rlin@mozilla.com>
Wed, 20 Nov 2013 17:32:22 +0800
changeset 156498 efb217f1897a1a687b06ec50ae0123d7d0bd43f9
parent 156497 c9a22296f31192ef92d99d8e0b86b1d05de43a02
child 156499 9cad550b8c5730773ff5f1ea8161d72ac08d433e
push id25683
push userryanvm@gmail.com
push dateThu, 21 Nov 2013 01:42:57 +0000
treeherdermozilla-central@cf378dddfac8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsmith
bugs935774
milestone28.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 935774 - Test for record four audio channels audiocontext. r=jsmith
content/media/test/mochitest.ini
content/media/test/test_mediarecorder_record_4ch_audiocontext.html
--- a/content/media/test/mochitest.ini
+++ b/content/media/test/mochitest.ini
@@ -232,16 +232,17 @@ support-files =
 [test_standalone.html]
 [test_volume.html]
 [test_video_to_canvas.html]
 [test_audiowrite.html]
 [test_mediarecorder_creation.html]
 [test_mediarecorder_avoid_recursion.html]
 [test_mediarecorder_record_timeslice.html]
 [test_mediarecorder_record_audiocontext.html]
+[test_mediarecorder_record_4ch_audiocontext.html]
 [test_mediarecorder_record_stopms.html]
 [test_mediarecorder_record_nosrc.html]
 [test_mozHasAudio.html]
 [test_source_media.html]
 [test_autoplay_contentEditable.html]
 [test_decoder_disable.html]
 [test_mediarecorder_record_no_timeslice.html]
 [test_mediarecorder_reload_crash.html]
new file mode 100644
--- /dev/null
+++ b/content/media/test/test_mediarecorder_record_4ch_audiocontext.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test MediaRecorder Record AudioContext with four channels</title>
+  <script type="text/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>
+
+<script class="testbody" type="text/javascript">
+
+function startTest() {
+  var context = new AudioContext();
+  var buffer = context.createBuffer(4, 80920, context.sampleRate);
+  for (var i = 0; i < 80920; ++i) {
+    for(var j = 0; j < 4; ++j) {
+      buffer.getChannelData(j)[i] = Math.sin(1000 * 2 * Math.PI * i / context.sampleRate);
+    }
+  }
+
+  var source = context.createBufferSource();
+  source.buffer = buffer;
+  var dest = context.createMediaStreamDestination();
+  var stopTriggered = false;
+  var onstopTriggered = false;
+  dest.channelCount = 4;
+  var expectedMimeType = 'audio/ogg';
+  source.channelCountMode = 'explicit';
+  source.connect(dest);
+  var elem = document.createElement('audio');
+  elem.mozSrcObject = dest.stream;
+  mMediaStream = dest.stream;
+  source.start(0);
+  elem.play();
+  mMediaRecorder = new MediaRecorder(dest.stream);
+  mMediaRecorder.onwarning = function() {
+    ok(false, 'onwarning unexpectedly fired');
+  };
+
+  mMediaRecorder.onerror = function() {
+    ok(false, 'onerror unexpectedly fired');
+  };
+
+  mMediaRecorder.onstop = function() {
+    ok(true, 'onstop fired successfully');
+    is(mMediaRecorder.state, 'inactive', 'check recording status is inactive');
+    onstopTriggered = true;
+    SimpleTest.finish();
+  };
+  mMediaRecorder.ondataavailable = function (e) {
+    ok(e.data.size > 0, 'check blob has data');
+    is(mMediaRecorder.mimeType, expectedMimeType, 'blob should has mimetype, return ' + mMediaRecorder.mimeType);
+    if (!stopTriggered) {
+      mMediaRecorder.stop();
+      stopTriggered = true;
+    } else if (onstopTriggered) {
+      ok(false, 'ondataavailable should come before onstop event');
+    }
+  };
+  try {
+    mMediaRecorder.start(1000);
+    is('recording', mMediaRecorder.state, "check record state recording");
+  } catch (e) {
+    ok(false, 'Can t record audio context');
+  }
+}
+
+startTest();
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+</body>
+</html>