title: FileReaderSync undefined inside Web Worker in Firefox extension using Add-on SDK
body: <p>I managed to get a Web Worker (not a content/worker) in my Firefox add-on using the Add-on SDK. I followed Wladimir's advice here to get the Worker class working: <a href="https://stackoverflow.com/questions/9216984/concurrency-with-firefox-add-on-script-and-content-script">Concurrency with Firefox add-on script and content script</a></p>
  
  <p>Now, I can launch a worker in my code and can talk to it by sending/receiving messages.</p>
  
  <p>This is my main.js file:</p>
  
  <pre class="lang-js prettyprint-override"><code>// spawn our log reader worker
  var worker = new Worker(data.url('log-reader.js'));
  
  // send and respond to some dummy messages
  worker.postMessage('halo');
  worker.onmessage = function(event) {
      console.log('received msg from worker: ' + event.data);
  };
  </code></pre>
  
  <p>This is my log-reader.js file:</p>
  
  <pre class="lang-js prettyprint-override"><code>// this function gets called when main.js sends a msg to this worker
  // using the postMessage call
  
  onmessage = function(event) {
      var info = event.data;
  
      // reply back
      postMessage('hey addon, i got your message: ' + info);
      if (!!FileReaderSync) {
          postMessage('ERROR: FileReaderSync is not supported');
      } else {
          postMessage('FileReaderSync is supported');
      }
  
  //    var reader = new FileReaderSync();
  //    postMessage('File contents: ' + reader.readAsText('/tmp/hello.txt'));
  };
  </code></pre>
  
  <p>My problem is that the FileReaderSync class is not defined inside the log-reader.js file, and as a result I get the error message back. If I uncomment the last lines where FileReaderSync is actually used, I will never get the message back in my addon.</p>
  
  <p>I tried using the same trick I used for Worker, by creating a dummy.jsm file and importing in main.js, but FileReaderSync will only be available in main.js and not in log-reader.js:</p>
  
  <pre class="lang-js prettyprint-override"><code>// In dummy.jsm
  var EXPORTED_SYMBOLS=["Worker"];
  var EXPORTED_SYMBOLS=["FileReaderSync"];
  
  // In main.js
  var { Worker, FileReaderSync } = Cu.import(data.url('workers.jsm'));
  Cu.unload(data.url("workers.jsm"));
  </code></pre>
  
  <p>I figure there has to be a solution since the documentation <a href="https://developer.mozilla.org/en-US/docs/DOM/FileReaderSync" rel="nofollow noreferrer">here</a> seems to indicate that the FileReaderSync class should be available to a Web Worker in Firefox:</p>
  
  <blockquote>
    <p>This interface is only available in workers as it enables synchronous I/O that could potentially block.</p>
  </blockquote>
  
  <p>So, is there a way to make FileReaderSync available and usable in the my Web Worker code?</p>