title: karma-runner: load scripts (and CSS) via DOM
body: <p>I want to inject some CSS and JavaScript files via a preprocessor.</p>
  
  <p>In my preprocessor I inject the html template to the body element.
  I printed the result out via <code>console.log(document.body)</code> - you can see the result at the bottom. It looks good, but the script is not evaluated.</p>
  
  <p>If I run <code>console.log(window.foobar)</code> in my test, it's undefined.
  Actually I don't want to to inject simple scripts, I want to load some files via<br>
   <code>&lt;script src="build/app.js"&gt;&lt;/script&gt;</code></p>
  
  <p>I need it in every test, so I don't want to refactor every single test for the same code injection, that's the reason why I tried to put it into the html generated by karma.</p>
  
  <pre><code>&lt;body&gt;&lt;script&gt;    window.foobar = 'miau!';&lt;/script&gt;
    &lt;!-- The scripts need to be at the end of body, so that some test running frameworks
         (Angular Scenario, for example) need the body to be loaded so that it can insert its magic
         into it. If it is before body, then it fails to find the body and crashes and burns in an epic
         manner. --&gt;
    &lt;script type="text/javascript"&gt;
      // sets window.__karma__ and overrides console and error handling
      // Use window.opener if this was opened by someone else - in a new window
      if (window.opener) {
        window.opener.karma.setupContext(window);
      } else {
        window.parent.karma.setupContext(window);
      }
  
      // All served files with the latest timestamps
      window.__karma__.files = {
    '/base/node_modules/mocha/mocha.js': '253e2fdce43a4b2eed46eb25139b784adbb5c47f',
    '/base/node_modules/karma-mocha/lib/adapter.js': '3664759c75e6f4e496fef20ad115ce8233a0f7b5',
    '/base/test/custom-test.js': 'abf5b0b3f4dbb62653c816b264a251c7fc264fb9',
    '/base/test/build/build.css': 'df7e943e50164a1fc4b66e0a0c46fc86efdef656',
    '/base/test/build/build.js': '9f0a39709e073846c73481453cdee8d37e528856',
    '/base/test/build/test.js': '0ccd4711b9c887458f81cf1dedc04c6ed59abe43'
  };
  
    &lt;/script&gt;
    &lt;!-- Dynamically replaced with &lt;script&gt; tags --&gt;
    &lt;script type="text/javascript" src="/base/node_modules/mocha/mocha.js?253e2fdce43a4b2eed46eb25139b784adbb5c47f"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/base/node_modules/karma-mocha/lib/adapter.js?3664759c75e6f4e496fef20ad115ce8233a0f7b5"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/base/test/custom-test.js?abf5b0b3f4dbb62653c816b264a251c7fc264fb9"&gt;&lt;/script&gt;&lt;/body&gt;
  </code></pre>