If necessary, fall back to an approximation of WorkerGlobalScope.importScripts
...for --disable-emscripten-proxy-to-pthread, where runUnoScriptUrl is run on the browser main thread Change-Id: I49c44219b7f77bbc8552994fe3e8483ae0e138fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181663 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
@@ -77,9 +77,21 @@ extern "C" void getUnoScriptUrls(std::vector<OUString> * urls) {
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD
|
||||
EM_JS(void, runUnoScriptUrl, (char16_t const * url), {
|
||||
importScripts(UTF16ToString(url));
|
||||
});
|
||||
#else
|
||||
EM_JS(void, runUnoScriptUrl, (char16_t const * url), {
|
||||
fetch(UTF16ToString(url)).then(res => {
|
||||
if (!res.ok) {
|
||||
throw Error(
|
||||
"Loading <" + res.url + "> failed with " + res.status + " " + res.statusText);
|
||||
}
|
||||
return res.blob();
|
||||
}).then(blob => blob.text()).then(text => eval(text));
|
||||
});
|
||||
#endif
|
||||
|
||||
EM_JS(void, setupMainChannel, (), {
|
||||
const orig = self.onmessage;
|
||||
|
||||
Reference in New Issue
Block a user