From 95312ab53a3a118955278a27a0297a17889ad36e Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 11 May 2022 21:15:54 -0400 Subject: fix: make Performance global an EventTarget This commit updates the Performance global to extend EventTarget. --- cli/dts/lib.deno.shared_globals.d.ts | 2 +- cli/tests/unit/performance_test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'cli') diff --git a/cli/dts/lib.deno.shared_globals.d.ts b/cli/dts/lib.deno.shared_globals.d.ts index d430c16b0..efd59ca2e 100644 --- a/cli/dts/lib.deno.shared_globals.d.ts +++ b/cli/dts/lib.deno.shared_globals.d.ts @@ -449,7 +449,7 @@ declare class Worker extends EventTarget { declare type PerformanceEntryList = PerformanceEntry[]; -declare class Performance { +declare class Performance extends EventTarget { /** Returns a timestamp representing the start of the performance measurement. */ readonly timeOrigin: number; constructor(); diff --git a/cli/tests/unit/performance_test.ts b/cli/tests/unit/performance_test.ts index 917546e2c..687bb024d 100644 --- a/cli/tests/unit/performance_test.ts +++ b/cli/tests/unit/performance_test.ts @@ -140,3 +140,16 @@ Deno.test(function performanceMeasureIllegalConstructor() { "Illegal constructor", ); }); + +Deno.test(function performanceIsEventTarget() { + assert(performance instanceof EventTarget); + + return new Promise((resolve) => { + const handler = () => { + resolve(); + }; + + performance.addEventListener("test", handler, { once: true }); + performance.dispatchEvent(new Event("test")); + }); +}); -- cgit v1.2.3