Can a WebWorker access the localStorage?
If not why not? Is it problematic from a security stand point?
Web workers only have access to the following:
XMLHttpRequest
navigator
location
setTimeout
clearTimeout
setInterval
clearInterval
Performance
mark
measure
now
caniuse?
IndexedDB
importScripts
JSON
Worker
The window or parent objects are not accessible from a Web worker therefore you can't access the localStorage.
localStorage
To communicate between window and the workerglobalscope you may use postMessage() function and onmessage event.
workerglobalscope
postMessage()
onmessage
Accessing the DOM and window would not be thread safe, since the child thread would have the same privileges as its parent.
1.4m articles
1.4m replys
5 comments
57.0k users