Skip to content

Commit

Permalink
Merge pull request web-platform-tests#70 from w3c/jgraham/force_timeout
Browse files Browse the repository at this point in the history
Add a force_timeout function to tests.
  • Loading branch information
jgraham committed Apr 17, 2014
2 parents 3f1aa35 + 6768f70 commit f448d6f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ policies and contribution forms [3].
* to the longer test timeout, the test must specify a meta element:
* <meta name="timeout" content="long">
*
* Occasionally tests may have a race between the harness timing out and
* a particular test failing; typically when the test waits for some event
* that never occurs. In this case it is possible to use test.force_timeout()
* in place of assert_unreached(), to immediately fail the test but with a
* status of "timeout". This should only be used as a last resort when it is
* not possible to make the test reliable in some other way.
*
* == Setup ==
*
* Sometimes tests require non-trivial setup that may fail. For this purpose
Expand Down Expand Up @@ -1214,6 +1221,11 @@ policies and contribution forms [3].
this.cleanup_callbacks.push(callback);
};

Test.prototype.force_timeout = function() {
this.set_status(this.TIMEOUT);
this.phase = this.phases.HAS_RESULT;
}

Test.prototype.set_timeout = function()
{
if (this.timeout_length !== null) {
Expand Down

0 comments on commit f448d6f

Please sign in to comment.