Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(client): Firefox for Android Sync marketing material is only avai…
Browse files Browse the repository at this point in the history
…lable to desktop sync users.

fixes #1041
  • Loading branch information
Shane Tomlinson committed Jun 25, 2014
1 parent 8c0e091 commit c5e62fa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
18 changes: 11 additions & 7 deletions app/scripts/views/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,25 @@ function (_, BaseView, FormView, Template, Session, Xss, Strings, OAuthMixin) {
return Math.random() <= (surveyPercentage / 100);
},

_shouldShowSignUpMarketing: function (showSurvey) {
if (! this.is('sign_up') || showSurvey) {
return false;
}
_shouldShowSignUpMarketing: function (isSurveyVisible) {
var isSignUp = this.is('sign_up');
var isSync = Session.service === 'sync';
var isFirefoxMobile = this._isFirefoxMobile();

return ! isSurveyVisible && isSignUp && isSync && ! isFirefoxMobile;
},

_isFirefoxMobile: function () {
// For UA information, see
// https://developer.mozilla.org/docs/Gecko_user_agent_string_reference

var ua = this.window.navigator.userAgent;

// covers both B2G and Firefox for Android
var isMobileFirefox = ua.indexOf('Mobile') > -1 && ua.indexOf('Firefox') > -1;
var isTabletFirefox = ua.indexOf('Tablet') > -1 && ua.indexOf('Firefox') > -1;
var isMobileFirefox = /Mobile/.test(ua) && /Firefox/.test(ua);
var isTabletFirefox = /Tablet/.test(ua) && /Firefox/.test(ua);

return ! (isMobileFirefox || isTabletFirefox);
return isMobileFirefox || isTabletFirefox;
},

afterRender: function() {
Expand Down
20 changes: 18 additions & 2 deletions app/tests/spec/views/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,33 @@ function (chai, View, Session, WindowMock) {
});
});

it('normally shows sign up marketing material', function () {
it('normally shows sign up marketing material to desktop sync users', function () {
view.type = 'sign_up';
windowMock.navigator.userAgent = 'Mozilla/5.0 (Windows NT x.y; rv:31.0) Gecko/20100101 Firefox/31.0';
Session.set('service', 'sync');

return view.render()
.then(function () {
assert.equal(view.$('.marketing.survey').length, 0);
assert.equal(view.$('.marketing.default').length, 1);
});
});

it('does not show sign up marketing material to non-sync users', function () {
view.type = 'sign_up';
windowMock.navigator.userAgent = 'Mozilla/5.0 (Windows NT x.y; rv:31.0) Gecko/20100101 Firefox/31.0';

return view.render()
.then(function () {
assert.equal(view.$('.marketing.survey').length, 0);
assert.equal(view.$('.marketing.default').length, 0);
});
});

it('does not show sign up marketing material if on Firefox for Android', function () {
view.type = 'sign_up';
windowMock.navigator.userAgent = 'Mozilla/5.0 (Android; Tablet; rv:26.0) Gecko/26.0 Firefox/26.0';
Session.set('service', 'sync');

return view.render()
.then(function () {
Expand All @@ -166,6 +180,7 @@ function (chai, View, Session, WindowMock) {
it('does not show sign up marketing material if on B2G', function () {
view.type = 'sign_up';
windowMock.navigator.userAgent = 'Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0';
Session.set('service', 'sync');

return view.render()
.then(function () {
Expand All @@ -186,8 +201,9 @@ function (chai, View, Session, WindowMock) {
});
});

it('still shows default marketing to non-english users', function () {
it('still shows default marketing to non-english desktop sync users', function () {
Session.set('language', 'de');
Session.set('service', 'sync');
createViewWithSurvey();
view.type = 'sign_up';

Expand Down

0 comments on commit c5e62fa

Please sign in to comment.