Skip to content

Commit

Permalink
Remove WASM endowment factory (#459)
Browse files Browse the repository at this point in the history
Node landed `WebAssembly.compileStreaming` and `instantiateStreaming` in nodejs/node#42701 and made it available in Node 18, so we no longer need to exclude these properties from our WebAssembly endowment. This PR therefore removes the WebAssembly endowment factory, which will now be included in whatever form it exists on the execution environment root realm global.
  • Loading branch information
rekmarks committed May 14, 2022
1 parent 31e1556 commit def4667
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 75 deletions.
6 changes: 3 additions & 3 deletions packages/execution-environments/jest.config.js
Expand Up @@ -7,9 +7,9 @@ module.exports = {
coverageThreshold: {
global: {
branches: 34.69,
functions: 38.89,
lines: 34.62,
statements: 34.98,
functions: 35.29,
lines: 32,
statements: 32.41,
},
},
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
Expand Down
Expand Up @@ -27,13 +27,13 @@ describe('createEndowments', () => {

it('handles factory endowments', () => {
const mockWallet = { foo: Symbol('bar') };
const { endowments } = createEndowments(mockWallet as any, ['WebAssembly']);
const { endowments } = createEndowments(mockWallet as any, ['setTimeout']);

expect(endowments).toStrictEqual({
wallet: mockWallet,
WebAssembly: expect.objectContaining(WebAssembly),
setTimeout: expect.any(Function),
});
expect(endowments.WebAssembly).not.toBe(WebAssembly);
expect(endowments.setTimeout).not.toBe(setTimeout);
});

it('handles some endowments from the same factory', () => {
Expand Down Expand Up @@ -80,17 +80,17 @@ describe('createEndowments', () => {
Math,
setTimeout: expect.any(Function),
clearTimeout: expect.any(Function),
WebAssembly: { ...WebAssembly },
WebAssembly,
});

expect(endowments.wallet).toBe(mockWallet);
expect(endowments.Buffer).toBe(Buffer);
expect(endowments.Math).toBe(Math);
expect(endowments.console).toBe(console);
expect(endowments.Math).toBe(Math);
expect(endowments.WebAssembly).toBe(WebAssembly);

expect(endowments.clearTimeout).not.toBe(clearTimeout);
expect(endowments.setTimeout).not.toBe(setTimeout);
expect(endowments.WebAssembly).not.toBe(WebAssembly);
});

it('throws for unknown endowments', () => {
Expand Down
Expand Up @@ -3,7 +3,6 @@ import { rootRealmGlobal } from '../globalObject';
import buffer from './buffer';
import timeout from './timeout';
import interval from './interval';
import wasm from './wasm';

type EndowmentFactoryResult = {
teardownFunction?: () => void;
Expand All @@ -15,7 +14,7 @@ type EndowmentFactoryResult = {
* the same factory function, but we only call each factory once for each snap.
* See {@link createEndowments} for details.
*/
const endowmentFactories = [buffer, timeout, interval, wasm].reduce(
const endowmentFactories = [buffer, timeout, interval].reduce(
(factories, builder) => {
builder.names.forEach((name) => {
factories.set(name, builder.factory);
Expand Down
30 changes: 0 additions & 30 deletions packages/execution-environments/src/common/endowments/wasm.test.ts

This file was deleted.

34 changes: 0 additions & 34 deletions packages/execution-environments/src/common/endowments/wasm.ts

This file was deleted.

0 comments on commit def4667

Please sign in to comment.