aboutsummaryrefslogtreecommitdiff
path: root/test/addons/dlopen-ping-pong/test-worker.js
blob: d24bd2df8050f2cec2eaa70143ce084061b4a7c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
const common = require('../../common');

if (common.isWindows)
  common.skip('dlopen global symbol loading is not supported on this os.');

const assert = require('assert');
const { Worker } = require('worker_threads');

// Check that modules that are not declared as context-aware cannot be re-loaded
// from workers.

const bindingPath = require.resolve(`./build/${common.buildType}/binding`);
require(bindingPath);

new Worker(`require(${JSON.stringify(bindingPath)})`, { eval: true })
  .on('error', common.mustCall((err) => {
    assert.strictEqual(err.constructor, Error);
    assert.strictEqual(err.message,
                       `Module did not self-register: '${bindingPath}'.`);
  }));