Bug 1110922 - Add logs to debug test_played.html timeouts. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Mon, 22 Dec 2014 23:12:00 -0500
changeset 238120 3d59a98d33c939f4ac6bdf24f1c5c976f1232586
parent 238119 a0315fb0c4f91e2611fd5f9993bba246ac8cc791
child 238121 c30c6cdaaa83aba93a04cb2ad6ef94ec4e7c26aa
push id7472
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 20:36:27 +0000
treeherdermozilla-aurora@300ca104f8fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1110922
milestone37.0a1
Bug 1110922 - Add logs to debug test_played.html timeouts. r=cpearce
dom/media/test/test_played.html
--- a/dom/media/test/test_played.html
+++ b/dom/media/test/test_played.html
@@ -10,16 +10,17 @@
 <body>
 <pre id='test'>
 <script class="testbody" type='application/javascript;version=1.8'>
 //longer timeout for sometimes B2G emulator runs very slowly
 if (SpecialPowers.Services.appinfo.name == "B2G") {
   SimpleTest.requestLongerTimeout(3);
 }
 
+SimpleTest.requestCompleteLog();
 let manager = new MediaTestManager;
 
 function finish_test(element) {
   removeNodeAndSource(element);
   manager.finished(element.token);
 }
 
 // Check that a file has been played in its entirety.
@@ -74,16 +75,17 @@ var tests = [
 },
 
 // Play the first half of the file, seek back, while
 // continuing to play. We shall have only one range.
 {
   setup : function (element) {
     let onTimeUpdate = function() {
       if (element.currentTime > element.duration / 2) {
+        info(element.token + ": currentTime=" + element.currentTime + ", duration=" + element.duration);
         element.removeEventListener("timeupdate", onTimeUpdate, false);
         element.pause();
         var oldEndRange = element.played.end(0);
         element.currentTime = element.duration / 4;
         is(element.played.end(0), oldEndRange,
            element.token + ": When seeking back, |played| should not be changed");
         element.play();
       }
@@ -97,16 +99,17 @@ var tests = [
 
 // Play and seek to have two ranges, and check that, as well a
 // boundaries.
 {
   setup : function (element) {
     let seekTarget = 0;
     let onTimeUpdate = function() {
       if (element.currentTime > element.duration / 2) {
+        info(element.token + ": currentTime=" + element.currentTime + ", duration=" + element.duration);
         element.removeEventListener("timeupdate", onTimeUpdate, false);
         element.pause();
         // Remember seek target for later comparison since duration may change
         // during playback.
         seekTarget = element.currentTime = element.duration / 10;
         element.currentTime = seekTarget;
         element.play();
       }
@@ -218,16 +221,29 @@ function createTestArray() {
 function startTest(test, token) {
   var elemType = getMajorMimeType(test.type);
   var element = document.createElement(elemType);
   element.src = test.src;
   element.token = token;
   element.preload = "metadata";
   test.setup(element);
   manager.started(token);
+
+  // Log events for debugging.
+  var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                "waiting", "pause"];
+  function logEvent(e) {
+    var v = e.target;
+    info(v.token + ": got " + e.type);
+  }
+  events.forEach(function(e) {
+    element.addEventListener(e, logEvent, false);
+  });
+
 }
 
 
 manager.runTests(createTestArray(), startTest);
 
 </script>
 </pre>
 </body>