title: Getting variables outside executeScript in chrome extension
body: <p>I am trying to code a chrome extension, and I have a background.html with this code:</p>
  
  <pre><code>var x = "test";
  
  function tabChanged(id, info, tab){
      if(info.status == 'complete'){
          chrome.tabs.executeScript(id, {code:"try{alert(x);}catch(e){alert(e);}"}, null);
      }
  }
  
  chrome.tabs.onUpdated.addListener(tabChanged);
  chrome.tabs.getAllInWindow(null,function(tabs){
      for(var index=0; index &lt; tabs.length; index++){
          chrome.tabs.executeScript(tabs[index].id, {code:"try{alert(x);}catch(e){alert(e);}"}, null);
      }
  });
  </code></pre>
  
  <p>But variable "x" is always undefined inside executeScript.</p>
  
  <p><strong>How can I get/set x from executeScript?</strong> Without using messaging.</p>