title: Error injecting a script in others tabs in my chrome extension
body: <p>this is my first try building a chrome extension.
  I took the first example and motified it to my needs.</p>
  
  <p>I want to build a chrome extension that can controll the youtube player on different tabs
  from the popup menu.</p>
  
  <p>At first i want to show a list of all open youtube tabs. This works fine.
  After that i want to insert a script in each of those tabs.</p>
  
  <p>Thats where the problem occurs:
  The developer console gives me the following error </p>
  
  <pre><code>Error during tabs.executeScript: Unknown error.      sendRequest:22
      chromeHidden.handleResponse                      sendRequest:22
  Callback worked 
  </code></pre>
  
  <p>My manifest.json looks like this</p>
  
  <pre><code>{
    "manifest_version": 2,
  
    "name": "YoutubeMusicControl",
    "description": "First Try",
    "version": "1.0",
  
    "permissions": [
      "tabs",
      "http://*/",
      "https://*/"
    ],
  
    "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html"
    }
  }
  </code></pre>
  
  <p>The popup.html does nothing special besides running the script.</p>
  
  <p>Here is the interesting part</p>
  
  <pre><code>var TabControl = {
  
      listCurrentTabs : function(){
          var name = "";
          var div;
  
          chrome.tabs.query({}, function(tabs){
  
              for(var i = 0; i &lt; tabs.length; i++){
  
                  var found = tabs[i].url.search(/.*youtube.*/);
  
                  if(found != -1){
                      div = document.createElement('div');
  
                      name = tabs[i].title;
                      div.className = "entry";
                      div.innerHTML = name;
                      document.body.appendChild(div);                  
  
                      chrome.tabs.executeScript(i,{
                          code:"alert('test');"
                      },function(results){console.log("Callback worked")});
                      }                    
                  }
          });
      }
  }
  
  document.addEventListener('DOMContentLoaded', function () {
    TabControl.listCurrentTabs();
  });
  </code></pre>
  
  <p>If i change the parameter i to null (the current tab), everythings works fine.
  It looks as if i dont have the permisson or something is wrong with the parameter,
  but i cant get the code to work. </p>
  
  <p>Can somebody see why the code is not working?</p>
  
  <p>Thanks in advance</p>