title: Firefox addon: Why the self.port in the panel's contentscript is undefined?
body: <p>I meet a strange thing with Firefox addon development: I write code like this (I convert the commented code from Chrome extension to Firefox addon code):</p>
  <pre><code>function sendStoreIdentitiesMessage(identities, remember){
      console.log(&quot;Storing identities: &quot;+identities.length);
      if(remember==null){
          remember=false;
      }
      //extension.sendMessage({type:&quot;save.identities&quot;, identities:identities, remember:remember}, function(response) {
      //  identitiesNum=identities.length;
      //  identitiesDate=new Date();
      //  sendGetPageIdsMessage(function(){showCodeImageSuccess();});
      //});
      
      self.postMessage({type:&quot;save.identities&quot;, identities:identities, remember:remember});
      self.port.on(&quot;response.save.identities&quot;,function(response){
          identitiesNum=identities.length;
          identitiesDate=new Date();
          sendGetPageIdsMessage(function(){showCodeImageSuccess();});
      });
  }
  </code></pre>
  <p>When I compile it with Addon Builder,it gets the error:</p>
  <blockquote>
  <p>&quot;Error: NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMWindow.postMessage]&quot;</p>
  </blockquote>
  <p>Then I change the code like this:</p>
  <pre><code>function sendStoreIdentitiesMessage(identities, remember){
      console.log(&quot;Storing identities: &quot;+identities.length);
      if(remember==null){
          remember=false;
      }
      //extension.sendMessage({type:&quot;save.identities&quot;, identities:identities, remember:remember}, function(response) {
      //  identitiesNum=identities.length;
      //  identitiesDate=new Date();
      //  sendGetPageIdsMessage(function(){showCodeImageSuccess();});
      //});
      
      self.port.emit(&quot;message&quot;,{type:&quot;save.identities&quot;, identities:identities, remember:remember});
      self.port.on(&quot;response.save.identities&quot;,function(response){
          identitiesNum=identities.length;
          identitiesDate=new Date();
          sendGetPageIdsMessage(function(){showCodeImageSuccess();});
      });
  }
  </code></pre>
  <p>I got another error:</p>
  <blockquote>
  <p>TypeError: self.port is undefined.</p>
  </blockquote>
  <p>So, what's wrong?</p>