I just made a script for a web-worker and wondered whether this is another bug chrome-browser suffers from. I do not know whether another chromium-bug has been fixed already because you could not initialized another worker(nested) within a running worker in chromium: https://code.google.com/p/chromium/issues/detail?id=31666
This in the main.html:
<script language="JavaScript" src="workerScript.js" type="text/javascript"></script>
<script language="JavaScript" src="workerScript2.js" type="text/javascript"></script>
<script>
// no error is thrown when workerScript.init('workerScript2.js') is called
console.log(workerScript.init('workerScript2.js')); // Worker { ... }
</script>
workerScript.js:
function callWorker(){
var worker = new Worker('workerScript.js');
}
callWorker(); // Uncaught ReferenceError: Worker is not defined
workerScript2:
var workerScript = {
init: function(file){
var worker = new Worker(file);
return worker;
}
};
When main.html is executed in chromium(version 40.0.2214.91 m) an error is thrown in workerScript.js:
Uncaught ReferenceError: Worker is not defined
In chromiums it seems that as long as you initialize a worker in an executed html-file no error is thrown except within an external js-file when a function is called or new Worker(...) is executed as it is the case in workerScript.js.
Actuall question: Is this a security-issue/precaution of chromium because if no error was thrown would workerScript.js be an infinite loop in chromium?(a worker in workerScript.js tries to open workerScript.js again?) But why is this working in other browsers like Firefox or even IE?
According to the comments provided by Rob W it's the same bug described at the top of the question.
Hopefully this bug is going to be fixed anytime soon. Because I've got to check whether it's a chrome-browser and if so only running one main-worker instead of several nested-workers. Chrome is fast but in terms of computing with workers it could be made faster.
Thanks for your time.