mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
e6b4d30a2f
This is the initial work to bootstrap Web interfaces that are defined with extended attributes `[Exposed=*]`. The ShadowRealm instances are garbage-collected once it is unreachable. However, V8 can not infer the reference cycles between the per-realm strong persistent function handles and the realm's context handle. To allow the context to be gc-ed once it is not reachable, the per-realm persistent handles are attached to the context's global object and the persistent handles are set as weak. PR-URL: https://github.com/nodejs/node/pull/46809 Refs: https://github.com/nodejs/node/issues/42528 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
28 lines
646 B
JavaScript
28 lines
646 B
JavaScript
// Flags: --experimental-shadow-realm
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const { intrinsics, webIdlExposedWildcard } = require('../common/globals');
|
|
const assert = require('assert');
|
|
|
|
// Validates APIs exposed on the ShadowRealm globalThis.
|
|
const shadowRealm = new ShadowRealm();
|
|
const itemsStr = shadowRealm.evaluate(`
|
|
(() => {
|
|
return Object.getOwnPropertyNames(globalThis).join(',');
|
|
})();
|
|
`);
|
|
const items = itemsStr.split(',');
|
|
const leaks = [];
|
|
for (const item of items) {
|
|
if (intrinsics.has(item)) {
|
|
continue;
|
|
}
|
|
if (webIdlExposedWildcard.has(item)) {
|
|
continue;
|
|
}
|
|
leaks.push(item);
|
|
}
|
|
|
|
assert.deepStrictEqual(leaks, []);
|