@@ -65,6 +65,16 @@ async function AsyncTestOk() {
6565 promise , module => assertInstanceof ( module , WebAssembly . Module ) ) ;
6666}
6767
68+ async function AsyncTestWithInstantiateOk ( ) {
69+ print ( 'async module instantiate (ok)...' ) ;
70+ % DisallowCodegenFromStrings ( false ) ;
71+ % DisallowWasmCodegen ( false ) ;
72+ let promise = WebAssembly . instantiate ( buffer ) ;
73+ assertPromiseResult (
74+ promise ,
75+ module => assertInstanceof ( module . instance , WebAssembly . Instance ) ) ;
76+ }
77+
6878async function AsyncTestFail ( ) {
6979 print ( 'async module compile (fail)...' ) ;
7080 % DisallowCodegenFromStrings ( true ) ;
@@ -78,6 +88,19 @@ async function AsyncTestFail() {
7888 }
7989}
8090
91+ async function AsyncTestWithInstantiateFail ( ) {
92+ print ( 'async module instantiate (fail)...' ) ;
93+ % DisallowCodegenFromStrings ( true ) ;
94+ % DisallowWasmCodegen ( false ) ;
95+ try {
96+ let m = await WebAssembly . instantiate ( buffer ) ;
97+ assertUnreachable ( ) ;
98+ } catch ( e ) {
99+ print ( " " + e ) ;
100+ assertInstanceof ( e , WebAssembly . CompileError ) ;
101+ }
102+ }
103+
81104async function AsyncTestWasmFail ( disallow_codegen ) {
82105 print ( 'async wasm module compile (fail)...' ) ;
83106 % DisallowCodegenFromStrings ( disallow_codegen ) ;
@@ -91,6 +114,19 @@ async function AsyncTestWasmFail(disallow_codegen) {
91114 }
92115}
93116
117+ async function AsyncTestWasmWithInstantiateFail ( disallow_codegen ) {
118+ print ( 'async wasm module instantiate (fail)...' ) ;
119+ % DisallowCodegenFromStrings ( disallow_codegen ) ;
120+ % DisallowWasmCodegen ( true ) ;
121+ try {
122+ let m = await WebAssembly . instantiate ( buffer ) ;
123+ assertUnreachable ( ) ;
124+ } catch ( e ) {
125+ print ( " " + e ) ;
126+ assertInstanceof ( e , WebAssembly . CompileError ) ;
127+ }
128+ }
129+
94130async function StreamingTestOk ( ) {
95131 print ( 'streaming module compile (ok)...' ) ;
96132 // TODO(titzer): compileStreaming must be supplied by embedder.
@@ -149,14 +185,17 @@ async function RunAll() {
149185 await SyncTestOk ( ) ;
150186 await SyncTestFail ( ) ;
151187 await AsyncTestOk ( ) ;
188+ await AsyncTestWithInstantiateOk ( ) ;
152189 await AsyncTestFail ( ) ;
190+ await AsyncTestWithInstantiateFail ( ) ;
153191 await StreamingTestOk ( ) ;
154192 await StreamingTestFail ( ) ;
155193
156194 disallow_codegen = false ;
157195 for ( count = 0 ; count < 2 ; ++ count ) {
158196 SyncTestWasmFail ( disallow_codegen ) ;
159197 AsyncTestWasmFail ( disallow_codegen ) ;
198+ AsyncTestWasmWithInstantiateFail ( disallow_codegen ) ;
160199 StreamingTestWasmFail ( disallow_codegen )
161200 disallow_codegen = true ;
162201 }
0 commit comments