Is there any way I can access the chrome.* apis (specifically chrome.history
) from a Web Worker?
If I pass the chrome.history or chrome object in with postMessage
, it is not working because of a conversion error to Transferable
type.
I can successfully query the history from my extension and pass the results, but I would like to leave the heavy lifting to the worker instead of the main thread and then pass the results.
Web Workers are meant to be light-weight, and do not inherit any permissions (not even host permissions) from the extension (besides, chrome
is not even defined in a Web worker).
If you're doing really heavy stuff with the results of the chrome.history
API, then you could pass the result of a callback to a worker for processing (with Transferables, the overhead is minimal). Before doing that, make sure that you profile whether the performance impact is really that significant to warrant implementing anything like this.