Skip to content

Commit fb9aba6

Browse files
marcopiracciniaduh95
authored andcommitted
test: deflake long timer WPTs
type-long-settimeout.any.js and type-long-setinterval.any.js arm setTimeout(assert_unreached, 100) as a guard. Under load it can fire after done(), and the resulting uncaught exception can reach the WPT runner before the completion message, failing the spec. Use a script modifier to clear the guard timer from a completion callback, for these two fixtures only. The guard still fails the test when done() is never called. Signed-off-by: marcopiraccini <marco.piraccini@gmail.com> PR-URL: #63106 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent a1bfb6f commit fb9aba6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎test/wpt/test-timers.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
'use strict';
22

3+
const assert = require('assert');
4+
const { basename } = require('path');
35
const { WPTRunner } = require('../common/wpt');
46

57
const runner = new WPTRunner('html/webappapis/timers', { concurrency: 1 });
68

9+
runner.setScriptModifier((script) => {
10+
if (!['type-long-settimeout.any.js', 'type-long-setinterval.any.js']
11+
.includes(basename(script.filename))) return;
12+
13+
// Cancel the failure timer when the test completes so it cannot throw
14+
// while the runner is still processing the completion message.
15+
const failureTimer = 'setTimeout(assert_unreached, 100);';
16+
assert(script.code.includes(failureTimer), `Unexpected contents of ${script.filename}`);
17+
script.code = script.code.replace(failureTimer,
18+
'const failureTimer = setTimeout(assert_unreached, 100);\n' +
19+
'add_completion_callback(() => clearTimeout(failureTimer));');
20+
});
21+
722
runner.runJsTests();

0 commit comments

Comments
 (0)