Skip to content

Commit

Permalink
fix IE version detection in old IE
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioCrisostomo committed Sep 15, 2014
1 parent 7ce4a62 commit a9628d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Browser/Browser.js
Expand Up @@ -45,7 +45,7 @@ var parse = function(ua, platform){

var Browser = this.Browser = parse(navigator.userAgent, navigator.platform);

if (Browser.name == 'ie'){
if (Browser.name == 'ie' && document.documentMode){
Browser.version = document.documentMode;
}

Expand Down
7 changes: 5 additions & 2 deletions Specs/Browser/Browser.js
Expand Up @@ -75,16 +75,15 @@ describe('Window', function(){
});

describe('Browser', function(){
var isPhantomJS = !!navigator.userAgent.match(/phantomjs/i);

it('should think it is executed in a browser', function(){
var isPhantomJS = !!navigator.userAgent.match(/phantomjs/i);
if (!isPhantomJS) expect(['ie', 'safari', 'chrome', 'firefox', 'opera']).toContain(Browser.name);
});

//<1.4compat>
it('should assign a Browser[Browser.name] property for all browsers, except IE v11 or higher', function(){
if (Browser.name != 'ie' || Browser.version < 11){
var isPhantomJS = !!navigator.userAgent.match(/phantomjs/i);
expect(isPhantomJS || Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera).toEqual(true);
}
});
Expand All @@ -99,6 +98,10 @@ describe('Browser', function(){
it('should assume the IE version is emulated by the documentMode (X-UA-Compatible)', function(){
if (Browser.name == 'ie' && document.documentMode) expect(Browser.version).toEqual(document.documentMode);
});
it('should find a browser version', function(){
expect(Browser.version || isPhantomJS).toBeTruthy();
expect(typeof Browser.version).toEqual('number');
});

});

Expand Down

0 comments on commit a9628d3

Please sign in to comment.