Bug 1289742. P6 - give the cloned test a different token for better logging messages. r=kaku
authorJW Wang <jwwang@mozilla.com>
Mon, 06 Mar 2017 15:28:41 +0800
changeset 494340 c3f28dc126fa6dee249c0a4a5c80fcdf3c3d19c7
parent 494339 c0b2e94b0b5ef433aaad1a4593c11cc62d6a8b70
child 494341 ca56682eb7c1388fb3cef8c4692b0f1cac2b909d
push id48023
push userjwwang@mozilla.com
push dateTue, 07 Mar 2017 02:32:15 +0000
reviewerskaku
bugs1289742
milestone54.0a1
Bug 1289742. P6 - give the cloned test a different token for better logging messages. r=kaku MozReview-Commit-ID: 3Hc0SON17Lt
dom/media/test/test_load_same_resource.html
--- a/dom/media/test/test_load_same_resource.html
+++ b/dom/media/test/test_load_same_resource.html
@@ -15,47 +15,49 @@ SimpleTest.requestCompleteLog();
 var manager = new MediaTestManager;
 
 function checkDuration(actual, expected, name) {
   ok(Math.abs(actual - expected) < 0.1,
      `${name} duration: ${actual} expected: ${expected}`);
 }
 
 function cloneLoaded(event) {
-  ok(true, "Clone loaded OK");
   var e = event.target;
+  ok(true, `${e.token} loaded OK`);
   checkDuration(e.duration, e._expectedDuration, e.token);
   removeNodeAndSource(e);
   manager.finished(e.token);
 }
 
 function tryClone(event) {
   var e = event.target;
   var clone = e.cloneNode(false);
-  clone.token = e.token;
+  clone.token = `${e.token}(cloned)`;
+  manager.started(clone.token);
+  manager.finished(e.token);
 
   // Log events for debugging.
   var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
                 "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
                 "waiting", "pause"];
   function logEvent(evt) {
     var e = evt.target;
-    info(e.token + ": got " + evt.type);
+    info(`${e.token} got ${evt.type}`);
   }
   events.forEach(function(e) {
     clone.addEventListener(e, logEvent);
   });
 
 
   checkDuration(e.duration, e._expectedDuration, e.token);
   clone._expectedDuration = e._expectedDuration;
 
   clone.addEventListener("loadeddata", cloneLoaded, {once: true});
   clone.addEventListener("loadstart", function(evt) {
-    info("cloned " + evt.target.token + " start loading.");
+    info(`${evt.target.token} starts loading.`);
     // Since there is only one H264 decoder instance, we have to delete the
     // decoder of the original element for the cloned element to load. However,
     // we can't delete the decoder too early otherwise cloning decoder will
     // fail to kick in. We wait for 'loadstart' event of the cloned element to
     // know when the decoder is already cloned and we can delete the decoder of
     // the original element.
     removeNodeAndSource(e);
   }, {once: true});