Add mechanism for an individual mochitest to say it needs a longer timeout. (Bug 527614) r=ted

This commit is contained in:
L. David Baron 2009-11-19 09:35:09 -08:00
parent ece0d0c7d1
commit d0f535b30d
3 changed files with 22 additions and 1 deletions

View File

@ -22,6 +22,7 @@ var iframe = document.getElementById("iframe");
var current_item;
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(3);
for (var prop in gCSSProperties) {
var info = gCSSProperties[prop];

View File

@ -217,6 +217,20 @@ SimpleTest.waitForExplicitFinish = function () {
SimpleTest._stopOnLoad = false;
};
/**
* Multiply the timeout the parent runner uses for this test by the
* given factor.
*
* For example, in a test that may take a long time to complete, using
* "SimpleTest.requestLongerTimeout(5)" will give it 5 times as long to
* finish.
*/
SimpleTest.requestLongerTimeout = function (factor) {
if (parentRunner) {
parentRunner.requestLongerTimeout(factor);
}
}
SimpleTest.waitForFocus_started = false;
SimpleTest.waitForFocus_loaded = false;
SimpleTest.waitForFocus_focused = false;

View File

@ -20,11 +20,12 @@ TestRunner.maxTimeouts = 4; // halt testing after too many timeouts
**/
TestRunner._numTimeouts = 0;
TestRunner._currentTestStartTime = new Date().valueOf();
TestRunner._timeoutFactor = 1;
TestRunner._checkForHangs = function() {
if (TestRunner._currentTest < TestRunner._urls.length) {
var runtime = new Date().valueOf() - TestRunner._currentTestStartTime;
if (runtime >= TestRunner.timeout) {
if (runtime >= TestRunner.timeout * TestRunner._timeoutFactor) {
var frameWindow = $('testframe').contentWindow.wrappedJSObject ||
$('testframe').contentWindow;
frameWindow.SimpleTest.ok(false, "Test timed out.");
@ -50,6 +51,10 @@ TestRunner._checkForHangs = function() {
}
}
TestRunner.requestLongerTimeout = function(factor) {
TestRunner._timeoutFactor = factor;
}
/**
* This function is called after generating the summary.
**/
@ -134,6 +139,7 @@ TestRunner.runNextTest = function() {
$("current-test-path").innerHTML = url;
TestRunner._currentTestStartTime = new Date().valueOf();
TestRunner._timeoutFactor = 1;
if (TestRunner.logEnabled)
TestRunner.logger.log("Running " + url + "...");