summaryrefslogtreecommitdiff
path: root/test/parallel/test-perf-hooks-worker-timeorigin.js
blob: b87beb76bb3e19850f094b8d41f27c2fc2536419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'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);
}));