Bug 1556637 - Replace all mozDumpDebugInfo calls r=jya,jib
authorTarek Ziadé <tarek@mozilla.com>
Wed, 14 Aug 2019 20:32:31 +0000
changeset 488124 05b192f3ba82425d42ab63510b224a90334e5ca9
parent 488123 640aff6b43b5099e362c4143f95068a188c5bcfa
child 488125 4c1bdf45201ae5fce0b87225c46a6ae5f7c6034a
push id113900
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:53:50 +0000
treeherdermozilla-inbound@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, jib
bugs1556637
milestone70.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 1556637 - Replace all mozDumpDebugInfo calls r=jya,jib Replaces mozDumpDebugInfo with mozRequestDebugInfo Differential Revision: https://phabricator.services.mozilla.com/D37836
dom/imptests/testharnessreport.js
dom/media/mediasource/test/mediasource.js
dom/media/mediasource/test/test_Eviction_mp4.html
dom/media/mediasource/test/test_ExperimentalAsync.html
dom/media/test/manifest.js
testing/mochitest/tests/SimpleTest/SimpleTest.js
testing/mochitest/tests/SimpleTest/TestRunner.js
--- a/dom/imptests/testharnessreport.js
+++ b/dom/imptests/testharnessreport.js
@@ -273,17 +273,17 @@ var W3CTest = {
       "todo": false
     });
   },
 
   /**
    * Timeout the current test. Intended to be used from harness code, not
    * from tests.
    */
