title: Message Passing issues in Chrome Extension
body: <p>I'm trying to pass a message from my content script to my background page. This error occurs when the content script is executed:</p>
  
  <pre><code>Uncaught TypeError: Cannot call method 'sendRequest' of undefined 
  </code></pre>
  
  <p>Content Script:</p>
  
  <pre><code>function injectFunction(func, exec) {
      var script = document.createElement("script");
      script.textContent = "-" + func + (exec ? "()" : "");
      document.body.appendChild(script);
  }
  
  function login() {
  
      chrome.extension.sendMessage({greeting: "hello"}, function(response) {
          console.log(response.farewell);
      });
  
      var d = window.mainFrame.document;
      d.getElementsByName("email")[0].value = "I need the response data here";
      d.getElementsByName("passwort")[0].value = "Here too.";
      d.forms["login"].submit();
  }
  
  injectFunction(login, true);
  </code></pre>
  
  <p>Background:</p>
  
  <pre><code> chrome.extension.onMessage.addListener(
   function(request, sender, sendResponse) {
        if (request.greeting == "hello")
        sendResponse({farewell: "goodbye"});
   });
  </code></pre>
  
  <p>manifest.json:</p>
  
  <pre><code>{
      "name": "Sephir Auto-Login",
      "version": "1.0",
      "manifest_version": 2,
      "description": "Contact x@x.com for support or further information.",
      "options_page": "options.html",
      "icons":{
          "128":"icon.png"
      },
      "background": {
          "scripts": ["eventPage.js"]
      },
      "content_scripts": [
          {
            "matches": ["https://somewebsite/*"],
            "js": ["login.js"]
          }, 
          {
            "matches": ["somewebsite/*"],
            "js": ["changePicture.js"]
          }
      ],
       "permissions": [
          "storage",
          "http://*/*",
          "https://*/*",
          "tabs"
      ]
  }
  </code></pre>
  
  <p>Those are the examples on the documentation from google, so they <em>should</em> work. </p>
  
  <p>Any help? I'm completely lost.</p>