Bug 442125: check Date.now() to try to diagnose focus failures. r=ted
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -64,33 +64,34 @@ TestRunner._toggle = function(el) {
el.style.cssText = "width:0px; height:0px; border:0px;";
}
};
/**
* Creates the iframe that contains a test
**/
-TestRunner._makeIframe = function (url, retry) {
+TestRunner._makeIframe = function (url, retry, startTime) {
var iframe = $('testframe');
window.scrollTo(0, $('indicator').offsetTop);
if (url != "about:blank" && (!document.hasFocus() ||
document.activeElement != iframe)) {
// typically calling ourselves from setTimeout is sufficient
// but we'll try focus() just in case that's needed
window.focus();
iframe.focus();
if (retry < 3) {
- window.setTimeout('TestRunner._makeIframe("'+url+'", '+(retry+1)+')', 1000);
+ window.setTimeout('TestRunner._makeIframe("'+url+'", '+(retry+1)+', '+startTime+')', 1000);
return;
}
var frameWindow = $('testframe').contentWindow.wrappedJSObject ||
$('testframe').contentWindow;
- frameWindow.SimpleTest.ok(false, "Unable to restore focus ("+
+ frameWindow.SimpleTest.ok(false, "Unable to restore focus after "+
+ ((Date.now()-startTime)/1000)+" seconds ("+
(document.hasFocus() ? document.activeElement : "[none]")+
"), expect failures and timeouts.");
}
iframe.src = url;
iframe.name = url;
iframe.width = "500";
return iframe;
};
@@ -125,20 +126,20 @@ TestRunner.runNextTest = function() {
$("current-test-path").innerHTML = url;
TestRunner._currentTestStartTime = new Date().valueOf();
if (TestRunner.logEnabled)
TestRunner.logger.log("Running " + url + "...");
- TestRunner._makeIframe(url, 0);
+ TestRunner._makeIframe(url, 0, Date.now());
} else {
$("current-test").innerHTML = "<b>Finished</b>";
- TestRunner._makeIframe("about:blank", 0);
+ TestRunner._makeIframe("about:blank", 0, Date.now());
if (TestRunner.logEnabled) {
TestRunner.logger.log("Passed: " + $("pass-count").innerHTML);
TestRunner.logger.log("Failed: " + $("fail-count").innerHTML);
TestRunner.logger.log("Todo: " + $("todo-count").innerHTML);
TestRunner.logger.log("SimpleTest FINISHED");
}
if (TestRunner.onComplete)
TestRunner.onComplete();