summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/dts/lib.deno.shared_globals.d.ts2
-rw-r--r--cli/tests/unit/performance_test.ts13
-rw-r--r--ext/web/15_performance.js18
-rw-r--r--tools/wpt/expectation.json8
4 files changed, 30 insertions, 11 deletions
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"));
+ });
+});
diff --git a/ext/web/15_performance.js b/ext/web/15_performance.js
index 10e014008..e7eafd533 100644
--- a/ext/web/15_performance.js
+++ b/ext/web/15_performance.js
@@ -327,9 +327,14 @@
}
webidl.configurePrototype(PerformanceMeasure);
const PerformanceMeasurePrototype = PerformanceMeasure.prototype;
- class Performance {
- constructor() {
- webidl.illegalConstructor();
+ class Performance extends EventTarget {
+ constructor(key = null) {
+ if (key != illegalConstructorKey) {
+ webidl.illegalConstructor();
+ }
+
+ super();
+ this[webidl.brand] = webidl.brand;
}
get timeOrigin() {
@@ -572,12 +577,17 @@
webidl.configurePrototype(Performance);
const PerformancePrototype = Performance.prototype;
+ webidl.converters["Performance"] = webidl.createInterfaceConverter(
+ "Performance",
+ PerformancePrototype,
+ );
+
window.__bootstrap.performance = {
PerformanceEntry,
PerformanceMark,
PerformanceMeasure,
Performance,
- performance: webidl.createBranded(Performance),
+ performance: new Performance(illegalConstructorKey),
setTimeOrigin,
};
})(this);
diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json
index e3e87a44c..c3f6b19f3 100644
--- a/tools/wpt/expectation.json
+++ b/tools/wpt/expectation.json
@@ -1161,12 +1161,8 @@
"hr-time": {
"monotonic-clock.any.html": true,
"monotonic-clock.any.worker.html": true,
- "basic.any.html": [
- "Performance interface extends EventTarget."
- ],
- "basic.any.worker.html": [
- "Performance interface extends EventTarget."
- ],
+ "basic.any.html": true,
+ "basic.any.worker.html": true,
"idlharness.any.html": [
"Performance interface: existence and properties of interface object",
"Performance interface: existence and properties of interface prototype object",