added notify balloon if !navigator.mozApps (bug 680602)

This commit is contained in:
Davor Spasovski 2011-10-26 16:04:30 -07:00
Родитель 9254d08b33
Коммит a9dd6e0b0b
7 изменённых файлов: 112 добавлений и 2 удалений

Просмотреть файл

@ -74,6 +74,7 @@ class TestHome(amo.tests.TestCase):
eq_(doc('#site-notice').length, 0)
eq_(doc('#site-nonfx').length, 1)
eq_(doc('#site-welcome').length, 1)
eq_(doc('#site-noinstall-apps').length, 0)
@mock.patch.object(settings, 'READ_ONLY', True)
def test_balloons_readonly(self):
@ -82,6 +83,7 @@ class TestHome(amo.tests.TestCase):
eq_(doc('#site-notice').length, 1)
eq_(doc('#site-nonfx').length, 1)
eq_(doc('#site-welcome').length, 1)
eq_(doc('#site-noinstall-apps').length, 0)
def test_tools_regular_user(self):
self.client.login(username='regular@mozilla.com', password='password')

Просмотреть файл

@ -11,7 +11,18 @@
{% block aux_nav %}{% endblock %}
{% block amo_balloons %}{% endblock %}
{% block amo_balloons %}
<div class="site-balloon" id="site-noinstall-apps">
<p>
{% trans url='http://mozilla.org/firefox/?src=amo' %}
It seems your browser does not support Open Web Apps. Consider
downloading <a href="{{ url }}">Mozilla Firefox</a>,
a fast, free way to surf the Web!
{% endtrans %}
</p>
<a href="#" class="close">{{ _('Close') }}</a>
</div>
{% endblock %}
{% block footer %}
{% include "amo_footer_small.html" %}

Просмотреть файл

@ -58,6 +58,7 @@ class TestListing(WebappTest):
eq_(doc('#site-notice').length, 0)
eq_(doc('#site-nonfx').length, 0)
eq_(doc('#site-welcome').length, 0)
eq_(doc('#site-noinstall-apps').length, 1)
@patch.object(settings, 'READ_ONLY', True)
def test_balloons_readonly(self):
@ -66,6 +67,7 @@ class TestListing(WebappTest):
eq_(doc('#site-notice').length, 1)
eq_(doc('#site-nonfx').length, 0)
eq_(doc('#site-welcome').length, 0)
eq_(doc('#site-noinstall-apps').length, 1)
def test_footer(self):
response = self.client.get(self.url)

Просмотреть файл

@ -4,7 +4,8 @@ z.capabilities = {
'debug_in_page': (('' + document.location).indexOf('dbginpage') >= 0),
'console': window.console && (typeof window.console.log == 'function'),
'replaceState': typeof history.replaceState === 'function',
'localStorage': false
'localStorage': false,
'webApps': !!(navigator.mozApps && navigator.mozApps.install)
};

Просмотреть файл

@ -34,6 +34,11 @@ z.visitor = z.Storage('visitor');
// Show the bad-browser message if it has not been dismissed
if (!z.visitor.get('seen_badbrowser_warning') && $('body').hasClass('badbrowser')) {
$('#site-nonfx').show();
} else if (!z.capabilities.webApps) {
// show lack of open web apps support warning balloon
if (!z.visitor.get('seen_noinstall_apps_warning')) {
$('#site-noinstall-apps').show();
}
}
})();
@ -160,6 +165,8 @@ function initBanners(delegate) {
z.visitor.set('seen_badbrowser_warning', 1);
} else if ($parent.is('#acr-pitch')) {
z.visitor.set('seen_acr_pitch', 1);
} else if ($parent.is('#site-noinstall-apps')) {
z.visitor.set('seen_noinstall_apps_warning', 1);
}
}));
}

Просмотреть файл

@ -0,0 +1,76 @@
$(document).ready(function() {
var openWebAppsFixture = {
setup: function(hasAppsSupport, hasSeenAppsSupportWarning) {
this.sandbox = tests.createSandbox('#balloons');
this.visitor = z.Storage('visitor');
this._seen_noinstall_apps_warning = this.visitor.get('seen_noinstall_apps_warning');
this.visitor.remove('seen_noinstall_apps_warning');
var $balloon = $('#site-noinstall-apps', this.sandbox);
// this is normally ensured via CSS
$balloon.hide();
// this is the logic being mocked from global.js
if (!hasAppsSupport && !hasSeenAppsSupportWarning) {
$balloon.show();
}
},
teardown: function() {
this.visitor.set('seen_noinstall_apps_warning', this._seen_noinstall_apps_warning);
this.sandbox.remove();
},
check: function(showWarning) {
var self = this;
if (showWarning) {
equal($('#site-noinstall-apps:visible', this.sandbox).length, 1);
$.when($('#site-noinstall-apps .close', this.sandbox).click()).done(function() {
equal(self.visitor.get('seen_noinstall_apps_warning'), '1');
});
} else {
equal(this.visitor.get('seen_noinstall_apps_warning'), undefined);
equal($('#site-noinstall-apps:hidden', this.sandbox).length, 1);
}
}
};
module('Browser has Open Web Apps Support', $.extend({}, openWebAppsFixture, {
setup: function() {
// Browser has Open Web Apps support (.mozApps) and user hasn't seen the warning
openWebAppsFixture.setup.call(this, true, false);
}
}));
test('No warning balloon', function() {
this.check(false);
});
module('Browser has Open Web Apps Support (seen warning)', $.extend({}, openWebAppsFixture, {
setup: function() {
// Browser has OWA support (.mozApps) and user has seen the warning
openWebAppsFixture.setup.call(this, true, true);
}
}));
test('No warning balloon', function() {
this.check(false);
});
module('Browser has no Open Web Apps Support', $.extend({}, openWebAppsFixture, {
setup: function() {
// Browser has no OWA support and user hasn't seen the warning
openWebAppsFixture.setup.call(this, false, false);
}
}));
test('Show warning balloon', function() {
this.check(true);
});
module('Browser has no Open Web Apps Support (seen warning)', $.extend({}, openWebAppsFixture, {
setup: function() {
// Browser has no OWA support and user has seen the warning
openWebAppsFixture.setup.call(this, false, true);
}
}));
test('No warning balloon', function() {
this.check(false);
});
});

Просмотреть файл

@ -208,4 +208,15 @@
<div id="pjax-results"></div>
</div>
<div id="balloons">
<div class="site-balloon" id="site-noinstall-apps">
<p>
It seems your browser does not support Open Web Apps. Consider
downloading <a href="#">Mozilla Firefox</a>,
a fast, free way to surf the Web!
</p>
<a href="#" class="close">Close</a>
</div>
</div>
{% endblock %}