title: Attach event to window from popup
body: <p>I am writing a library to working with socket.</p>
  <p>In MyPeer.js file</p>
  <pre><code>var MyPeer = (function(){
      function MyPeer( opt ){
          var self = this;
          this.socket = new Socket(opt);
          this.socket.on('message', function(data) {
              self.emit('onmessage', data);
              if ( data.type == 'MYTYPE' ) {
                  self.emit('myevent', data);
              }
          });
      }
      return MyPeer;
  })();
  </code></pre>
  <p>In my page, I create a new <code>MyPeer</code> and listen event. It works fine.</p>
  <pre><code>var myPeer = new MyPeer();
  myPeer.on('onmessage', function(data){
      console.log('in onmessage');//it works
  });
  myPeer.on('myevent', function(data){
      console.log('in myevent');//it works
  });
  </code></pre>
  <p>In this page, I open a new popup by using <code>window.open</code> function. In popup, I access <code>myPeer</code> variable and listen event. Some event works well, some event does not work.</p>
  <pre><code>window.opener.myPeer.on('onmessage', function(data){
      console.log('in onmessage in popup');//it works
  });
  window.opener.myPeer.on('myevent', function(data){
      console.log('in myevent in popup');//it doesn't work
  });
  </code></pre>
  <p>Could you please help me explain why <code>myevent</code> is not working and how can I achieve this?</p>