summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/dts/lib.deno.shared_globals.d.ts1
-rw-r--r--cli/tests/unit/performance_test.ts7
-rw-r--r--ext/web/15_performance.js10
-rw-r--r--runtime/js/99_main.js3
-rw-r--r--tools/wpt/expectation.json4
5 files changed, 22 insertions, 3 deletions
diff --git a/cli/dts/lib.deno.shared_globals.d.ts b/cli/dts/lib.deno.shared_globals.d.ts
index 5f44e2d1b..b96c56dba 100644
--- a/cli/dts/lib.deno.shared_globals.d.ts
+++ b/cli/dts/lib.deno.shared_globals.d.ts
@@ -450,6 +450,7 @@ declare class Worker extends EventTarget {
declare type PerformanceEntryList = PerformanceEntry[];
declare class Performance {
+ readonly timeOrigin: number;
constructor();
/** Removes the stored timestamp with the associated name. */
diff --git a/cli/tests/unit/performance_test.ts b/cli/tests/unit/performance_test.ts
index 4c7d08d4e..252a31fc4 100644
--- a/cli/tests/unit/performance_test.ts
+++ b/cli/tests/unit/performance_test.ts
@@ -20,6 +20,13 @@ Deno.test({ permissions: { hrtime: false } }, async function performanceNow() {
assert(totalTime >= 10);
});
+Deno.test(function timeOrigin() {
+ const origin = performance.timeOrigin;
+
+ assert(origin > 0);
+ assert(Date.now() >= origin);
+});
+
Deno.test(function performanceMark() {
const mark = performance.mark("test");
assert(mark instanceof PerformanceMark);
diff --git a/ext/web/15_performance.js b/ext/web/15_performance.js
index 41b40159e..07fa2a01d 100644
--- a/ext/web/15_performance.js
+++ b/ext/web/15_performance.js
@@ -24,6 +24,7 @@
const illegalConstructorKey = Symbol("illegalConstructorKey");
const customInspect = SymbolFor("Deno.customInspect");
let performanceEntries = [];
+ let timeOrigin;
webidl.converters["PerformanceMarkOptions"] = webidl
.createDictionaryConverter(
@@ -77,6 +78,10 @@
return webidl.converters.DOMString(V, opts);
};
+ function setTimeOrigin(origin) {
+ timeOrigin = origin;
+ }
+
function findMostRecent(
name,
type,
@@ -327,6 +332,10 @@
webidl.illegalConstructor();
}
+ get timeOrigin() {
+ return timeOrigin;
+ }
+
clearMarks(markName = undefined) {
webidl.assertBranded(this, PerformancePrototype);
if (markName !== undefined) {
@@ -566,5 +575,6 @@
PerformanceMeasure,
Performance,
performance: webidl.createBranded(Performance),
+ setTimeOrigin,
};
})(this);
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 07a350424..d83a2e6c8 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -9,6 +9,7 @@ delete Object.prototype.__proto__;
const core = Deno.core;
const {
ArrayPrototypeMap,
+ DateNow,
Error,
FunctionPrototypeCall,
FunctionPrototypeBind,
@@ -530,6 +531,7 @@ delete Object.prototype.__proto__;
throw new Error("Worker runtime already bootstrapped");
}
+ performance.setTimeOrigin(DateNow());
const consoleFromV8 = window.console;
const wrapConsole = window.__bootstrap.console.wrapConsole;
@@ -622,6 +624,7 @@ delete Object.prototype.__proto__;
throw new Error("Worker runtime already bootstrapped");
}
+ performance.setTimeOrigin(DateNow());
const consoleFromV8 = window.console;
const wrapConsole = window.__bootstrap.console.wrapConsole;
diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json
index 67e256353..1c402903e 100644
--- a/tools/wpt/expectation.json
+++ b/tools/wpt/expectation.json
@@ -1179,7 +1179,6 @@
"Performance interface: existence and properties of interface object",
"Performance interface: existence and properties of interface prototype object",
"Performance interface: attribute timeOrigin",
- "Performance interface: performance must inherit property \"timeOrigin\" with the proper type",
"Performance interface: default toJSON operation on performance",
"Window interface: attribute performance"
],
@@ -1187,12 +1186,11 @@
"Performance interface: existence and properties of interface object",
"Performance interface: existence and properties of interface prototype object",
"Performance interface: attribute timeOrigin",
- "Performance interface: performance must inherit property \"timeOrigin\" with the proper type",
"Performance interface: default toJSON operation on performance",
"WorkerGlobalScope interface: attribute performance",
"WorkerGlobalScope interface: self must inherit property \"performance\" with the proper type"
],
- "window-worker-timeOrigin.window.html": false,
+ "window-worker-timeOrigin.window.html": true,
"idlharness-shadowrealm.window.html": false
},
"streams": {