From 95cb074ed9b88d20a235a8a7b051d57ea707a202 Mon Sep 17 00:00:00 2001 From: Nicholas Paun Date: Thu, 29 Oct 2026 07:42:40 +0000 Subject: [PATCH] Add WPT html/webappapis/timers tests Run the .any.js tests from html/webappapis/timers, which cover setTimeout and setInterval: clearing timers from callbacks, using clearTimeout and clearInterval interchangeably, missing, undefined and negative delays, and ordering of zero-delay timers. All 10 subtests in the 7 enabled files pass, including the two setup({single_test: true}) files that check negative delays. - evil-spec-example.any.js is omitted: it relies on string handlers, which workerd does not support because it disallows eval. - type-long-settimeout.any.js and type-long-setinterval.any.js are disabled because they hang. workerd clamps the delay as a double rather than converting it to a WebIDL long, so 2 ** 32 ms does not wrap to 0 and done() is never called. Co-Authored-By: Claude Opus 5.5 --- src/wpt/BUILD.bazel | 6 ++++++ src/wpt/html/webappapis/timers-test.ts | 30 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/wpt/html/webappapis/timers-test.ts diff --git a/src/wpt/BUILD.bazel b/src/wpt/BUILD.bazel index ee1f9aac7aa..6f997ca8688 100644 --- a/src/wpt/BUILD.bazel +++ b/src/wpt/BUILD.bazel @@ -271,3 +271,9 @@ wpt_test( extra_wpt_directories = ["@wpt//:fetch/data-urls@module"], wpt_directory = "@wpt//:html/webappapis/atob@module", ) + +wpt_test( + name = "html/webappapis/timers", + config = "html/webappapis/timers-test.ts", + wpt_directory = "@wpt//:html/webappapis/timers@module", +) diff --git a/src/wpt/html/webappapis/timers-test.ts b/src/wpt/html/webappapis/timers-test.ts new file mode 100644 index 00000000000..9e708cd4eb3 --- /dev/null +++ b/src/wpt/html/webappapis/timers-test.ts @@ -0,0 +1,30 @@ +// Copyright (c) 2017-2026 Cloudflare, Inc. +// Licensed under the Apache 2.0 license found in the LICENSE file or at: +// https://opensource.org/licenses/Apache-2.0 + +import { type TestRunnerConfig } from 'harness/harness'; + +export default { + 'clearinterval-from-callback.any.js': {}, + 'cleartimeout-clearinterval.any.js': {}, + 'evil-spec-example.any.js': { + comment: + 'Passes a non-function handler, which WebIDL stringifies and evaluates as code. workerd does not support string handlers because it disallows eval; setTimeout throws a TypeError at the top level.', + omittedTests: true, + }, + 'missing-timeout-setinterval.any.js': {}, + 'negative-setinterval.any.js': {}, + 'negative-settimeout.any.js': {}, + 'setinterval-settimeout-clamping.any.js': {}, + 'type-long-setinterval.any.js': { + comment: + 'Hangs: workerd takes the setInterval delay as a double instead of converting it to a WebIDL long, so a delay of 2 ** 32 waits about 49 days instead of wrapping to 0. done() is never called, so the single test never completes.', + disabledTests: true, + }, + 'type-long-settimeout.any.js': { + comment: + 'Hangs: workerd takes the setTimeout delay as a double instead of converting it to a WebIDL long, so a delay of 2 ** 32 waits about 49 days instead of wrapping to 0. done() is never called, so the single test never completes.', + disabledTests: true, + }, + 'zero-settimeout.any.js': {}, +} satisfies TestRunnerConfig;