title: Chrome Extension -- Running executeScript in multiple new tabs at the same time
body: <p>I'm building a Chrome Extension that has a popup.html with a search form.  Like Travelocity or Kayak, the form includes checkboxes so the user can select which sites they want to query.  </p>
  
  <p>On submit, <code>popup.js</code> launches multiple new tabs based on the selected checkboxes.  In the <code>tabs.create()</code> callback for each new tab I use executeScript to:
  - (A) inject the user's query into the search form on each of the new pages, and 
  - (B) submit the search form on those pages.</p>
  
  <p>My code is working when one checkbox is selected (i.e. new tab is launched), but when multiple new tabs are created simultaneously it appears that the executeScript isn't running consistently.  Sometimes it works, and sometimes it doesn't.</p>
  
  <p>This leads me to believe that there's some sort of issue with the timing of the script execution, but I'm not sure.</p>
  
  <p>If you have any idea what's going on I'd love to hear your advice.</p>
  
  <p>Also, I'd appreciate any resources on how to debug this sort of issue in the future.</p>
  
  <p>Here's my code on github...</p>
  
  <ul>
  <li>whole repo: <a href="https://github.com/rossmorey/SongSearch" rel="nofollow">https://github.com/rossmorey/SongSearch</a></li>
  <li>manifest.json</li>
  <li>popup.html</li>
  <li>popup.js (most relevant file)</li>
  </ul>
  
  <p>Many thanks!</p>