@@ -4197,39 +4197,31 @@ def test_vanilla_html_when_proxying(self, args):
4197
4197
})
4198
4198
def test_async_compile (self , opts , returncode ):
4199
4199
# notice when we use async compilation
4200
- script = '''
4201
- <script>
4200
+ create_file ('pre.js' , '''
4202
4201
// note if we do async compilation
4203
4202
var real_wasm_instantiate = WebAssembly.instantiate;
4204
4203
var real_wasm_instantiateStreaming = WebAssembly.instantiateStreaming;
4205
4204
if (typeof real_wasm_instantiateStreaming === 'function') {
4206
4205
WebAssembly.instantiateStreaming = (a, b) => {
4206
+ err('instantiateStreaming called');
4207
4207
console.log('instantiateStreaming called');
4208
4208
Module.sawAsyncCompilation = true;
4209
4209
return real_wasm_instantiateStreaming(a, b);
4210
4210
};
4211
4211
} else {
4212
4212
WebAssembly.instantiate = (a, b) => {
4213
- console.log ('instantiate called');
4213
+ err ('instantiate called');
4214
4214
Module.sawAsyncCompilation = true;
4215
4215
return real_wasm_instantiate(a, b);
4216
4216
};
4217
4217
}
4218
- // show stderr for the viewer's fun
4219
- err = (x) => {
4220
- out('<<< ' + x + ' >>>');
4221
- console.log(x);
4222
- };
4223
- </script>
4224
- {{{ SCRIPT }}}
4225
- '''
4226
- shell_with_script ('shell.html' , 'shell.html' , script )
4227
- common_args = ['--shell-file' , 'shell.html' ]
4228
- self .btest_exit ('test_async_compile.c' , assert_returncode = returncode , emcc_args = common_args + opts )
4218
+ ''' )
4219
+ self .emcc_args .append ('--pre-js=pre.js' )
4220
+ self .btest_exit ('test_async_compile.c' , assert_returncode = returncode , emcc_args = opts )
4229
4221
# Ensure that compilation still works and is async without instantiateStreaming available
4230
- no_streaming = '<script> WebAssembly.instantiateStreaming = undefined;</script>'
4231
- shell_with_script ( 'shell.html' , 'shell.html' , no_streaming + script )
4232
- self .btest_exit ('test_async_compile.c' , assert_returncode = 1 , emcc_args = common_args )
4222
+ create_file ( 'pre0.js' , ' WebAssembly.instantiateStreaming = undefined;' )
4223
+ self . emcc_args . insert ( 0 , '--pre-js=pre0.js' )
4224
+ self .btest_exit ('test_async_compile.c' , assert_returncode = 1 )
4233
4225
4234
4226
# Test that implementing Module.instantiateWasm() callback works.
4235
4227
@also_with_asan
0 commit comments