Bug 1414706 - dump debug info immediately when a test times out.
For now we dump debug info when the whole test case finishes. However, it
would be harder to relate the debug info to the timed out test when there
are multiple test timeouts.
Note we don't call |this.finished(token)| until v.mozDumpDebugInfo() is done
because |this.finished(token)| might finish the whole test case and clean up
the page which might change the output of v.mozDumpDebugInfo().
MozReview-Commit-ID: BrdZ0EVpaBQ
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -1625,18 +1625,16 @@ const DEBUG_TEST_LOOP_FOREVER = false;
// the token back to the manager. The manager may either start the next run
// or end the mochitest if all the tests are done.
function MediaTestManager() {
// Set a very large timeout to prevent Mochitest timeout.
// Instead MediaTestManager will manage timeout of each test.
SimpleTest.requestLongerTimeout(1000);
- this.hasTimeout = false;
-
// Return how many seconds elapsed since |begin|.
function elapsedTime(begin) {
var end = new Date();
return (end.getTime() - begin.getTime()) / 1000;
}
// Sets up a MediaTestManager to runs through the 'tests' array, which needs
// to be one of, or have the same fields as, the g*Test arrays of tests. Uses
// the user supplied 'startTest' function to initialize the test. This
@@ -1678,20 +1676,20 @@ function MediaTestManager() {
// Registers that the test corresponding to 'token' has been started.
// Don't call more than once per token.
this.started = function(token, handler) {
this.tokens.push(token);
this.numTestsRunning++;
this.handlers[token] = handler;
- var onTimeout = () => {
- this.hasTimeout = true;
+ var onTimeout = async () => {
ok(false, "Test timed out!");
info(`${token} timed out!`);
+ await dumpDebugInfoForToken(token);
this.finished(token);
};
// Default timeout to 180s for each test.
// Call SimpleTest._originalSetTimeout() to bypass the flaky timeout checker.
this.timers[token] = SimpleTest._originalSetTimeout.call(window, onTimeout, 180000);
is(this.numTestsRunning, this.tokens.length,
"[started " + token + " t=" + elapsedTime(this.startTime) + "] Length of array should match number of running tests");
@@ -1747,19 +1745,16 @@ function MediaTestManager() {
!DEBUG_TEST_LOOP_FOREVER &&
this.tokens.length == 0 &&
!this.isShutdown)
{
this.isShutdown = true;
if (this.onFinished) {
this.onFinished();
}
- if (this.hasTimeout) {
- dumpDebugInfo();
- }
var onCleanup = () => {
var end = new Date();
SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)");
SimpleTest.info("Running time: " + elapsedTime(this.startTime) + "s");
SimpleTest.finish();
};
mediaTestCleanup(onCleanup);
return;
@@ -1784,16 +1779,30 @@ function mediaTestCleanup(callback) {
SpecialPowers.exactGC(callback);
}
// B2G emulator and Android 2.3 are condidered slow platforms
function isSlowPlatform() {
return SpecialPowers.Services.appinfo.name == "B2G" || getAndroidVersion() == 10;
}
+async function dumpDebugInfoForToken(token) {
+ for (let v of document.getElementsByTagName("video")) {
+ if (token === v.token) {
+ return v.mozDumpDebugInfo();
+ }
+ }
+ for (let a of document.getElementsByTagName("audio")) {
+ if (token === a.token) {
+ return a.mozDumpDebugInfo();
+ }
+ }
+ return Promise.resolve();
+}
+
function dumpDebugInfo() {
for (var v of document.getElementsByTagName("video")) {
v.mozDumpDebugInfo();
}
for (var a of document.getElementsByTagName("audio")) {
a.mozDumpDebugInfo();
}
}