Skip to content
This repository has been archived by the owner on Jan 25, 2018. It is now read-only.

Commit

Permalink
put ie8 as an obsolet browser
Browse files Browse the repository at this point in the history
  • Loading branch information
timotta committed Apr 5, 2013
1 parent 4698bdb commit 3ec2889
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 35 deletions.
11 changes: 11 additions & 0 deletions .project
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sawpf</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
6 changes: 6 additions & 0 deletions Rakefile
Expand Up @@ -26,6 +26,12 @@ task :server do
server.start
end

desc "Run a test server."
task :server_test do
require 'evergreen/server'
Evergreen::Server.new.serve
end

task :environment do
end

57 changes: 51 additions & 6 deletions spec/compatible_mode_ie7_spec.js
@@ -1,10 +1,55 @@
Cookie.unset('__sawpf_');
fakeUserAgent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0)');
document['documentMode'] = 5;
require('/src/1.0.js');

describe('Internet Explorer 8.0/9.0 com user-agent do IE7 por causa do compatibility mode', function() {
it('should not show sawpf bar', function() {
expect(document.getElementById('sawpf')).not.toExist();
describe('Compatibility mode:', function() {

describe('using IE7 on IE8', function() {
it('should show sawpf bar', function() {
fakeUserAgent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0)');
document.documentMode = 7;
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).toExist();
})
});
});

describe('using IE7 on IE9', function() {
it('should not show sawpf bar', function() {
fakeUserAgent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)');
document.documentMode = 7;
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
});
});
});

describe('using IE8 on IE9', function() {
it('should not show sawpf bar', function() {
fakeUserAgent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/5.0)');
document.documentMode = 8;
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
});
});
});

describe('using IE7 on IE10', function() {
it('should not show sawpf bar', function() {
fakeUserAgent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/6.0)');
document.documentMode = 7;
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
});
});
});

describe('using IE8 on IE10', function() {
it('should not show sawpf bar', function() {
fakeUserAgent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/6.0)');
document.documentMode = 8;
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
});
});
});

});
26 changes: 6 additions & 20 deletions spec/ff90_spec.js
@@ -1,33 +1,19 @@
Cookie.unset('__sawpf_');

function loadSawpf() {
(function(d,t){
var g=d.createElement(t),
s=d.getElementsByTagName(t)[0];
g.src='/src/1.0.js';
s.parentNode.insertBefore(g,s)
}(document,'script'));
}

describe('Firefox 9.0', function() {

beforeEach(function() {
return;
var el = document.getElementById('sawpf');
if (!el) return;
el.parent.removeChild(el);
});

it('should not show sawpf bar', function() {
fakeUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a2) Gecko/20111101 Firefox/9.0a2');
loadSawpf();
expect(document.getElementById('sawpf')).not.toExist();
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
});
});

it('should not show sawpf bar', function() {
fakeUserAgent('Mozilla/5.0 (Windows NT 6.2; rv:9.0.1) Gecko/20100101 Firefox/9.0.1');
loadSawpf();
expect(document.getElementById('sawpf')).not.toExist();
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
});
});

});
Expand Down
26 changes: 26 additions & 0 deletions spec/ie10_spec.js
@@ -0,0 +1,26 @@
Cookie.unset('__sawpf_');

describe('IE10 should not show with user agent', function() {

var userAgents = [
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)',
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)',
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)',
'Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)',
'Mozilla/4.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)',
'Mozilla/1.22 (compatible; MSIE 10.0; Windows 3.1)',
'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0'
];

for(var i=0; i<userAgents.length; i++) {
var u = userAgents[i];
it(u, function() {
fakeUserAgent(u);
afterSawpfLoaded(function(){
expect(document.getElementById('sawpf')).not.toExist();
})
});
};


});
4 changes: 2 additions & 2 deletions spec/ie8_ie6_spec.js
Expand Up @@ -6,7 +6,7 @@ fakeUserAgent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; G
require('/src/1.0.js');

describe('Internet Explorer 8.0 com user-agent duplo com o IE6', function() {
it('should not show sawpf bar', function() {
expect(document.getElementById('sawpf')).not.toExist();
it('should show sawpf bar', function() {
expect(document.getElementById('sawpf')).toExist();
});
});
4 changes: 2 additions & 2 deletions spec/ie8_spec.js
Expand Up @@ -3,7 +3,7 @@ fakeUserAgent('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)')
require('/src/1.0.js');

describe('Internet Explorer 8.0', function() {
it('should not show sawpf bar', function() {
expect(document.getElementById('sawpf')).not.toExist();
it('should show sawpf bar', function() {
expect(document.getElementById('sawpf')).toExist();
});
});
25 changes: 25 additions & 0 deletions spec/spec_helper.js
Expand Up @@ -6,6 +6,31 @@ function fakeUserAgent(value) {
});
}

window.sawpfLoaded = false

function loadSawpf() {
window.sawpfLoaded = false
var el = document.getElementById('sawpf');
if (el) {
el.parentNode.removeChild(el);
}
var g=document.createElement('script');
var s=document.getElementsByTagName('script')[0];
g.onload = function(){
window.sawpfLoaded = true;
};
g.src='/src/1.0.js';
s.parentNode.insertBefore(g,s);
}

function afterSawpfLoaded(callback) {
loadSawpf();
waitsFor(function(){ return window.sawpfLoaded });
runs(function() {
callback()
});
}

// Cookie control
var Cookie = {
set: function(name, value, msecs){
Expand Down
15 changes: 10 additions & 5 deletions src/1.0.js
Expand Up @@ -7,7 +7,7 @@
// based on jquery's browser detection
var userAgent = navigator.userAgent.toLowerCase();
var BrowserDetect = {
version: parseFloat((userAgent.match(/.+(?:firefox|ie)[\/: ]([\d.]+)/) || [0, '0'])[1]),
version: parseFloat((userAgent.match(/.+(?:firefox|ie)[\/: ]([\d.]+)/) || [0, 0])[1]),
msie: (/msie/).test(userAgent) && !(/opera/).test(userAgent),
firefox: (/mozilla/).test(userAgent) && !(/(compatible|webkit)/).test(userAgent)
};
Expand All @@ -18,16 +18,20 @@
if (isIE && BrowserDetect.version == 6 && (/msie 8/.test(userAgent))) BrowserDetect.version = 8;

// http://stackoverflow.com/questions/1328963/detect-ie8-compatibility-mode
if (isIE && BrowserDetect.version < 8 && document.documentMode) BrowserDetect.version = 8;

// http://social.msdn.microsoft.com/Forums/en-US/netfxjscript/thread/ae715fd2-1ddd-46f7-8c26-9aed6b2103f1/
if (isIE && BrowserDetect.version < 9 && document.documentMode < 9) {
var trident = parseInt((userAgent.match(/.+trident\/(\d+)\..*/) || [0,0])[1], 10);
BrowserDetect.version = trident < 5 ? 8 : 9;
}

// ---------------------------------------------------------------------------------------------------

if (!(isFirefox || isIE)) return;
if (isFirefox && BrowserDetect.version >= 9) return;
if (isIE && BrowserDetect.version >= 8) return;
if (isIE && BrowserDetect.version >= 9) return;

// ---------------------------------------------------------------------------------------------------

// Cookie control
var Cookie = {
set: function(name, value, msecs){
Expand Down Expand Up @@ -172,5 +176,6 @@
return false;
};
emile(container, 'height: 58px', {duration: 500});

})(this, document, navigator);

1 comment on commit 3ec2889

@shankarcabus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement! Thanks

Please sign in to comment.