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
objectlocation
objectsetTimeout
methodclearTimeout
methodsetInterval
methodclearInterval
methodPerformance
object (mark
,measure
,now
methods: caniuse?
)IndexedDB
API (see: caniuse?
)importScripts
methodJSON
Worker
The window or parent objects are not accessible from a Web worker therefore you can't access the localStorage
.
To communicate between window and the workerglobalscope
you may use postMessage()
function and onmessage
event.
Accessing the DOM and window would not be thread safe, since the child thread would have the same privileges as its parent.