Bug 1153739 - Make Log() usable outside EME test cases. r=edwin, a=test-only
authorJW Wang <jwwang@mozilla.com>
Tue, 14 Apr 2015 11:27:58 +0800
changeset 258462 bf3ca76f10c3
parent 258461 8a5486269821
child 258463 b2d1be38dab1
push id4676
push userryanvm@gmail.com
push date2015-04-15 02:06 +0000
treeherdermozilla-beta@91df81e2edac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin, test-only
bugs1153739
milestone38.0
Bug 1153739 - Make Log() usable outside EME test cases. r=edwin, a=test-only
dom/media/test/eme.js
dom/media/test/manifest.js
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -48,36 +48,16 @@ function HexToBase64(hex)
 {
   var bin = "";
   for (var i = 0; i < hex.length; i += 2) {
     bin += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
   }
   return window.btoa(bin).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
 }
 
-function TimeStamp(token) {
-  function pad(x) {
-    return (x < 10) ? "0" + x : x;
-  }
-  var now = new Date();
-  var ms = now.getMilliseconds();
-  var time = "[" +
-             pad(now.getHours()) + ":" +
-             pad(now.getMinutes()) + ":" +
-             pad(now.getSeconds()) + "." +
-             ms +
-             "]" +
-             (ms < 10 ? "  " : (ms < 100 ? " " : ""));
-  return token ? (time + " " + token) : time;
-}
-
-function Log(token, msg) {
-  info(TimeStamp(token) + " " + msg);
-}
-
 function UpdateSessionFunc(test, token, sessionType, resolve, reject) {
   return function(ev) {
     var msgStr = ArrayBufferToString(ev.message);
     var msg = JSON.parse(msgStr);
 
     Log(token, "got message from CDM: " + msgStr);
     is(msg.type, sessionType, TimeStamp(token) + " key session type should match");
     ok(msg.kids, TimeStamp(token) + " message event should contain key ID array");
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -732,16 +732,36 @@ function removeNodeAndSource(n) {
   // reset |mozSrcObject| first since it takes precedence over |src|.
   n.mozSrcObject = null;
   n.src = "";
   while (n.firstChild) {
     n.removeChild(n.firstChild);
   }
 }
 
+function TimeStamp(token) {
+  function pad(x) {
+    return (x < 10) ? "0" + x : x;
+  }
+  var now = new Date();
+  var ms = now.getMilliseconds();
+  var time = "[" +
+             pad(now.getHours()) + ":" +
+             pad(now.getMinutes()) + ":" +
+             pad(now.getSeconds()) + "." +
+             ms +
+             "]" +
+             (ms < 10 ? "  " : (ms < 100 ? " " : ""));
+  return token ? (time + " " + token) : time;
+}
+
+function Log(token, msg) {
+  info(TimeStamp(token) + " " + msg);
+}
+
 // Number of tests to run in parallel.
 var PARALLEL_TESTS = 2;
 
 // When true, we'll loop forever on whatever test we run. Use this to debug
 // intermittent test failures.
 const DEBUG_TEST_LOOP_FOREVER = false;
 
 // Manages a run of media tests. Runs them in chunks in order to limit