Bug 881954 - Generalize test_too_many_elements to run on more than just Ogg audio. r=padenot
authorChris Pearce <cpearce@mozilla.com>
Fri, 14 Jun 2013 09:07:07 +1200
changeset 146482 a40c0f052f758aed0a6e8592cc953b716469a674
parent 146481 e1c91dd828e8b41010eb86bde607878f9a712f3e
child 146483 dc08e8496fc6c00f47307ebf8ca38cc95011053b
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs881954
milestone24.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 881954 - Generalize test_too_many_elements to run on more than just Ogg audio. r=padenot
content/media/test/manifest.js
content/media/test/test_too_many_elements.html
--- a/content/media/test/manifest.js
+++ b/content/media/test/manifest.js
@@ -489,16 +489,35 @@ var gMetadataTests = [
       name:"歌曲名稱",
       comments:"註解",
     }
   },
   { name:"wavedata_u8.wav", tags: { }
   },
 ];
 
+// The resources for test_too_many_elements.
+// We loads *lots* of these all at the same time.
+var gTooManyElementAudioTests = [
+  { name:"small-shot.ogg", type:"audio/ogg" },
+  { name:"r11025_s16_c1.wav", type:"audio/x-wav" },
+  { name:"detodos.opus", type:"audio/ogg; codecs=opus" },
+  { name:"bogus.duh", type:"bogus/duh" }
+];
+// Unfortunately the WMF backend on Windows 7 can't handle having lots of
+// decoders running concurrently, so we only include MPEG files when running on
+// Windows versions 8 and later, and non Windows systems.
+if (navigator.userAgent.indexOf("Windows") == -1 ||
+    IsWindows8OrLater()) {
+  gTooManyElementAudioTests = gTooManyElementAudioTests.concat([
+    { name:"small-shot.m4a", type:"audio/mp4" },
+    { name:"small-shot.mp3", type:"audio/mpeg" }
+  ]);
+}
+
 function checkMetadata(msg, e, test) {
   if (test.width) {
     is(e.videoWidth, test.width, msg + " video width");
   }
   if (test.height) {
     is(e.videoHeight, test.height, msg + " video height");
   }
   if (test.duration) {
--- a/content/media/test/test_too_many_elements.html
+++ b/content/media/test/test_too_many_elements.html
@@ -19,50 +19,72 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p>Received loadeddata event for <span id="result">0</span> <span id="expected"></span>audio elements.</p>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 713381 **/
 
 const num = 500;
 var loadeddata = 0;
+var testName = "?";
 
 var result = document.getElementById("result");
 document.getElementById("expected").innerHTML = " of " + num + " ";
 
 var finish = function(testNum) {
   return function() {
-    ok(true, "Received loadeddata event for instance " + testNum );
+    ok(true, testName + ": received loadeddata event for instance " + testNum );
     loadeddata++;
     if (loadeddata == num) {
-      ok(true, "Should receive loadeddata events for all " + num + " elements.");
-      SimpleTest.finish();
+      ok(true, testName + ": should receive loadeddata events for all " + num + " elements.");
+      nextTest();
     }
   }
 };
 
-var resource = getPlayableAudio(gSmallTests);
+var testNum = 0;
+
+function nextTest() {
+  if (testNum >= gTooManyElementAudioTests.length) {
+    SimpleTest.finish();
+    return;
+  }
+  var test = gTooManyElementAudioTests[testNum];
+  testNum++;
 
-if (resource == null) {
-  todo(false, "No types supported");
-} else {
-  SimpleTest.waitForExplicitFinish();
+  if (!document.createElement("audio").canPlayType(test.type)) {
+    setTimeout(nextTest, 0);
+    return;
+  }
+  var name = test.name;
+  
+  loadeddata = 0;
+  testName = name;
+
   // Load the resource, and play it to ensure it's entirely downloaded.
   // Once it's played through, create a large number of audio elements which
   // are the same resource. These will share data with the other resource, and
   // so be really cheap to create.
-  var res = new Audio(resource.name);
+  var res = new Audio(name);
   res.addEventListener("ended",
     function() {  
       for (var i=0; i<num; ++i) {
-        var a = new Audio(resource.name);
+        var a = new Audio(name);
         a.addEventListener("loadeddata", finish(i), false);
       }
     }, false);
   res.play();
+  
 }
 
-setInterval(function() { result.innerHTML = loadeddata; }, 1000);
+if (getPlayableAudio(gTooManyElementAudioTests) == null) {
+  todo(false, "No types supported");
+} else {
+  SimpleTest.waitForExplicitFinish();
+  nextTest();
+}
+
+setInterval(function() { result.innerHTML = testName + ": " + loadeddata; }, 1000);
 
 </script>
 </pre>
 </body>
 </html>