Skip to content

Commit

Permalink
Add globals available in all supported node versions
Browse files Browse the repository at this point in the history
PR-URL: #109
  • Loading branch information
tshemsedinov committed Jul 31, 2023
1 parent 723a88c commit 1073e2b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions metavm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const EMPTY_CONTEXT = vm.createContext(Object.freeze({}), CONTEXT_OPTIONS);

const COMMON_CONTEXT = vm.createContext(
Object.freeze({
AbortController,
Event,
EventTarget,
MessageChannel,
MessageEvent,
MessagePort,
Buffer,
URL,
URLSearchParams,
Expand Down
18 changes: 18 additions & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ metatests.test('Create common context', async (test) => {
test.strictSame(typeof context, 'object');
test.strictSame(context.console, console);
test.strictSame(context.global, undefined);
test.strictSame(context.AbortController, AbortController);
test.strictSame(context.Buffer, Buffer);
test.strictSame(context.Event, Event);
test.strictSame(context.EventTarget, EventTarget);
test.strictSame(context.MessageChannel, MessageChannel);
test.strictSame(context.MessageEvent, MessageEvent);
test.strictSame(context.MessagePort, MessagePort);
test.strictSame(context.URL, URL);
test.strictSame(context.URLSearchParams, URLSearchParams);
test.strictSame(context.TextDecoder, TextDecoder);
test.strictSame(context.TextEncoder, TextEncoder);
test.strictSame(context.queueMicrotask, queueMicrotask);
test.strictSame(context.setTimeout, setTimeout);
test.strictSame(context.setImmediate, setImmediate);
test.strictSame(context.setInterval, setInterval);
test.strictSame(context.clearTimeout, clearTimeout);
test.strictSame(context.clearImmediate, clearImmediate);
test.strictSame(context.clearInterval, clearInterval);
test.end();
});

Expand Down

0 comments on commit 1073e2b

Please sign in to comment.