{"action":"created","issue":{"url":"https://api.github.com/repos/tmpvar/jsdom/issues/1344","labels_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1344/labels{/name}","comments_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1344/comments","events_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1344/events","html_url":"https://github.com/tmpvar/jsdom/issues/1344","id":125710648,"number":1344,"title":"Default `window.navigator.userAgent` value is `undefined`","user":{"login":"necolas","id":239676,"avatar_url":"https://avatars.githubusercontent.com/u/239676?v=3","gravatar_id":"","url":"https://api.github.com/users/necolas","html_url":"https://github.com/necolas","followers_url":"https://api.github.com/users/necolas/followers","following_url":"https://api.github.com/users/necolas/following{/other_user}","gists_url":"https://api.github.com/users/necolas/gists{/gist_id}","starred_url":"https://api.github.com/users/necolas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/necolas/subscriptions","organizations_url":"https://api.github.com/users/necolas/orgs","repos_url":"https://api.github.com/users/necolas/repos","events_url":"https://api.github.com/users/necolas/events{/privacy}","received_events_url":"https://api.github.com/users/necolas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-08T22:49:51Z","updated_at":"2016-01-12T22:32:58Z","closed_at":null,"body":"Using `jsdom@7.2.2` I get the following error from modules using `navigator.userAgent`:\r\n\r\n```js\r\nCannot read property 'indexOf' of undefined\r\n```\r\n\r\nAccording to the README, there is a default UA used in requests and set in [jsdom.js#L314-L325](https://github.com/tmpvar/jsdom/blob/7.2.2/lib/jsdom.js#L314-L325).\r\n\r\n> `config.userAgent`: the user agent string used in requests; defaults to `Node.js (#process.platform#; U; rv:#process.version#)`\r\n\r\nHowever, there is no default value for `window.navigator.userAgent` in [browser/Window.js#L309-L311](https://github.com/tmpvar/jsdom/blob/7.2.2/lib/jsdom/browser/Window.js#L309-L311), and browser module authors assume `userAgent` will always be a string. I can confirm that the errors go away by defaulting to a string:\r\n\r\n```js\r\nget userAgent() {\r\n  return options.userAgent || '';\r\n}\r\n```\r\n\r\nIf a PR from me would save rather than waste your time, I'd be happy to give it go. Where would you want tests to go?"},"comment":{"url":"https://api.github.com/repos/tmpvar/jsdom/issues/comments/171081705","html_url":"https://github.com/tmpvar/jsdom/issues/1344#issuecomment-171081705","issue_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1344","id":171081705,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T22:32:58Z","updated_at":"2016-01-12T22:32:58Z","body":"Maybe it is a difference when using jsdom.jsdom() in the tests vs. jsdom.env() or something else in your original code?"}}