title: chrome.runtime.sendMessage not working as expected
body: <p>I am writing a Chrome plugin with a content script and a background script, and I am trying to make the two communicate.</p>
  
  <p>In my content script, I am doing</p>
  
  <pre><code>chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
        console.log(response.farewell);
  });
  </code></pre>
  
  <p>and in my background script, I am doing </p>
  
  <pre><code>chrome.runtime.onMessage.addListener(
      function(request, sender, sendResponse) {
          console.log(sender.tab ?
            "from a content script:" + sender.tab.url :
            "from the extension");
          if (request.greeting == "hello")
              sendResponse({farewell: "goodbye"});
      }
  );
  </code></pre>
  
  <p>My manifest looks like this:</p>
  
  <pre><code>{
      "manifest_version": 2,
      "name": "Tesing Phase",
      "version": "1.0",
      "background": {
          "persistent": false,
          "scripts": ["bgscript.js"]
      },
      "content_scripts": [{
          "js": ["contentscript.js"],
          "all_frames": true,
          "run_at" : "document_start",
          "matches": ["*://*/*"]
      }],
      "web_accessible_resources": ["script.js"]
  }
  </code></pre>
  
  <p>When I run my plugin, I get the following error:</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;Object&gt; has no method 'sendMessage' 
  </code></pre>
  
  <p>I tried logging <code>chrome.runtime</code>, and there was no method <code>sendMessage</code>. I am using version 25.0 of Chromium on Ubuntu. I tried using <code>sendRequest</code> as well, but it said it's depreciated and <code>sendMessage</code> should be used.</p>
  
  <p>Can anyone point me out what I am missing here? Are there any permissions needed for this to work?</p>