Skip to content

Commit 2bee1fd

Browse files
committed
Fix Bug 1125166 - Some mozilla.org-sites consider 31.4ESR to be out of date
1 parent 2d8606a commit 2bee1fd

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

bedrock/tabzilla/templates/tabzilla/tabzilla.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,17 @@ var Tabzilla = (function (Tabzilla) {
484484

485485
return offeredLang;
486486
};
487-
Infobar.update = function (ua, latestVersion) {
488-
ua = ua || navigator.userAgent;
487+
Infobar.update = function (latestVersion, ua, buildID) {
489488
latestVersion = parseInt(latestVersion || '{{ latest_firefox_version }}', 10);
489+
ua = ua || navigator.userAgent;
490+
buildID = buildID || navigator.buildID;
490491

491492
var updatebar = new Infobar('updatebar', 'Update Bar');
492493
var isFirefox = ((/\sFirefox\/\d+/).test(ua) &&
493494
!(/like\ Firefox|Iceweasel|SeaMonkey/i).test(ua)); // Exclude Camino and others
494495
var isMobile = (/Mobile|Tablet|Fennec/i).test(ua);
495496
var userVersion = (isFirefox) ? parseInt(ua.match(/Firefox\/(\d+)/)[1], 10) : 0;
497+
var isFirefox31ESR = !isMobile && userVersion === 31 && buildID && buildID !== '20140716183446';
496498
var showInfobar = function () {
497499
if ($('body').data('defaultSlug') === 'update-firefox-latest-version') {
498500
// 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) {
516518
});
517519
};
518520

519-
if (updatebar.disabled || !isFirefox || isMobile ||
521+
if (updatebar.disabled || !isFirefox || isMobile || isFirefox31ESR ||
520522
userVersion > latestVersion) {
521523
return false;
522524
}
523525

524526
// Show the Update Bar if the user's major version is older than 3 major
525527
// versions. Once the Mozilla.UITour API starts providing the channel
526528
// info (Bug 1065525, Firefox 35+), we can show the Bar only to Release
527-
// channel users. Until then, because we cannot distinguish between ESR
528-
// users and Release users, some ESR users may see a wrong message even
529-
// when they are using one of the latest ESR builds, but it's a
530-
// compromise; we rather care about many older Release users.
529+
// channel users. 31 ESR can be detected only with the navigator.buildID
530+
// property. 20140716183446 is the non-ESR build ID that can be found at
531+
// https://wiki.mozilla.org/Releases/Firefox_31/Test_Plan
531532
if (userVersion < latestVersion - 2) {
532533
showInfobar();
533534

media/js/test/spec/tabzilla.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ describe("tabzilla.js", function() {
141141

142142
describe("infobar.update", function () {
143143

144-
var setup = function (ua) {
144+
var setup = function (ua, buildID) {
145145
// Test a case where the latest version is a non-dot release
146-
var result1 = Tabzilla.infobar.update(ua, '26.0');
146+
var result1 = Tabzilla.infobar.update('35.0', ua, buildID);
147147

148148
// Cleanup
149149
$('#tabzilla-infobar').remove();
150150

151151
// Test a case where the latest version is a dot release
152-
var result2 = Tabzilla.infobar.update(ua, '25.0.1');
152+
var result2 = Tabzilla.infobar.update('35.0.1', ua, buildID);
153153

154154
// Cleanup
155155
$('#tabzilla-infobar').remove();
@@ -165,9 +165,9 @@ describe("tabzilla.js", function() {
165165
});
166166

167167
it('should return false if the user agent is a latest Firefox version', function () {
168-
expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0')).toBeFalsy();
169-
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:26.0) Gecko/20100101 Firefox/26.0')).toBeFalsy();
170-
expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0')).toBeFalsy();
168+
expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:39.0) Gecko/20100101 Firefox/39.0')).toBeFalsy();
169+
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:36.0) Gecko/20100101 Firefox/36.0')).toBeFalsy();
170+
expect(setup('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:34.0) Gecko/20100101 Firefox/34.0')).toBeFalsy();
171171
});
172172

173173
it('should return false if the user agent is Firefox for mobile', function () {
@@ -181,10 +181,19 @@ describe("tabzilla.js", function() {
181181
expect(setup('Mozilla/5.0 (Tablet; rv:26.0) Gecko/26.0 Firefox/26.0')).toBeFalsy();
182182
});
183183

184+
it('should return false if the user agent is Firefox ESR', function () {
185+
// Firefox 31 ESR
186+
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:31.0) Gecko/20100101 Firefox/31.0', '20140717132905')).toBeFalsy();
187+
// Firefox 31.4.0 ESR
188+
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:31.0) Gecko/20100101 Firefox/31.0', '20150105205548')).toBeFalsy();
189+
});
190+
184191
it('should return true if the user agent is an outdated Firefox version', function () {
185192
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:22.0) Gecko/20100101 Firefox/22.0')).toBeTruthy();
186193
expect(setup('Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1')).toBeTruthy();
187194
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();
195+
// Firefox 31 non-ESR
196+
expect(setup('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:31.0) Gecko/20100101 Firefox/31.0', '20140716183446')).toBeTruthy();
188197
});
189198

190199
});

0 commit comments

Comments
 (0)