Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

This PR implements the missing Performance API methods as specified in the W3C Performance Timeline spec:

  • clearResourceTimings(): Removes all performance entries with an entryType of "resource" from the performance timeline
  • setResourceTimingBufferSize(maxSize): Sets the desired size of the browser's resource timing buffer

Both methods are implemented as no-ops since Deno doesn't currently track resource timing entries, but they are provided for web compatibility.

Changes

  • ext/web/15_performance.js: Added clearResourceTimings() and setResourceTimingBufferSize() methods to the Performance class
  • cli/tsc/dts/lib.deno.shared_globals.d.ts: Added TypeScript type definitions for both methods
  • tests/unit/performance_test.ts: Added unit tests for both methods

Test plan

  • Added tests for clearResourceTimings() - verifies method exists and doesn't throw
  • Added tests for setResourceTimingBufferSize() - verifies method exists, accepts a size parameter, and throws when called without arguments

Closes #13605

…ngBufferSize()

Implements the missing Performance API methods as specified in the W3C
Performance Timeline spec:

- clearResourceTimings(): Removes all "resource" type entries from the
  performance timeline
- setResourceTimingBufferSize(maxSize): Sets the buffer size for resource
  timing entries

Both methods are implemented as no-ops since Deno doesn't currently track
resource timing entries, but they are provided for web compatibility.

Closes denoland#13605
@CLAassistant
Copy link

CLAassistant commented Dec 14, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Dec 14, 2025

Walkthrough

Added two methods to the Performance API: clearResourceTimings() (removes entries with entryType === "resource") and setResourceTimingBufferSize(maxSize) (performs argument validation but is a no-op in this environment). TypeScript declarations and JavaScript implementations were updated, unit tests for both methods were added, and a WPT expectation referring to performance.clearResourceTimings in workers was removed.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—adding two Performance API methods (clearResourceTimings and setResourceTimingBufferSize) to Deno.
Description check ✅ Passed The description clearly explains what was implemented, why (web compatibility), which files were changed, and testing approach—all related to the changeset.
Linked Issues check ✅ Passed The PR implements clearResourceTimings() and setResourceTimingBufferSize() as requested in issue #13605, providing web-compatible Performance API methods per W3C spec.
Out of Scope Changes check ✅ Passed All changes directly support the objective of adding two Performance API methods—type definitions, implementation, unit tests, and test expectation updates are in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 367b7e7 and 3a93c6c.

📒 Files selected for processing (1)
  • tests/wpt/runner/expectation.json (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/wpt/runner/expectation.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: test release linux-x86_64
  • GitHub Check: bench release linux-x86_64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: lint debug linux-x86_64
  • GitHub Check: build libs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
ext/web/15_performance.js (1)

429-437: Add argument type validation for consistency.

While this is a no-op, the method should still validate the argument type to match the spec and maintain consistency with other methods in this file (e.g., clearMarks, getEntriesByName).

Apply this diff:

 setResourceTimingBufferSize(_maxSize) {
   webidl.assertBranded(this, PerformancePrototype);
+  const prefix = "Failed to execute 'setResourceTimingBufferSize' on 'Performance'";
   webidl.requiredArguments(
     arguments.length,
     1,
-    "Failed to execute 'setResourceTimingBufferSize' on 'Performance'",
+    prefix,
   );
+  _maxSize = webidl.converters["unsigned long"](
+    _maxSize,
+    prefix,
+    "Argument 1",
+  );
   // This is a noop in Deno as we don't have resource timing entries
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d17ae8c and 367b7e7.

📒 Files selected for processing (3)
  • cli/tsc/dts/lib.deno.shared_globals.d.ts (1 hunks)
  • ext/web/15_performance.js (1 hunks)
  • tests/unit/performance_test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js}: For JavaScript runtime debugging, enable V8 inspector with --inspect-brk flag and connect Chrome DevTools to chrome://inspect
Use console.log() for debug prints in JavaScript runtime code

Files:

  • tests/unit/performance_test.ts
  • ext/web/15_performance.js
  • cli/tsc/dts/lib.deno.shared_globals.d.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: build libs
  • GitHub Check: lint debug linux-x86_64
🔇 Additional comments (3)
cli/tsc/dts/lib.deno.shared_globals.d.ts (1)

743-758: LGTM!

The type definitions are correct and clearly document that these methods are no-ops in Deno. The signatures match the Performance API spec.

ext/web/15_performance.js (1)

421-427: LGTM!

The implementation correctly follows the same pattern as clearMarks() and clearMeasures(), filtering out entries by type.

tests/unit/performance_test.ts (1)

75-96: LGTM!

The tests verify the methods exist, don't throw with valid inputs, and enforce argument requirements. This is adequate coverage for no-op compatibility methods.

Now that performance.clearResourceTimings is implemented in workers,
remove it from the expected failures list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext/timers: add performance.clearResourceTimings()

2 participants