1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/node): Define performance.timeOrigin as getter property (#19714)

This commit is contained in:
await-ovo 2023-07-05 01:19:18 +08:00 committed by GitHub
parent a3986b641c
commit 686ec85f52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View file

@ -1,7 +1,10 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import * as perfHooks from "node:perf_hooks";
import { performance } from "node:perf_hooks";
import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
import {
assertEquals,
assertThrows,
} from "../../../test_util/std/testing/asserts.ts";
Deno.test({
name: "[perf_hooks] performance",
@ -39,3 +42,14 @@ Deno.test({
assertEquals<unknown>(perfHooks.PerformanceEntry, PerformanceEntry);
},
});
Deno.test({
name: "[perf_hooks] performance.timeOrigin",
fn() {
assertEquals(typeof performance.timeOrigin, "number");
assertThrows(() => {
// @ts-expect-error: Cannot assign to 'timeOrigin' because it is a read-only property
performance.timeOrigin = 1;
});
},
});

View file

@ -54,8 +54,10 @@ const performance:
nodeTiming: {},
now: () => shimPerformance.now(),
timerify: () => notImplemented("timerify from performance"),
get timeOrigin() {
// deno-lint-ignore no-explicit-any
timeOrigin: (shimPerformance as any).timeOrigin,
return (shimPerformance as any).timeOrigin;
},
markResourceTiming: () => {},
// @ts-ignore waiting on update in `deno`, but currently this is
// a circular dependency