title: Chrome extension: message from background.js to content.js
body: <p>I am trying to send a message from <code>background.js</code> to <code>content.js</code> using the following code:</p>
  
  <p><strong>Background</strong></p>
  
  <pre><code>chrome.runtime.sendMessage({'method': 'test'});
  </code></pre>
  
  <p><strong>Content</strong></p>
  
  <pre><code>chrome.runtime.onMessage.addListener(function(message,sender,sendResponse){
    if(message.method == 'test')
      console.log('Got message');
  });
  </code></pre>
  
  <p>The background message is sent when <code>background.js</code> receives a specific message from <code>popup.js</code> which occurs on a click event. So the user clicks a button in the popup and a message is sent to background and then to content.</p>
  
  <p>I have a feeling my problem is something to do with the fact that when the button is clicked in the popup (which is a separate tab), the content script does not receive it because it is not the current active tab.</p>
  
  <p>Please help me out.</p>