Skip to content

Commit

Permalink
Merge pull request #2970 from schalkneethling/bug1161938-support-like…
Browse files Browse the repository at this point in the history
…-firefox-browsers-plugincheck

Fix Bug 1161938, support other Gecko based browsers
  • Loading branch information
alexgibson committed May 12, 2015
2 parents 06afb83 + 9177e22 commit 532669e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
22 changes: 9 additions & 13 deletions media/js/base/global.js
Expand Up @@ -87,15 +87,17 @@ function getFirefoxMasterVersion(userAgent) {
return version;
}

// Used on the plugincheck page to also support all browsers based on Gecko.
function isLikeFirefox(userAgent) {
var ua = userAgent || navigator.userAgent;
return (/Iceweasel/i).test(ua) || (/IceCat/i).test(ua) ||
(/SeaMonkey/i).test(ua) || (/Camino/i).test(ua) ||
(/like Firefox/i).test(ua);
}

function isFirefox(userAgent) {
var ua = userAgent || navigator.userAgent;
// camino UA string contains 'like Firefox'
return (
(/\sFirefox/).test(ua) &&
!(/like Firefox/i).test(ua) &&
!(/Iceweasel/i).test(ua) &&
!(/SeaMonkey/i).test(ua)
);
return (/\sFirefox/).test(ua) && !isLikeFirefox(ua);
}

// 2015-01-20: Gives no special consideration to ESR builds
Expand All @@ -114,12 +116,6 @@ function isFirefoxUpToDate(latest) {
return (latestFirefoxVersion <= fx_version);
}

// Used on the plugincheck page to also support SeaMonkey
function isSeaMonkey(userAgent) {
var ua = userAgent || navigator.userAgent;
return /SeaMonkey/i.test(ua);
}

// used in bedrock for desktop specific checks like `isFirefox() && !isFirefoxMobile()`
// reference https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
function isFirefoxMobile(userAgent) {
Expand Down
4 changes: 2 additions & 2 deletions media/js/plugincheck/check-plugins.js
Expand Up @@ -152,7 +152,7 @@ $(function() {
}

// show main download button to non Fx traffic
if(!isFirefox() && !isSeaMonkey() ) {
if(!isFirefox() && !isLikeFirefox() ) {
wrapper.addClass('non-fx');
}

Expand All @@ -162,7 +162,7 @@ $(function() {
}

// only execute the plugincheck code if this is Firefox
if (isFirefox() || isSeaMonkey()) {
if (isFirefox() || isLikeFirefox()) {
PluginCheck.getPluginsStatus('https://plugins.mozilla.org/en-us/plugins_list.json',
function(response) {
displayPlugins(response);
Expand Down
54 changes: 33 additions & 21 deletions media/js/test/spec/global.js
Expand Up @@ -320,47 +320,59 @@ describe('global.js', function() {
});
});

describe('isSeaMonkey', function() {
describe('isLikeFirefox', function() {

it('should consider SeaMonkey as SeaMonkey', function() {
it('should consider SeaMonkey to be like Firefox', function() {
var ua = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0 SeaMonkey/2.37a1';
var result = isSeaMonkey(ua);
var result = isLikeFirefox(ua);
expect(result).toBeTruthy();
});

it('should not consider Firefox to be SeaMonkey', function() {
var ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0';
var result = isSeaMonkey(ua);
expect(result).not.toBeTruthy();
it('should consider IceWeasel to be like Firefox', function() {
var ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121202 Firefox/17.0 Iceweasel/17.0.1';
var result = isLikeFirefox(ua);
expect(result).toBeTruthy();
});

it('should not consider Camino to be SeaMonkey', function() {
it('should consider IceCat to be like Firefox', function() {
var ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121201 icecat/17.0.1';
var result = isLikeFirefox(ua);
expect(result).toBeTruthy();
});

it('should consider Camino to be like Firefox', function() {
var ua = 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en; rv:1.9.2.24) Gecko/20111114 Camino/2.1 (like Firefox/3.6.24)';
var result = isSeaMonkey(ua);
var result = isLikeFirefox(ua);
expect(result).toBeTruthy();
});

it('should consider Camino like userAgent to be like Firefox', function() {
var ua = 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en; rv:1.9.2.24) Gecko/20111114 (like Firefox/3.6.24)';
var result = isLikeFirefox(ua);
expect(result).toBeTruthy();
});

it('should not consider Firefox to be "like" Firefox', function() {
var ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:23.0) Gecko/20100101 Firefox/23.0';
var result = isLikeFirefox(ua);
expect(result).not.toBeTruthy();
});

it('should not consider Chrome to be SeaMonkey', function() {
it('should not consider Chrome to be like Firefox', function() {
var ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36';
var result = isSeaMonkey(ua);
var result = isLikeFirefox(ua);
expect(result).not.toBeTruthy();
});

it('should not consider Safari to be SeaMonkey', function() {
it('should not consider Safari to be like Firefox', function() {
var ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2';
var result = isSeaMonkey(ua);
var result = isLikeFirefox(ua);
expect(result).not.toBeTruthy();
});

it('should not consider IE to be SeaMonkey', function() {
it('should not consider IE to be like Firefox', function() {
var ua = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)';
var result = isSeaMonkey(ua);
expect(result).not.toBeTruthy();
});

it('should not consider Iceweasel to be SeaMonkey', function() {
var ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20121202 Firefox/17.0 Iceweasel/17.0.1';
var result = isSeaMonkey(ua);
var result = isLikeFirefox(ua);
expect(result).not.toBeTruthy();
});
})
Expand Down

0 comments on commit 532669e

Please sign in to comment.