title: Chrome extension content scripts are not injected in the first place, how to debug?
body: <p>When I'm running the Chromium browser using:</p>
  
  <blockquote>
    <p>chromium-browser --load-extension=/path/to/my/extension
    --user-data-dir=/path/to/chrome/profile --app=http://localhost/somepage</p>
  </blockquote>
  
  <p>some content scripts are not injected into the page. These scripts are defined as follows in the manifest file:</p>
  
  <pre><code>"content_scripts" : [{
                  "matches" : [ "http://*/*", "https://*/*" ],
                  "js" : [ "content/s1.js", "content/s2.js", "content/s3.js", "content/s4.js" ],
                  "run_at" : "document_end"
  }]
  </code></pre>
  
  <p>When inspecting the page, I see that only <code>s1.js</code> and <code>s4.js</code> were injected successfully. After reloading the page all scripts are injected correctly, and my extension works as expected.</p>
  
  <p>What can be the reason for that, and how to debug this?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Those content scripts (that fail to inject sometimes) reference 'document' at the beginning. It seems like if I wrap them into something like:</p>
  
  <pre><code>setTimeout(function() { document. ... }, 5000);
  </code></pre>
  
  <p>They are always injected as expected. Is it possible that the document is not available, even though "run_at": "document_end" was specified in manifest?</p>
  
  <p>Thanks!</p>