Try:
navigator.__defineGetter__('userAgent', function(){
return 'foo' // customized user agent
});
navigator.userAgent; // 'foo'
Tried it in FF2 and FF3.
More Related Contents:
- How to find the operating system details using JavaScript?
- Detect IE version (prior to v9) in JavaScript
- JavaScript unit test tools for TDD
- jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
- How do I mock a service that returns promise in AngularJS Jasmine unit test?
- Mocking globals in Jest
- Change default timeout for mocha
- Using Jasmine to spy on a function without an object
- How to mock localStorage in JavaScript unit tests?
- Angular ui router unit testing (states to urls)
- How can I mock dependencies for unit testing in RequireJS?
- How to spyOn a value property (rather than a method) with Jasmine
- Getting the User Agent with JavaScript
- How to test the type of a thrown exception in Jest
- Is there a way to get Chai working with asynchronous Mocha tests?
- How to test a function which has a setTimeout with jasmine?
- How to trigger script.onerror in Internet Explorer?
- How can I mock the imports of an ES6 module?
- How to change the behaviour of a mocked import?
- What functions should I mock during unit testing
- How to mock Axios with Jest?
- Jest: how to mock console when it is used by a third-party-library?
- How to Unit Test Isolated Scope Directive in AngularJS
- How to mock dependencies for unit tests with ES6 Modules
- Mocking and Stubbing with protractor
- How to detect device name in Safari on iOS 13 while it doesn’t show the correct user agent?
- Testing code that uses an IntersectionObserver
- Setting a custom userAgent in HTML or JavaScript
- how to fix 404 warnings for images during karma unit testing
- Mobile detection [closed]