I'm creating an incredibly simple Firefox extension. I used cfx init to create the directory structure and have code in lib/main.js and data/my_worker.js
main.js is as follows:
var worker = new Worker("my_worker.js");
worker.onmessage = function(e) {
console.log(e.data);
};
worker.postMessage("Bobby");
and my_worker.js is as follows:
self.onmessage = function(e) {
self.postMessage("Hello " + e.data);
};
Then I run: cfx run to run the extension. The results are as follows:
(addon-sdk-1.17)me:lib me$ cfx run Using binary at '/Applications/Firefox.app/Contents/MacOS/firefox-bin'. Using profile at '/var/folders/p1/zzdzcrrx6pq96hgsmy5xjqmh0000gp/T/tmp57OYe9.mozrunner'. console.error: test: Message: ReferenceError: Worker is not defined Stack: @resource://jid1-zmowxggdley0aa-at-jetpack/test/lib/main.js:1:9 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 run@resource://gre/modules/commonjs/sdk/addon/runner.js:138:19 startup/
I tried putting my_worker.js in both the data and lib folders but neither works. This seems like a SUPER simple extension. What could be going wrong?