title: PhantomJS to Chromeheadless with navigator.userAgent
body: <p>I'm migrating PhantomJS to Chromeheadless in my project. The project is writen in Angular1.x and has *.spec.js files for test. I have done the following changes to use Chromeheadless.</p>
  
  <p>karma.conf.js</p>
  
  <pre><code>// browsers: ['PhantomJS']
  browsers: ['ChromeHeadless']
  </code></pre>
  
  <p>package.json</p>
  
  <pre><code>"karma": "^1.7.1",
  "karma-chrome-launcher": "^2.2.0"
  </code></pre>
  
  <p>Tests failing where ever *.spec.js setting different userAgent.</p>
  
  <pre><code>window.navigator = {
    userAgent: 'Firefox;'
  }
  
  window.navigator = {
    userAgent: 'iPad;'
  }
  </code></pre>
  
  <p>This is working fine for PhantomJS but throws <code>"cannot assign to readonly property navigator of object '#&lt;Window&gt;'"</code> for ChromeHeadless.</p>
  
  <p>Here is how i get my Window object.</p>
  
  <p>myfile.spec.js</p>
  
  <pre><code>'use strict';
  describe('My test description', function(){
    var rootScope, compile, window, $document, browser, scope, timeout;
    beforeEach(inject(function($rootScope, $compile, $window, _$document_, _browser_, $timeout;){
      rootScope = $rootScope;
      compile = $compile;
      window = $window;
      $document = _$document_;
      browser = _browser_;
      timeout = $timeout;
    }));
    ...
    ...
    ...
  });
  </code></pre>
  
  <p>Searched in internet and could not find any solution or topic related to my issue. What changes should be done to make window object not read only so that i can assign other userAgents? Can anyone help on this?</p>
  
  <p>Thanks in advance.</p>