Repository: denoland/deno
Pull request: feat(ext/web): add performance.clearResourceTimings() and setResourceTimingBufferSize()

## Summary

This PR implements the missing Performance API methods as specified in the [W3C Performance Timeline spec](https://www.w3.org/TR/performance-timeline/#dom-performance-clearresourcetimings):

- `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

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

Closes #13605

Changed files:
filename: cli/tsc/dts/lib.deno.shared_globals.d.ts
patch: @@ -740,6 +740,23 @@ interface Performance extends EventTarget {
   /** Removes stored timestamp with the associated name. */
   clearMeasures(measureName?: string): void;
 
+  /** Removes all performance entries with an entryType of "resource" from the
+   * performance timeline and sets the size of the performance resource data
+   * buffer to zero.
+   *
+   * Note: Deno does not currently track resource timings, so this method has
+   * no observable effect. It is provided for API compatibility.
+   */
+  clearResourceTimings(): void;
+
+  /** Sets the desired size of the browser's resource timing buffer which
+   * stores the "resource" performance entries.
+   *
+   * Note: Deno does not currently track resource timings, so this method has
+   * no observable effect. It is provided for API compatibility.
+   */
+  setResourceTimingBufferSize(maxSize: number): void;
+
   getEntries(): PerformanceEntryList;
   getEntriesByName(name: string, type?: string): PerformanceEntryList;
   getEntriesByType(type: string): PerformanceEntryList;

filename: ext/web/15_performance.js
patch: @@ -418,6 +418,24 @@ class Performance extends EventTarget {
     }
   }
 
+  clearResourceTimings() {
+    webidl.assertBranded(this, PerformancePrototype);
+    performanceEntries = ArrayPrototypeFilter(
+      performanceEntries,
+      (entry) => entry.entryType !== "resource",
+    );
+  }
+
+  setResourceTimingBufferSize(_maxSize) {
+    webidl.assertBranded(this, PerformancePrototype);
+    webidl.requiredArguments(
+      arguments.length,
+      1,
+      "Failed to execute 'setResourceTimingBufferSize' on 'Performance'",
+    );
+    // This is a noop in Deno as we don't have resource timing entries
+  }
+
   getEntries() {
     webidl.assertBranded(this, PerformancePrototype);
     return filterByNameType();

filename: tests/unit/performance_test.ts
patch: @@ -72,6 +72,29 @@ Deno.test(function clearMeasures() {
   performance.clearMarks();
 });
 
+Deno.test(function clearResourceTimings() {
+  // clearResourceTimings should exist and not throw
+  // Since Deno doesn't currently track resource timings, this is effectively a no-op
+  performance.clearResourceTimings();
+  // After clearing, there should be no resource entries
+  assertEquals(performance.getEntriesByType("resource").length, 0);
+});
+
+Deno.test(function setResourceTimingBufferSize() {
+  // setResourceTimingBufferSize should exist and not throw
+  // Since Deno doesn't currently track resource timings, this is effectively a no-op
+  performance.setResourceTimingBufferSize(100);
+  performance.setResourceTimingBufferSize(0);
+  // Verify it requires an argument
+  assertThrows(
+    () => {
+      // @ts-expect-error: testing missing argument
+      performance.setResourceTimingBufferSize();
+    },
+    TypeError,
+  );
+});
+
 Deno.test(function performanceMark() {
   const mark = performance.mark("test");
   assert(mark instanceof PerformanceMark);

filename: tests/wpt/runner/expectation.json
patch: @@ -15355,7 +15355,6 @@
     "shared-worker-in-data-url-context.window.html": false,
     "worker-performance.worker.html": [
       "Resource timing seems to work in workers",
-      "performance.clearResourceTimings in workers",
       "performance.setResourceTimingBufferSize in workers"
     ],
     "importscripts_mime_local.any.worker.html": [