I want to use web workers in a javascript code module that load code from a blob. Typically this could be done in a webpage by calling "window.URL.createObjectURL" on the blob and giving the url generated by createObjectURL to the worker. Is this possible in a javascript code module, despite there being no window.URL object?
Asked
Active
Viewed 258 times
1 Answers
2
You can import the URL constructor
Components.utils.importGlobalProperties(['URL']);

paa
- 5,048
- 1
- 18
- 22
-
Thank you! This seems to have worked. Is Components.utils.importGlobalProperties documented anywhere? – Paul Apr 11 '14 at 21:39
-
1I don't think so. The properties supported are `indexedDB`, `XMLHttpRequest`, `TextEncoder`, `TextDecoder`, `URL`, `atob` and `btoa`. – paa Apr 12 '14 at 10:15
-
Since what version of Firefox is this supported? I was also trying to use `createObjectURL` and came across this post. Is this the only way to get to createObjectURL and revokeObjectURL? – Noitidart Oct 31 '14 at 06:29
-
1@Noitidart importGlobalProperties is available since Gecko 27. AFAIK the methods you mention are not accessible otherwise. – paa Oct 31 '14 at 14:01
-
Cool thanks man, URL.createObjectUrl was available to window scope before 27 though right? – Noitidart Oct 31 '14 at 16:31
-
1@Noitidart yes, but [not that much](https://developer.mozilla.org/en-US/docs/Web/API/URL.URL#Browser_compatibility) – paa Oct 31 '14 at 18:45
-
Oh cool it started in FF26, how would people accomplish this prior to FF26? just curuious now, i dont have an application for it. – Noitidart Oct 31 '14 at 19:29