diff --git a/test/wasi/test-wasi-start-validation.js b/test/wasi/test-wasi-start-validation.js new file mode 100644 index 00000000000000..80fc035d7c9826 --- /dev/null +++ b/test/wasi/test-wasi-start-validation.js @@ -0,0 +1,31 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const { WASI } = require('wasi'); + +const fixtures = require('../common/fixtures'); + +{ + const wasi = new WASI(); + assert.throws( + () => { + wasi.start(); + }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Instance\b/ } + ); +} + +{ + const wasi = new WASI({}); + (async () => { + const bufferSource = fixtures.readSync('simple.wasm'); + const wasm = await WebAssembly.compile(bufferSource); + const instance = await WebAssembly.instantiate(wasm); + + assert.throws( + () => { wasi.start(instance); }, + { code: 'ERR_INVALID_ARG_TYPE', message: /\bWebAssembly\.Memory\b/ } + ); + })(); +}