Failed to create Web Worker from local file in Chrome

1

When trying to create a worker

var worker = new Worker('teste.js');

I get the following message:

  

Uncaught SecurityError: Failed to construct 'Worker': Script at   'file: /// C: /...../js/teste.js' can not be accessed from source 'null'.

Of course with this answer in SOen, link , it is not possible to load the local file. Is there any alternative way to do this?

Note: I use Google Chrome and Firefox

    
asked by anonymous 10.02.2016 / 18:14

1 answer

0

Currently, there is a disagreement among browsers between what is considered a violation of the same source policy for the Workers. Chrome and Opera do not allow local addresses even running from a local script, which, in my humble opinion, is silly.

While this is not resolved, Firefox supports running local Web Workers since the page is also running locally. This can be verified by running this example . Notice that all paths are local.

If you have a problem even following these steps, post a new question specific to your case with the problematic code.

    
10.02.2016 / 19:26