node/test/common/globals.js
Chengzhong Wu e6b4d30a2f
src: bootstrap Web [Exposed=*] APIs in the shadow realm
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>
2023-03-16 00:22:06 +08:00

141 lines
2.3 KiB
JavaScript

'use strict';
const intrinsics = new Set([
'Object',
'Function',
'Array',
'Number',
'parseFloat',
'parseInt',
'Infinity',
'NaN',
'undefined',
'Boolean',
'String',
'Symbol',
'Date',
'Promise',
'RegExp',
'Error',
'AggregateError',
'EvalError',
'RangeError',
'ReferenceError',
'SyntaxError',
'TypeError',
'URIError',
'globalThis',
'JSON',
'Math',
'Intl',
'ArrayBuffer',
'Uint8Array',
'Int8Array',
'Uint16Array',
'Int16Array',
'Uint32Array',
'Int32Array',
'Float32Array',
'Float64Array',
'Uint8ClampedArray',
'BigUint64Array',
'BigInt64Array',
'DataView',
'Map',
'BigInt',
'Set',
'WeakMap',
'WeakSet',
'Proxy',
'Reflect',
'ShadowRealm',
'FinalizationRegistry',
'WeakRef',
'decodeURI',
'decodeURIComponent',
'encodeURI',
'encodeURIComponent',
'escape',
'unescape',
'eval',
'isFinite',
'isNaN',
'SharedArrayBuffer',
'Atomics',
'WebAssembly',
]);
if (global.gc) {
intrinsics.add('gc');
}
// v8 exposes console in the global scope.
intrinsics.add('console');
const webIdlExposedWildcard = new Set([
'DOMException',
'TextEncoder',
'TextDecoder',
'AbortController',
'AbortSignal',
'EventTarget',
'Event',
'URL',
'URLSearchParams',
'ReadableStream',
'ReadableStreamDefaultReader',
'ReadableStreamBYOBReader',
'ReadableStreamBYOBRequest',
'ReadableByteStreamController',
'ReadableStreamDefaultController',
'TransformStream',
'TransformStreamDefaultController',
'WritableStream',
'WritableStreamDefaultWriter',
'WritableStreamDefaultController',
'ByteLengthQueuingStrategy',
'CountQueuingStrategy',
'TextEncoderStream',
'TextDecoderStream',
'CompressionStream',
'DecompressionStream',
]);
const webIdlExposedWindow = new Set([
'console',
'BroadcastChannel',
'queueMicrotask',
'structuredClone',
'MessageChannel',
'MessagePort',
'MessageEvent',
'clearInterval',
'clearTimeout',
'setInterval',
'setTimeout',
'atob',
'btoa',
'Blob',
'Performance',
'performance',
'fetch',
'FormData',
'Headers',
'Request',
'Response',
]);
const nodeGlobals = new Set([
'process',
'global',
'Buffer',
'clearImmediate',
'setImmediate',
]);
module.exports = {
intrinsics,
webIdlExposedWildcard,
webIdlExposedWindow,
nodeGlobals,
};