http://crbug.com/357664 is the bug report about not being able to load extension scripts as a web worker.
The workaround to this problem is to load the worker script using XMLHttpRequest, then load the worker from a string. When I faced this problem in the past, I created a wrapper that transparently modifies the Worker
constructor, so you can use new Worker(chrome.runtime.getURL('worker.js'))
without any problems.
See patch-worker.js
(documentation) for the implementation of the previous idea.
patch-worker.js
has some limitations (e.g. importScripts
does not work as expected), mainly related to the fact that it does not run in the chrome-extension:
-origin. To solve these problems, I created another library that uses an iframe to create the Worker. See worker_proxy
for the source code and documentation.