Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
marcopiraccini committed Sep 19, 2026
commit e5f48b41f2bb4bb5d1a22c5edeb19ce93c390878
15 changes: 15 additions & 0 deletions test/wpt/test-timers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
'use strict';

const assert = require('assert');
const { basename } = require('path');
const { WPTRunner } = require('../common/wpt');

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

runner.setScriptModifier((script) => {
if (!['type-long-settimeout.any.js', 'type-long-setinterval.any.js']
.includes(basename(script.filename))) return;

// Cancel the failure timer when the test completes so it cannot throw
// while the runner is still processing the completion message.
const failureTimer = 'setTimeout(assert_unreached, 100);';
assert(script.code.includes(failureTimer), `Unexpected contents of ${script.filename}`);
script.code = script.code.replace(failureTimer,
'const failureTimer = setTimeout(assert_unreached, 100);\n' +
'add_completion_callback(() => clearTimeout(failureTimer));');
});

runner.runJsTests();
Loading