@@ -4469,7 +4469,17 @@ def test_in_flight_memfile_request(self, args, expected):
4469
4469
# should happen when there is a mem init file (-O2+)
4470
4470
self .btest ('in_flight_memfile_request.c' , expected = expected )
4471
4471
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 ):
4473
4483
# notice when we use async compilation
4474
4484
script = '''
4475
4485
<script>
@@ -4478,11 +4488,13 @@ def test_async_compile(self):
4478
4488
var real_wasm_instantiateStreaming = WebAssembly.instantiateStreaming;
4479
4489
if (typeof real_wasm_instantiateStreaming === 'function') {
4480
4490
WebAssembly.instantiateStreaming = (a, b) => {
4491
+ console.log('instantiateStreaming called');
4481
4492
Module.sawAsyncCompilation = true;
4482
4493
return real_wasm_instantiateStreaming(a, b);
4483
4494
};
4484
4495
} else {
4485
4496
WebAssembly.instantiate = (a, b) => {
4497
+ console.log('instantiate called');
4486
4498
Module.sawAsyncCompilation = true;
4487
4499
return real_wasm_instantiate(a, b);
4488
4500
};
@@ -4495,23 +4507,12 @@ def test_async_compile(self):
4495
4507
</script>
4496
4508
{{{ SCRIPT }}}
4497
4509
'''
4510
+ create_file ('post.js' , 'console.log("post js");' );
4498
4511
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 )
4513
4514
# 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>'
4515
4516
shell_with_script ('shell.html' , 'shell.html' , no_streaming + script )
4516
4517
self .btest_exit ('test_async_compile.c' , assert_returncode = 1 , args = common_args )
4517
4518
0 commit comments