@@ -4469,7 +4469,17 @@ def test_in_flight_memfile_request(self, args, expected):
44694469 # should happen when there is a mem init file (-O2+)
44704470 self .btest ('in_flight_memfile_request.c' , expected = expected )
44714471
4472- def test_async_compile (self ):
4472+
4473+ @parameterized ({
4474+ '' : ([], 1 ),
4475+ 'O1' : (['-O1' ], 1 ),
4476+ 'O2' : (['-O2' ], 1 ),
4477+ 'O3' : (['-O3' ], 1 ),
4478+ # force it on
4479+ 'force' : (['-sWASM_ASYNC_COMPILATION' ], 1 ),
4480+ 'off' : (['-sWASM_ASYNC_COMPILATION=0' ], 0 ),
4481+ })
4482+ def test_async_compile (self , opts , returncode ):
44734483 # notice when we use async compilation
44744484 script = '''
44754485 <script>
@@ -4478,11 +4488,13 @@ def test_async_compile(self):
44784488 var real_wasm_instantiateStreaming = WebAssembly.instantiateStreaming;
44794489 if (typeof real_wasm_instantiateStreaming === 'function') {
44804490 WebAssembly.instantiateStreaming = (a, b) => {
4491+ console.log('instantiateStreaming called');
44814492 Module.sawAsyncCompilation = true;
44824493 return real_wasm_instantiateStreaming(a, b);
44834494 };
44844495 } else {
44854496 WebAssembly.instantiate = (a, b) => {
4497+ console.log('instantiate called');
44864498 Module.sawAsyncCompilation = true;
44874499 return real_wasm_instantiate(a, b);
44884500 };
@@ -4495,23 +4507,12 @@ def test_async_compile(self):
44954507 </script>
44964508 {{{ SCRIPT }}}
44974509'''
4510+ create_file ('post.js' , 'console.log("post js");' );
44984511 shell_with_script ('shell.html' , 'shell.html' , script )
4499- common_args = ['--shell-file' , 'shell.html' ]
4500- for opts , returncode in [
4501- ([], 1 ),
4502- (['-O1' ], 1 ),
4503- (['-O2' ], 1 ),
4504- (['-O3' ], 1 ),
4505- # force it on
4506- (['-sWASM_ASYNC_COMPILATION' ], 1 ),
4507- # force it off. note that we use -O3 here to make the binary small enough
4508- # for chrome to allow compiling it synchronously
4509- (['-O3' , '-sWASM_ASYNC_COMPILATION=0' ], 0 ),
4510- ]:
4511- print (opts , returncode )
4512- self .btest_exit ('test_async_compile.c' , assert_returncode = returncode , args = common_args + opts )
4512+ common_args = ['--shell-file' , 'shell.html' , '--post-js=post.js' ]
4513+ self .btest_exit ('test_async_compile.c' , assert_returncode = returncode , args = common_args + opts )
45134514 # Ensure that compilation still works and is async without instantiateStreaming available
4514- no_streaming = ' <script> WebAssembly.instantiateStreaming = undefined;</script>'
4515+ no_streaming = '<script>WebAssembly.instantiateStreaming = undefined;</script>'
45154516 shell_with_script ('shell.html' , 'shell.html' , no_streaming + script )
45164517 self .btest_exit ('test_async_compile.c' , assert_returncode = 1 , args = common_args )
45174518
0 commit comments