@@ -65,6 +65,16 @@ async function AsyncTestOk() {
65
65
promise , module => assertInstanceof ( module , WebAssembly . Module ) ) ;
66
66
}
67
67
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
+
68
78
async function AsyncTestFail ( ) {
69
79
print ( 'async module compile (fail)...' ) ;
70
80
% DisallowCodegenFromStrings ( true ) ;
@@ -78,6 +88,19 @@ async function AsyncTestFail() {
78
88
}
79
89
}
80
90
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
+
81
104
async function AsyncTestWasmFail ( disallow_codegen ) {
82
105
print ( 'async wasm module compile (fail)...' ) ;
83
106
% DisallowCodegenFromStrings ( disallow_codegen ) ;
@@ -91,6 +114,19 @@ async function AsyncTestWasmFail(disallow_codegen) {
91
114
}
92
115
}
93
116
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
+
94
130
async function StreamingTestOk ( ) {
95
131
print ( 'streaming module compile (ok)...' ) ;
96
132
// TODO(titzer): compileStreaming must be supplied by embedder.
@@ -149,14 +185,17 @@ async function RunAll() {
149
185
await SyncTestOk ( ) ;
150
186
await SyncTestFail ( ) ;
151
187
await AsyncTestOk ( ) ;
188
+ await AsyncTestWithInstantiateOk ( ) ;
152
189
await AsyncTestFail ( ) ;
190
+ await AsyncTestWithInstantiateFail ( ) ;
153
191
await StreamingTestOk ( ) ;
154
192
await StreamingTestFail ( ) ;
155
193
156
194
disallow_codegen = false ;
157
195
for ( count = 0 ; count < 2 ; ++ count ) {
158
196
SyncTestWasmFail ( disallow_codegen ) ;
159
197
AsyncTestWasmFail ( disallow_codegen ) ;
198
+ AsyncTestWasmWithInstantiateFail ( disallow_codegen ) ;
160
199
StreamingTestWasmFail ( disallow_codegen )
161
200
disallow_codegen = true ;
162
201
}
0 commit comments