Bug 1089484 - Have test_reset_src.html test more files to increase test coverage. r=kinetik
authorJW Wang <jwwang@mozilla.com>
Mon, 27 Oct 2014 23:34:00 +0100
changeset 212920 160999d8824b5a7f4d9b9469faa654bec4c7099a
parent 212919 ddbf4c3a4f34621ea3b7bde26f17a277587f21f8
child 212921 35467f9c4fa5c39a8de4e4570ab8278353c7de2a
push id27736
push userryanvm@gmail.com
push dateWed, 29 Oct 2014 20:49:13 +0000
treeherdermozilla-central@80e18ff7c7b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1089484
milestone36.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 1089484 - Have test_reset_src.html test more files to increase test coverage. r=kinetik
dom/media/test/manifest.js
dom/media/test/test_reset_src.html
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -119,17 +119,17 @@ var gPlayTests = [
 
   // oggz-chop stream
   { name:"bug482461.ogv", type:"video/ogg", duration:4.34 },
   // Theora only oggz-chop stream
   { name:"bug482461-theora.ogv", type:"video/ogg", duration:4.138 },
   // With first frame a "duplicate" (empty) frame.
   { name:"bug500311.ogv", type:"video/ogg", duration:1.96 },
   // Small audio file
-  { name:"small-shot.ogg", type:"video/ogg", duration:0.276 },
+  { name:"small-shot.ogg", type:"audio/ogg", duration:0.276 },
   // More audio in file than video.
   { name:"short-video.ogv", type:"video/ogg", duration:1.081 },
   // First Theora data packet is zero bytes.
   { name:"bug504613.ogv", type:"video/ogg", duration:Number.NaN },
   // Multiple audio streams.
   { name:"bug516323.ogv", type:"video/ogg", duration:4.208 },
   // oggz-chop with non-keyframe as first frame
   { name:"bug556821.ogv", type:"video/ogg", duration:2.551 },
@@ -674,23 +674,27 @@ function checkMetadata(msg, e, test) {
     ok(Math.abs(e.duration - test.duration) < 0.1,
        msg + " duration (" + e.duration + ") should be around " + test.duration);
   }
 }
 
 // Returns the first test from candidates array which we can play with the
 // installed video backends.
 function getPlayableVideo(candidates) {
-  var v = document.createElement("video");
-  var resources = candidates.filter(function(x){return /^video/.test(x.type) && v.canPlayType(x.type);});
+  var resources = getPlayableVideos(candidates);
   if (resources.length > 0)
     return resources[0];
   return null;
 }
 
+function getPlayableVideos(candidates) {
+  var v = document.createElement("video");
+  return candidates.filter(function(x){return /^video/.test(x.type) && v.canPlayType(x.type);});
+}
+
 function getPlayableAudio(candidates) {
   var v = document.createElement("audio");
   var resources = candidates.filter(function(x){return /^audio/.test(x.type) && v.canPlayType(x.type);});
   if (resources.length > 0)
     return resources[0];
   return null;
 }
 
--- a/dom/media/test/test_reset_src.html
+++ b/dom/media/test/test_reset_src.html
@@ -9,78 +9,87 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="manifest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank"
 href="https://bugzilla.mozilla.org/show_bug.cgi?id=804875">Mozilla Bug 804875</a>
 
-<video style="border: 4px solid red" controls></video>
 <canvas></canvas>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
+var manager = new MediaTestManager;
+
+function finish(v) {
+  removeNodeAndSource(v);
+  manager.finished(v.token);
+}
+
 function onLoadedMetadata_Audio(e) {
   var t = e.target;
-  is(t.videoHeight, 0, "videoHeight should be zero when there is no video.");
-  is(t.videoWidth, 0, "videoWidth should be zero when there is no video.");
-  is(t.mozPaintedFrames, 0, "mozPaintedFrames should be zero when there is no video.");
-  is(t.mozFrameDelay, 0, "mozFrameDelay should be zero when there is no video.");
+  is(t.videoHeight, 0, t.name + ": videoHeight should be zero when there is no video.");
+  is(t.videoWidth, 0, t.name + ": videoWidth should be zero when there is no video.");
+  is(t.mozPaintedFrames, 0, t.name + ": mozPaintedFrames should be zero when there is no video.");
+  is(t.mozFrameDelay, 0, t.name + ": mozFrameDelay should be zero when there is no video.");
   var c = document.getElementsByTagName("canvas")[0].getContext("2d");
   try {
     c.drawImage(t, 0, 0, t.videoHeight, t.videoWidth);
   } catch (e) {
-    ok(true, "Trying to draw to a canvas should throw, since we don't have a frame anymore");
-    SimpleTest.finish();
+    ok(true, t.name + ": Trying to draw to a canvas should throw, since we don't have a frame anymore");
+    finish(t);
     return;
   }
-  ok(false, "We should not succeed to draw a video frame on the canvas.");
+  ok(false, t.name + ": We should not succeed to draw a video frame on the canvas.");
 }
 
 function onTimeUpdate_Video(e) {
   var t = e.target;
   if (t.currentTime < t.duration / 4) {
     return;
   }
   t.removeEventListener("timeupdate", onTimeUpdate_Video);
-  ok(t.mozPaintedFrames > 0, "mozPaintedFrames should be positive, is " + t.mozPaintedFrames + ".");
-  ok(t.mozFrameDelay >= 0, "mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
+  ok(t.mozPaintedFrames > 0, t.name + ": mozPaintedFrames should be positive, is " + t.mozPaintedFrames + ".");
+  ok(t.mozFrameDelay >= 0, t.name + ": mozFrameDelay should be positive or zero, is " + t.mozFrameDelay + ".");
 
-  if (v._firstTime) {
+  if (t._firstTime) {
     t.src = t.src;
-    v._firstTime = false;
+    t._firstTime = false;
   } else {
     var source = getPlayableAudio(gPlayTests);
     if (!source) {
       todo("No audio file available.")
-      SimpleTest.finish();
+      finish(t);
     } else {
       t.removeEventListener("loadedmetadata", onLoadedMetadata_Video);
       t.addEventListener("loadedmetadata", onLoadedMetadata_Audio);
       t.src = source.name;
     }
   }
 }
 
 function onLoadedMetadata_Video(e) {
   var t = e.target;
-  ok(t.videoHeight != 0, "We should have a videoHeight.");
-  ok(t.videoWidth != 0, "We should have a videoWidth.");
+  isnot(t.videoHeight, 0, t.name + ": We should have a videoHeight.");
+  isnot(t.videoWidth, 0, t.name + ": We should have a videoWidth.");
   t.addEventListener("timeupdate", onTimeUpdate_Video);
   t.play();
 }
 
-var v = document.getElementsByTagName("video")[0];
-v._firstTime = true;
-var source = getPlayableVideo(gPlayTests);
-if (!source) {
-  todo("No video file available.");
-} else {
+function startTest(test, token) {
+  var v = document.createElement('video');
+  document.body.appendChild(v);
+  v.preload = "metadata";
+  v._firstTime = true;
   v.addEventListener("loadedmetadata", onLoadedMetadata_Video);
-  v.src = source.name;
-  SimpleTest.waitForExplicitFinish();
+  v.src = test.name;
+  v.token = token;
+  v.name = test.name;
+  manager.started(token);
 }
+
+manager.runTests(getPlayableVideos(gSmallTests.concat(gSeekTests)), startTest);
 </script>
 </pre>
 </body>
 </html>