2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-03-04 11:31:14 -05:00
|
|
|
import { unitTest, assert, createResolvable } from "./test_util.ts";
|
2019-02-02 01:27:42 -05:00
|
|
|
|
2020-03-04 11:31:14 -05:00
|
|
|
unitTest({ perms: { hrtime: false } }, async function performanceNow(): Promise<
|
|
|
|
void
|
|
|
|
> {
|
2020-03-03 12:22:53 -05:00
|
|
|
const resolvable = createResolvable();
|
2019-02-02 01:27:42 -05:00
|
|
|
const start = performance.now();
|
2019-04-21 16:40:10 -04:00
|
|
|
setTimeout((): void => {
|
2019-02-02 01:27:42 -05:00
|
|
|
const end = performance.now();
|
|
|
|
assert(end - start >= 10);
|
2020-03-03 12:22:53 -05:00
|
|
|
resolvable.resolve();
|
2019-02-02 01:27:42 -05:00
|
|
|
}, 10);
|
2020-03-03 12:22:53 -05:00
|
|
|
await resolvable;
|
2019-02-02 01:27:42 -05:00
|
|
|
});
|