mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

According to https://html.spec.whatwg.org/#environment-settings-object, the timeOrigin is a per-environment value. Worker's timeOrigin is the time when the worker is created. PR-URL: https://github.com/nodejs/node/pull/43781 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
21 lines
564 B
JavaScript
21 lines
564 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
const w = new Worker(`
|
|
require('worker_threads').parentPort.postMessage(performance.timeOrigin);
|
|
`, { eval: true });
|
|
|
|
w.on('message', common.mustCall((timeOrigin) => {
|
|
// Worker is created after this main context, it's
|
|
// `performance.timeOrigin` must be greater than this
|
|
// main context's.
|
|
assert.ok(timeOrigin > performance.timeOrigin);
|
|
}));
|
|
|
|
w.on('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 0);
|
|
}));
|