node/test/addons/new-context-inspector/test.js
Chengzhong Wu d92ee51aa6
src: expose node::RegisterContext to make a node managed context
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
PR-URL: https://github.com/nodejs/node/pull/62322
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-05-21 13:50:23 +00:00

18 lines
451 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
// This verifies that the addon-created context has an independent
// global object.
{
const ctx = binding.makeContext();
const result = binding.runInContext(ctx, `
globalThis.foo = 'bar';
foo;
`);
assert.strictEqual(result, 'bar');
assert.strictEqual(globalThis.foo, undefined);
}