code: function setupCommunications() {
    // Listen for data from the extension.
    self.port.on('extension-event', function(data) {
      // We try to keep the data opaque so we don't waste any time here.
      sendMessage(data);
    });
  
    // Setup a communication channel with the page via events.
    var localId = String(Number(Date.now() + Math.random()));
    document.defaultView.addEventListener('message', function(e) {
      // The message here is from the wtf.ipc.MessageChannel, and has some header
      // data in it.
      // Note that because we are also sending messages it's possible to get
      // our own messages back, so filter that by localId.
      var packet = e.data;
      if (!packet ||
          !packet['wtf_ipc_connect_token'] ||
          packet['wtf_ipc_sender_token'] == localId) {
        return;
      }
  
      e.stopPropagation();
  
      // NOTE: Chrome ports do not support transferrables! Need to convert!
  
      // Pass through the messages.
      // We trust the Chrome security model and just send the data along.
      var data = packet['data'];
      self.port.emit('page-event', JSON.stringify(data));
    }, true);
  
    function sendMessage(data) {
      var packet = {
        'wtf_ipc_connect_token': true,
        'wtf_ipc_sender_token': localId,
        'data': data
      };
      document.defaultView.postMessage(packet, '*');
    };
  }
docs: Sets up two-way communications with the page.
  This enables proxying to the background page.