emscripten-core / emscripten-core/emscripten
Searching `window.URL` in Web worker context
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Hi there. First of all I am an absolute beginner in emscriptenm, emcc and WebAssembly.
I tried to compilate an [JavascriptSubtitlesOctopus](https://github.com/cawa-93/JavascriptSubtitlesOctopus/tree/826db3acaa5a15561ea53ea9b2654759f6508f01) with the [following parameters](https://github.com/cawa-93/JavascriptSubtitlesOctopus/blob/826db3acaa5a15561ea53ea9b2654759f6508f01/Makefile#L305-L315):
```
-s WASM=1 \
-s BUILD_AS_WORKER=1 \
-s ENVIRONMENT=worker \
```
But in the output JS I still get the following line:
```js
Browser.URLObject = typeof window != "undefined" ? window.URL ? window.URL : window.webkitURL : undefined;
```
Obviously, the variable `window` does not exist in the web worker context. And access to the target `URL` interface can be obtained like `self.URL` or `globalThis.URL`.
Contributor guide
Assessment
This issue has not been assessed yet.