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:
parent
a3986b641c
commit
686ec85f52
2 changed files with 19 additions and 3 deletions
|
@ -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;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue