Bug 760325 - Report all events after 'ended' as test failures, except when removing the element we ignore timeupdate/pause/stalled events. Use info() for logging, not ok(). r=roc
authorMats Palmgren <matspal@gmail.com>
Fri, 01 Jun 2012 20:52:37 +0200
changeset 95561 79b0b7c40b24ebf4f783294756a07f782dc7dfb3
parent 95560 8c39ac876f64e1e9d7a2a1ecca9e0fc25cae0b25
child 95562 0e2a092e3f004e9c35d82bd89d1ba6bc2e03cb17
push id22819
push usereakhgari@mozilla.com
push dateSat, 02 Jun 2012 18:40:08 +0000
treeherdermozilla-central@f4a7c1a1f514 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs760325
milestone15.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 760325 - Report all events after 'ended' as test failures, except when removing the element we ignore timeupdate/pause/stalled events. Use info() for logging, not ok(). r=roc
content/media/test/test_timeupdate_small_files.html
--- a/content/media/test/test_timeupdate_small_files.html
+++ b/content/media/test/test_timeupdate_small_files.html
@@ -15,59 +15,66 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var manager = new MediaTestManager;
 
 function timeupdate(e) {
   var v = e.target;
   v._timeupdateCount++;
-  ok(!v.gotEnded, v._name + " - shouldn't get timeupdate after ended");
+  ok(v.gotEnded == 0, v._name + " - shouldn't get timeupdate after ended");
 }
 
 function ended(e) {
   var v = e.target;
-  v.gotEnded = true;
+  ++v.gotEnded;
   ok(v._timeupdateCount > 0, v._name + " - should see at least one timeupdate: " + v.currentTime);
   v._finished = true;
   // Finish the test after 500ms. We shouldn't receive any timeupdate events
   // after the ended event, so this gives time for any pending timeupdate events
   // to fire so we can ensure we don't regress behaviour.
   setTimeout(
     function() {
       // Remove the event listeners before removing the video from the document.
       // We should receive a timeupdate and pause event when we remove the element
       // from the document (as the element is specified to behave as if pause() was
       // invoked when it's removed from a document), and we don't want those
       // confusing the test results.
       v.removeEventListener("ended", ended, false);
       v.removeEventListener("timeupdate", timeupdate, false);
+      v.removeEventListener("timeupdate", logEvent, false);
+      v.removeEventListener("pause", logEvent, false);
+      v.removeEventListener("stalled", logEvent, false);
       v.parentNode.removeChild(v);
       manager.finished(v.token);
     },
     500);
 }
 
 var eventsToLog = ["play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
   "loadeddata", "playing", "progress", "timeupdate", "ended", "suspend", "error", "stalled", "emptied", "abort",
   "waiting", "pause"];
 function logEvent(event) {
-  ok(true, event.target.currentSrc + " got " + event.type);
+  if (event.target.gotEnded > (event.type == "ended" ? 1 : 0)) {
+    ok(false, event.target.currentSrc + " got unexpected " + event.type + " after ended");
+  } else {
+    info(event.target.currentSrc + " got " + event.type);
+  }
 }
 
 function startTest(test, token) {
   var type = /^video/.test(test.type) ? "video" : "audio";
   var v = document.createElement(type);
   v.token = token;
   manager.started(token);
   v.src = test.name;
   v._name = test.name;
   v._timeupdateCount = 0;
   v._finished = false;
-  v.gotEnded = false;
+  v.gotEnded = 0;
   v.autoplay = true;
   v.addEventListener("ended", ended, false);
   v.addEventListener("timeupdate", timeupdate, false);
   for (var i = 0; i < eventsToLog.length; ++i) {
     v.addEventListener(eventsToLog[i], logEvent, false);
   }
   document.body.appendChild(v);
 }