How to access Chrome API in Web Worker?

1.4k Views Asked by At

I have some metadataWorker.js in my Chrome App, It is Web Worker and runs as follows:

metaThread = new Worker('/src/utils/metadataworker.js');

But I can't access the chrome global object in metadataworker.js.

Is there any way to use Chrome API (access the chrome global object) in Web Worker?

1

There are 1 best solutions below

0
On

You can't access chrome object from web worker. This is sandboxed from the app and it run in separate thread. You can only use web APIs inside a web worker, without DOM access.