Permalink
Browse files

Merge pull request #6910 from mnoorenberghe/815501-app-install-developer

Bug 815501 - Handle undefined developer name and url in the app install dialog
  • Loading branch information...
2 parents 75f4a1a + f2b01c2 commit 6aa968bde678ae3753e94dc07ead8a5e8f18bc65 @vingtetun vingtetun committed Jan 9, 2013
Showing with 80 additions and 19 deletions.
  1. +2 −2 apps/system/js/app_install_manager.js
  2. +78 −17 apps/system/test/unit/app_install_manager_test.js
View
4 apps/system/js/app_install_manager.js
@@ -115,8 +115,8 @@ var AppInstallManager = {
this.msg.textContent = msg;
if (manifest.developer) {
- this.authorName.textContent = manifest.developer.name;
- this.authorUrl.textContent = manifest.developer.url;
+ this.authorName.textContent = manifest.developer.name || _('unknown');
+ this.authorUrl.textContent = manifest.developer.url || '';
} else {
this.authorName.textContent = _('unknown');
this.authorUrl.textContent = '';
View
95 apps/system/test/unit/app_install_manager_test.js
@@ -267,27 +267,88 @@ suite('system/AppInstallManager >', function() {
'install-app{"name":"Fake app"}');
});
- test('should fill the developer infos', function() {
- assert.equal('Fake dev', AppInstallManager.authorName.textContent);
- assert.equal('http://fakesoftware.com',
- AppInstallManager.authorUrl.textContent);
- });
+ suite('developer infos >', function() {
+ test('should fill the developer infos', function() {
+ assert.equal('Fake dev', AppInstallManager.authorName.textContent);
+ assert.equal('http://fakesoftware.com',
+ AppInstallManager.authorUrl.textContent);
+ });
- test('should tell if the developer is unknown', function() {
- var evt = new MockChromeEvent({
- type: 'webapps-ask-install',
- id: 42,
- app: {
- updateManifest: {
- name: 'Fake app',
- size: 5245678
+ test('should tell if the developer is unknown', function() {
+ var evt = new MockChromeEvent({
+ type: 'webapps-ask-install',
+ id: 42,
+ app: {
+ updateManifest: {
+ name: 'Fake app',
+ size: 5245678
+ }
}
- }
+ });
+
+ AppInstallManager.handleAppInstallPrompt(evt.detail);
+ assert.equal('unknown', AppInstallManager.authorName.textContent);
+ assert.equal('', AppInstallManager.authorUrl.textContent);
});
- AppInstallManager.handleAppInstallPrompt(evt.detail);
- assert.equal('unknown', AppInstallManager.authorName.textContent);
- assert.equal('', AppInstallManager.authorUrl.textContent);
+ test('should handle empty developer object properly', function() {
+ var evt = new MockChromeEvent({
+ type: 'webapps-ask-install',
+ id: 42,
+ app: {
+ updateManifest: {
+ name: 'Fake app',
+ size: 5245678,
+ developer: {}
+ }
+ }
+ });
+
+ AppInstallManager.handleAppInstallPrompt(evt.detail);
+ assert.equal('unknown', AppInstallManager.authorName.textContent);
+ assert.equal('', AppInstallManager.authorUrl.textContent);
+ });
+
+ test('should tell if the developer name is unknown', function() {
+ var evt = new MockChromeEvent({
+ type: 'webapps-ask-install',
+ id: 42,
+ app: {
+ updateManifest: {
+ name: 'Fake app',
+ size: 5245678,
+ developer: {
+ url: 'http://example.com'
+ }
+ }
+ }
+ });
+
+ AppInstallManager.handleAppInstallPrompt(evt.detail);
+ assert.equal('unknown', AppInstallManager.authorName.textContent);
+ assert.equal('http://example.com',
+ AppInstallManager.authorUrl.textContent);
+ });
+
+ test('the developer url should default to blank', function() {
+ var evt = new MockChromeEvent({
+ type: 'webapps-ask-install',
+ id: 42,
+ app: {
+ updateManifest: {
+ name: 'Fake app',
+ size: 5245678,
+ developer: {
+ name: 'Fake dev'
+ }
+ }
+ }
+ });
+
+ AppInstallManager.handleAppInstallPrompt(evt.detail);
+ assert.equal('Fake dev', AppInstallManager.authorName.textContent);
+ assert.equal('', AppInstallManager.authorUrl.textContent);
+ });
});
suite('install size >', function() {

0 comments on commit 6aa968b

Please sign in to comment.