Skip to content

Commit

Permalink
Fix URL created for worker JS file import and change test to test it
Browse files Browse the repository at this point in the history
  • Loading branch information
Twinklebear committed Jun 29, 2024
1 parent 34c1aa3 commit f95b7b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,13 @@ var LibraryPThread = {
var p = trustedTypes.createPolicy(
'emscripten#workerPolicy1',
{
createScriptURL: (ignored) => new URL(import.meta.url)
createScriptURL: (ignored) => new URL("{{{ TARGET_JS_NAME }}}", import.meta.url)
}
);
worker = new Worker(p.createScriptURL('ignored'), workerOptions);
} else
#endif
worker = new Worker(new URL(import.meta.url), workerOptions);
worker = new Worker(new URL("{{{ TARGET_JS_NAME }}}", import.meta.url), workerOptions);
#else
var pthreadMainJs = _scriptName;
#if expectToReceiveOnModule('mainScriptUrlOrBlob')
Expand Down
2 changes: 1 addition & 1 deletion test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ def add_on_exit(self, code):
# libraries, for example
def get_emcc_args(self, main_file=False, compile_only=False, asm_only=False):
def is_ldflag(f):
return any(f.startswith(s) for s in ['-sEXPORT_ES6', '-sPROXY_TO_PTHREAD', '-sENVIRONMENT=', '--pre-js=', '--post-js='])
return any(f.startswith(s) for s in ['-sEXPORT_ES6', '-sPROXY_TO_PTHREAD', '-sENVIRONMENT=', '--pre-js=', '--post-js=', '-sPTHREAD_POOL_SIZE='])

args = self.serialize_settings(compile_only or asm_only) + self.emcc_args
if asm_only:
Expand Down
4 changes: 2 additions & 2 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5548,13 +5548,13 @@ def test_error_reporting(self):
def test_webpack(self, es6):
if es6:
shutil.copytree(test_file('webpack_es6'), 'webpack')
self.emcc_args += ['-sEXPORT_ES6']
self.emcc_args += ['-sEXPORT_ES6', '-pthread', '-sPTHREAD_POOL_SIZE=1']
outfile = 'src/hello.mjs'
else:
shutil.copytree(test_file('webpack'), 'webpack')
outfile = 'src/hello.js'
with utils.chdir('webpack'):
self.compile_btest('hello_world.c', ['-sEXIT_RUNTIME', '-sMODULARIZE', '-sENVIRONMENT=web', '-o', outfile])
self.compile_btest('hello_world.c', ['-sEXIT_RUNTIME', '-sMODULARIZE', '-sENVIRONMENT=web,worker', '-o', outfile])
self.run_process(shared.get_npm_cmd('webpack') + ['--mode=development', '--no-devtool'])
shutil.copyfile('webpack/src/hello.wasm', 'webpack/dist/hello.wasm')
self.run_browser('webpack/dist/index.html', '/report_result?exit:0')
Expand Down

0 comments on commit f95b7b9

Please sign in to comment.