Bug 1523563 - Test all mime types with audio node recording. r=jib
authorAndreas Pehrson <apehrson@mozilla.com>
Wed, 19 Jun 2019 16:09:26 +0000
changeset 481087 944da9f033e8c2da0610742f7dcbf8a05c4a775b
parent 481086 e431e395e20e3028689d4bf4e8529414e16b9fdd
child 481088 7c42061bf905302cb5159f79f5db4accd60260de
push id89078
push userpehrsons@gmail.com
push dateWed, 03 Jul 2019 09:31:19 +0000
treeherderautoland@d9f2bc3dd281 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1523563
milestone69.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 1523563 - Test all mime types with audio node recording. r=jib Differential Revision: https://phabricator.services.mozilla.com/D35170
dom/media/test/test_mediarecorder_record_audionode.html
--- a/dom/media/test/test_mediarecorder_record_audionode.html
+++ b/dom/media/test/test_mediarecorder_record_audionode.html
@@ -44,32 +44,37 @@ function setUpSource(contextType, nodeTy
   // Explicitly start offline context.
   if (contextType == "offline") {
     context.startRendering();
   }
 
   return node;
 }
 
-async function testRecord(source) {
+async function testRecord(source, mimeType) {
   const isOffline = source.context instanceof OfflineAudioContext;
-  const recorder = new MediaRecorder(source);
+  const recorder = new MediaRecorder(source, 0, {mimeType});
+  is(recorder.mimeType, mimeType, "Mime type is set");
 
   recorder.onwarning = () => ok(false, "should not fire onwarning");
   recorder.onerror = () => ok(false, "should not fire onerror");
   if (!isOffline) {
     recorder.onstop = () => ok(false, "should not fire stop yet");
   }
 
   recorder.start(1000);
   is("recording", recorder.state, "state should become recording after calling start()");
 
   const chunks = [];
   let {data} = await new Promise(r => recorder.ondataavailable = r);
-  is(data.type, "audio/ogg", "Blob has expected mimetype");
+  is(recorder.state, "recording", "Expected to still be recording");
+  is(data.type, recorder.mimeType, "Blob has recorder mimetype");
+  if (mimeType != "") {
+    is(data.type, mimeType, "Blob has given mimetype");
+  }
   isnot(data.size, 0, "should get data and its length should be > 0");
   chunks.push(data);
 
   if (isOffline) {
     await new Promise(r => recorder.onstop = r);
     is(recorder.state, "inactive", "Offline context should end by itself");
   } else {
     is(recorder.state, "recording", "Expected to still be recording");
@@ -95,24 +100,32 @@ addLoadEvent(async function() {
   }
   ok(didThrow, "MediaRecorder(AudioNode) should be hidden behind a pref");
 
   await SpecialPowers.pushPrefEnv({"set": [
       ["media.recorder.audio_node.enabled", true],
     ]});
 
   // Test with various context and source node types.
-  for (const {context, node} of [
-    {context: "", node: "source"},
-    {context: "", node: "splitter"},
-    {context: "offline", node: "destination"},
+  for (const mimeType of [
+    "audio/ogg",
+    "audio/webm",
+    "video/webm",
+    "",
   ]) {
-    info(`Testing recording ${context == "" ? "regular" : context} context and ${node} node`);
-    await testRecord(setUpSource(context, node));
-  };
+    for (const {context, node} of [
+      {context: "", node: "source"},
+      {context: "", node: "splitter"},
+      {context: "offline", node: "destination"},
+    ]) {
+      info(`Testing recording ${context || "regular"} context and ${node} ` +
+           `node with mimeType '${mimeType}'`);
+      await testRecord(setUpSource(context, node), mimeType);
+    }
+  }
 
   SimpleTest.finish();
 });
 
 </script>
 </pre>
 </body>
 </html>