-  "timeout": function() {
+  "timeout": async function() {
     this.logFailure("Timeout", "Test runner timed us out.");
     timeout();
   }
 };
 (function() {
   try {
     var path = W3CTest.getPath();
     if (path) {
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -178,22 +178,22 @@ function fetchAndLoadAsync(sb, prefix, c
     for (const chunk of chunks) {
       rv = rv.then(loadSegmentAsync.bind(null, sb, buffers[chunk]));
     }
     return rv;
   });
 }
 
 // Register timeout function to dump debugging logs.
-SimpleTest.registerTimeoutFunction(function() {
+SimpleTest.registerTimeoutFunction(async function() {
   for (const v of document.getElementsByTagName("video")) {
-    v.mozDumpDebugInfo();
+    console.log(await SpecialPowers.wrap(v).mozRequestDebugInfo());
   }
   for (const a of document.getElementsByTagName("audio")) {
-    a.mozDumpDebugInfo();
+    console.log(await SpecialPowers.wrap(a).mozRequestDebugInfo());
   }
 });
 
 async function waitUntilTime(target, targetTime) {
   await new Promise(resolve => {
     target.addEventListener("waiting", function onwaiting() {
       info("Got a waiting event at " + target.currentTime);
       if (target.currentTime >= targetTime) {
--- a/dom/media/mediasource/test/test_Eviction_mp4.html
+++ b/dom/media/mediasource/test/test_Eviction_mp4.html
@@ -47,17 +47,17 @@ runWithMSE(async (ms, el) => {
   dump("dump: seeked to " + seekTime);
   is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
   try {
     audiosb.appendBuffer(audioBuffer);
     await once(audiosb, "update");
     ok(true, "appendBuffer succeeded");
   } catch (ex) {
     ok(false, "Shouldn't throw another time when data can be evicted");
-    el.mozDumpDebugInfo();
+    dump(JSON.stringify(await SpecialPowers.wrap(el).mozRequestDebugInfo()));
   }
   SimpleTest.finish();
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_ExperimentalAsync.html
+++ b/dom/media/mediasource/test/test_ExperimentalAsync.html
@@ -56,19 +56,19 @@ runWithMSE(async function(ms, el) {
     async function(ex1) { // onCaughtExceptionCallback
       is(ex1.name, "QuotaExceededError", "QuotaExceededError thrown");
       is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
       const seekTime = audiosb.buffered.end(0) / 2;
       el.currentTime = seekTime;
       await once(el, "seeked");
       dump("dump: seeked to " + seekTime);
       is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
-      await audiosb.appendBufferAsync(audioBuffer).catch(function(ex2) {
+      await audiosb.appendBufferAsync(audioBuffer).catch(async function(ex2) {
         ok(false, "Shouldn't throw another time when data can be evicted");
-        el.mozDumpDebugInfo();
+        dump(JSON.stringify(await SpecialPowers.wrap(el).mozRequestDebugInfo()));
         SimpleTest.finish();
       });
       // Test that an error in remove return a rejected promise
       await audiosb.removeAsync(5, 0).catch(async function(ex3) {
         ok(true, "remove promise got rejected with end <= start");
         is(ex3.name, "TypeError");
         await audiosb.removeAsync(ms.duration + 1, Infinity).catch(async function(ex4) {
           ok(true, "remove promise got rejected with start > duration");
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -1852,36 +1852,35 @@ function mediaTestCleanup(callback) {
       A[i] = null;
     }
     SpecialPowers.exactGC(callback);
 }
 
 async function dumpDebugInfoForToken(token) {
   for (let v of document.getElementsByTagName("video")) {
     if (token === v.token) {
-      return v.mozDumpDebugInfo();
+      info(JSON.stringify(await SpecialPowers.wrap(v).mozRequestDebugInfo()));
+      return;
     }
   }
   for (let a of document.getElementsByTagName("audio")) {
     if (token === a.token) {
-      return a.mozDumpDebugInfo();
+      info(JSON.stringify(await SpecialPowers.wrap(a).mozRequestDebugInfo()));
+      return;
     }
   }
-  return Promise.resolve();
-}
-
-function dumpDebugInfo() {
-  for (var v of document.getElementsByTagName("video")) {
-    v.mozDumpDebugInfo();
-  }
-  for (var a of document.getElementsByTagName("audio")) {
-    a.mozDumpDebugInfo();
-  }
 }
 
 // Could be undefined in a page opened by the parent test page
 // like file_access_controls.html.
 if ("SimpleTest" in window) {
   SimpleTest.requestFlakyTimeout("untriaged");
 
   // Register timeout function to dump debugging logs.
-  SimpleTest.registerTimeoutFunction(dumpDebugInfo);
+  SimpleTest.registerTimeoutFunction(async function() {
+    for (const v of document.getElementsByTagName("video")) {
+      SimpleTest.info(JSON.stringify(await SpecialPowers.wrap(v).mozRequestDebugInfo()));
+    }
+    for (const a of document.getElementsByTagName("audio")) {
+      SimpleTest.info(JSON.stringify(await SpecialPowers.wrap(a).mozRequestDebugInfo()));
+    }
+  });
 }
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -1088,19 +1088,19 @@ SimpleTest.testInChaosMode = function() 
     if (SimpleTest._inChaosMode) {
       // It's already enabled for this test, don't enter twice
       return;
     }
     SpecialPowers.DOMWindowUtils.enterChaosMode();
     SimpleTest._inChaosMode = true;
 };
 
-SimpleTest.timeout = function() {
-    for (let func of SimpleTest._timeoutFunctions) {
-        func();
+SimpleTest.timeout = async function() {
+    for (const func of SimpleTest._timeoutFunctions) {
+        await func();
     }
     SimpleTest._timeoutFunctions = [];
 }
 
 /**
  * Finishes the tests. This is automatically called, except when
  * SimpleTest.waitForExplicitFinish() has been invoked.
 **/
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -119,22 +119,22 @@ TestRunner._checkForHangs = function() {
   function reportError(win, msg) {
     if ("SimpleTest" in win) {
       win.SimpleTest.ok(false, msg);
     } else if ("W3CTest" in win) {
       win.W3CTest.logFailure(msg);
     }
   }
 
-  function killTest(win) {
+  async function killTest(win) {
     if ("SimpleTest" in win) {
-      win.SimpleTest.timeout();
+      await win.SimpleTest.timeout();
       win.SimpleTest.finish();
     } else if ("W3CTest" in win) {
-      win.W3CTest.timeout();
+      await win.W3CTest.timeout();
     }
   }
 
   if (TestRunner._currentTest < TestRunner._urls.length) {
     var runtime = new Date().valueOf() - TestRunner._currentTestStartTime;
     if (runtime >= TestRunner.timeout * TestRunner._timeoutFactor) {
       var frameWindow = $('testframe').contentWindow.wrappedJSObject ||
                           $('testframe').contentWindow;
@@ -149,17 +149,24 @@ TestRunner._checkForHangs = function() {
         TestRunner.currentTestURL = "(SimpleTest/TestRunner.js)";
         reportError(frameWindow, TestRunner.maxTimeouts + " test timeouts, giving up.");
         var skippedTests = TestRunner._urls.length - TestRunner._currentTest;
         reportError(frameWindow, "Skipping " + skippedTests + " remaining tests.");
       }
 
       // Add a little (1 second) delay to ensure automation.py has time to notice
       // "Test timed out" log and process it (= take a screenshot).
-      setTimeout(function delayedKillTest() { killTest(frameWindow); }, 1000);
+      setTimeout(async function delayedKillTest() {
+        try {
+          await killTest(frameWindow);
+        } catch(e) {
+          reportError(frameWindow, "Test error: " + e);
+        }
+      }, 1000);
+
 
       if (TestRunner._haltTests)
         return;
     }
 
     setTimeout(TestRunner._checkForHangs, 30000);
   }
 }