From 4e6da8890c6f7eb2a022ce86395999c350f7002f Mon Sep 17 00:00:00 2001 From: JW Wang Date: Fri, 3 Nov 2017 11:16:30 +0800 Subject: [PATCH] Bug 1414706 - dump debug info immediately when a test times out. r=jya 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 --HG-- extra : rebase_source : ee5d20c3ab605568e7fe895f14b8e9468fffd5ab extra : source : 1288e105a94ac05fc3a978b7287dd45ecdfb6e8d --- dom/media/test/manifest.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/dom/media/test/manifest.js b/dom/media/test/manifest.js index 35668abdc8752..bd5331fd6900d 100644 --- a/dom/media/test/manifest.js +++ b/dom/media/test/manifest.js @@ -1630,8 +1630,6 @@ function MediaTestManager() { // 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(); @@ -1683,10 +1681,10 @@ function MediaTestManager() { 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. @@ -1752,9 +1750,6 @@ function MediaTestManager() { if (this.onFinished) { this.onFinished(); } - if (this.hasTimeout) { - dumpDebugInfo(); - } var onCleanup = () => { var end = new Date(); SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)"); @@ -1789,6 +1784,20 @@ 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();