title: How to organize a two-way communication with the Firefox extension code injection?
body: <p>There is an extension for Firefox, which makes the injected JS code into the page.</p>
  
  <p>Code for XUL:</p>
  
  <pre><code>window.addEventListener("load", function load(event){
  document.addEventListener("TestEvnt", function (e) {
      var info = e.detail;
      if(info.cmd=='account_list') {
          consoleLog('... event account_list');
      }
  }, false, true);
  document.addEventListener("DOMContentLoaded", function (e) {
    var window = e.originalTarget.defaultView.wrappedJSObject;
    var inject = window.document.createElement('script');
    inject.type = 'text/javascript';
    inject.setAttribute('src','resource://apptab-notify/injscr.js');
    window.document.getElementsByTagName('head')[0].appendChild(inject);
  }, false);
  },false);
  </code></pre>
  
  <p>Code injscr.js:</p>
  
  <pre><code>var additionalInfo = {
          "cmd": 'account_list',
          "url": document.location.href
      };
  var evt = document.createEvent('CustomEvent');
  evt.initCustomEvent('TestEvnt', true, false, additionalInfo);
  document.dispatchEvent(evt);
  </code></pre>
  
  <p>How to provide bi-directional communication, something to listen to code injection events from the extension? Without using Addon-SDK!</p>