Skip to content

Commit 574a119

Browse files
committed
Fix browser.test_modularize
1 parent 3c0ce96 commit 574a119

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/preamble.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,12 @@ var wasmBinaryFile;
595595
if (Module['locateFile']) {
596596
#endif
597597
wasmBinaryFile = '{{{ WASM_BINARY_FILE }}}';
598+
#if !SINGLE_FILE
598599
if (!isDataURI(wasmBinaryFile)) {
599600
wasmBinaryFile = locateFile(wasmBinaryFile);
600601
}
602+
#endif
603+
601604
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`.
602605
} else {
603606
#if ENVIRONMENT_MAY_BE_SHELL
@@ -612,11 +615,12 @@ if (Module['locateFile']) {
612615

613616
#if SINGLE_FILE && SINGLE_FILE_BINARY_ENCODE
614617
function binaryDecode(bin) { for(var i=0,l=bin.length,o=new Uint8Array(l);i<l;++i) o[i]=bin.charCodeAt(i)-1; return o; }
618+
wasmBinaryFile = binaryDecode(wasmBinaryFile);
615619
#endif
616620

617621
function getBinarySync(file) {
618622
#if SINGLE_FILE && SINGLE_FILE_BINARY_ENCODE
619-
return binaryDecode(file);
623+
return file;
620624
#else
621625
if (file == wasmBinaryFile && wasmBinary) {
622626
return new Uint8Array(wasmBinary);

test/test_browser.py

+2
Original file line numberDiff line numberDiff line change
@@ -3480,10 +3480,12 @@ def test_modularize(self):
34803480
# this test is synchronous, so avoid async startup due to wasm features
34813481
self.compile_btest('browser_test_hello_world.c', ['-sMODULARIZE', '-sSINGLE_FILE'] + args + opts)
34823482
create_file('a.html', '''
3483+
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"></head><body>
34833484
<script src="a.out.js"></script>
34843485
<script>
34853486
%s
34863487
</script>
3488+
</body></html>
34873489
''' % code)
34883490
self.run_browser('a.html', '/report_result?0')
34893491

0 commit comments

Comments
 (0)