Permalink
Browse files

Fix Bug 1125166 - Some mozilla.org-sites consider 31.4ESR to be out o…

…f date
  • Loading branch information...
1 parent 2d8606a commit 2bee1fd25be11f981a205fd3775c524c06ccffb3 @kyoshino kyoshino committed Jan 26, 2015
Showing with 23 additions and 13 deletions.
  1. +8 −7 bedrock/tabzilla/templates/tabzilla/tabzilla.js
  2. +15 −6 media/js/test/spec/tabzilla.js
@@ -484,15 +484,17 @@ var Tabzilla = (function (Tabzilla) {
return offeredLang;
};
- Infobar.update = function (ua, latestVersion) {
- ua = ua || navigator.userAgent;
+ Infobar.update = function (latestVersion, ua, buildID) {
latestVersion = parseInt(latestVersion || '{{ latest_firefox_version }}', 10);
+ ua = ua || navigator.userAgent;
+ buildID = buildID || navigator.buildID;
var updatebar = new Infobar('updatebar', 'Update Bar');
var isFirefox = ((/\sFirefox\/\d+/).test(ua) &&
!(/like\ Firefox|Iceweasel|SeaMonkey/i).test(ua)); // Exclude Camino and others
var isMobile = (/Mobile|Tablet|Fennec/i).test(ua);
var userVersion = (isFirefox) ? parseInt(ua.match(/Firefox\/(\d+)/)[1], 10) : 0;
+ var isFirefox31ESR = !isMobile && userVersion === 31 && buildID && buildID !== '20140716183446';
var showInfobar = function () {
if ($('body').data('defaultSlug') === 'update-firefox-latest-version') {
// Don't show the info bar on the page that the info bar sends the user to.
@@ -516,18 +518,17 @@ var Tabzilla = (function (Tabzilla) {
});
};
- if (updatebar.disabled || !isFirefox || isMobile ||
+ if (updatebar.disabled || !isFirefox || isMobile || isFirefox31ESR ||
userVersion > latestVersion) {
return false;
}
// Show the Update Bar if the user's major version is older than 3 major
// versions. Once the Mozilla.UITour API starts providing the channel
// info (Bug 1065525, Firefox 35+), we can show the Bar only to Release
- // channel users. Until then, because we cannot distinguish between ESR
- // users and Release users, some ESR users may see a wrong message even
- // when they are using one of the latest ESR builds, but it's a
- // compromise; we rather care about many older Release users.
+ // channel users. 31 ESR can be detected only with the navigator.buildID
+ // property. 20140716183446 is the non-ESR build ID that can be found at
+ // https://wiki.mozilla.org/Releases/Firefox_31/Test_Plan
if (userVersion < latestVersion - 2) {
showInfobar();
@@ -141,15 +141,15 @@ describe("tabzilla.js", function() {
describe("infobar.update", function () {
- var setup = function (ua) {
+ var setup = function (ua, buildID) {
// Test a case where the latest version is a non-dot release
- var result1 = Tabzilla.infobar.update(ua, '26.0');
+ var result1 = Tabzilla.infobar.update('35.0', ua, buildID);
// Cleanup
$('#tabzilla-infobar').remove();
// Test a case where the latest version is a dot release
- var result2 = Tabzilla.infobar.update(ua, '25.0.1');
+ var result2 = Tabzilla.infobar.update('35.0.1', ua, buildID);
// Cleanup
$('#tabzilla-infobar').remove();
@@ -165,9 +165,9 @@ describe("tabzilla.js", function() {
});
it('should return false if the user agent is a latest Firefox version', function () {
- expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0')).toBeFalsy();
- expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:26.0) Gecko/20100101 Firefox/26.0')).toBeFalsy();
- expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0')).toBeFalsy();
+ expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:39.0) Gecko/20100101 Firefox/39.0')).toBeFalsy();
+ expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:36.0) Gecko/20100101 Firefox/36.0')).toBeFalsy();
+ expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:34.0) Gecko/20100101 Firefox/34.0')).toBeFalsy();
});
it('should return false if the user agent is Firefox for mobile', function () {
@@ -181,10 +181,19 @@ describe("tabzilla.js", function() {
expect(setup('Mozilla/5.0 (Tablet; rv:26.0) Gecko/26.0 Firefox/26.0')).toBeFalsy();
});
+ it('should return false if the user agent is Firefox ESR', function () {
+ // Firefox 31 ESR
+ expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:31.0) Gecko/20100101 Firefox/31.0', '20140717132905')).toBeFalsy();
+ // Firefox 31.4.0 ESR
+ expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:31.0) Gecko/20100101 Firefox/31.0', '20150105205548')).toBeFalsy();
+ });
+
it('should return true if the user agent is an outdated Firefox version', function () {
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:22.0) Gecko/20100101 Firefox/22.0')).toBeTruthy();
expect(setup('Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1')).toBeTruthy();
expect(setup('Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100915 Gentoo Firefox/3.6.9')).toBeTruthy();
+ // Firefox 31 non-ESR
+ expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:31.0) Gecko/20100101 Firefox/31.0', '20140716183446')).toBeTruthy();
});
});

0 comments on commit 2bee1fd

Please sign in to comment.