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

Commit

Permalink
Bug 1142572 - merge pull request #29023 from sfoster:manifest-display…
Browse files Browse the repository at this point in the history
…name-bug-1142572 to mozilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed Mar 26, 2015
2 parents f672321 + dedd57b commit b5c4bdf
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 34 deletions.
15 changes: 7 additions & 8 deletions apps/bookmark/js/bookmark_editor.js
Expand Up @@ -6,7 +6,7 @@
var BookmarkEditor = {
BOOKMARK_ICON_SIZE: 60,
APP_ICON_SIZE: 60,

init: function bookmarkEditor_show(options) {
this.data = options.data;
this.onsaved = options.onsaved;
Expand Down Expand Up @@ -86,30 +86,29 @@ var BookmarkEditor = {
this.appIcon.addEventListener('load', this.appIconListener);
this.appIcon.setAttribute('src', iconURL);
},

_handleAppIconLoad: function _handleAppIconLoad() {
this.appIconPlaceholder.classList.add('hidden');
this.appIcon.classList.remove('hidden');
this.appIcon.removeEventListener('load', this.appIconListener);
},

_fetchManifest: function bookmarkEditor_fetchManifest(manifestURL) {
var manifestPromise = window.WebManifestHelper.getManifest(manifestURL);

manifestPromise.then((function(manifestData) {
if (manifestData) {
this.installAppButtonListener = this._installApp.bind(this);
this.installAppButton.addEventListener('click',
this.installAppButtonListener);
this.appNameText.textContent = manifestData.short_name ||
manifestData.name;
this.appNameText.textContent = manifestData.displayName;
this.appInstallationSection.classList.remove('hidden');
this._renderAppIcon(manifestData, manifestURL, this.APP_ICON_SIZE);
}
}).bind(this)).catch(function(error) {
console.error('Unable to get web manifest: ' + error);
});

return manifestPromise;
},

Expand Down Expand Up @@ -143,7 +142,7 @@ var BookmarkEditor = {
var title = this.bookmarkTitle.value.trim();
this.saveButton.disabled = title === '';
},

_installApp: function bookmarkEditor_installApp() {
window.navigator.mozApps.install(this.manifestURL);
},
Expand Down
6 changes: 5 additions & 1 deletion apps/bookmark/test/unit/mock_web_manifest_helper.js
Expand Up @@ -3,7 +3,11 @@
/* exported MockWebManifestHelper */
var MockWebManifestHelper = {
getManifest: function(manifestURL) {
return Promise.resolve({'short_name': 'App', 'name': 'My App'});
return Promise.resolve({
'short_name': 'App',
'name': 'My App',
'displayName': 'App'
});
},

iconURLForSize: function(manifest, manifestURL, size) {
Expand Down
Expand Up @@ -47,7 +47,7 @@ define(function(require) {
var manifest = new ManifestHelper(app.manifest ?
app.manifest : app.updateManifest);
var developer = manifest.developer;
elements.detailTitle.textContent = manifest.short_name || manifest.name;
elements.detailTitle.textContent = manifest.displayName;
elements.uninstallButton.disabled = !app.removable;
if (!developer || !('name' in developer)) {
elements.developerInfos.hidden = true;
Expand Down
Expand Up @@ -207,7 +207,7 @@ define(function(require) {
var manifest = new ManifestHelper(app.manifest ?
app.manifest : app.updateManifest);
var li = this._genAppItemTemplate({
name: manifest.short_name || manifest.name,
name: manifest.displayName,
index: index,
iconSrc: this._getBestIconURL(app, manifest.icons)
});
Expand Down
8 changes: 2 additions & 6 deletions apps/system/js/app_window.js
Expand Up @@ -131,13 +131,10 @@
// Store initial configuration in this.config
this.config = configuration;

if (this.manifest) {
this.shortName = new ManifestHelper(this.manifest).short_name;
}
if (!this.manifest && this.config && this.config.title) {
this.updateName(this.config.title);
} else {
this.name = new ManifestHelper(this.manifest).name;
this.name = new ManifestHelper(this.manifest).displayName;
}

// Get icon splash
Expand Down Expand Up @@ -885,8 +882,7 @@
if (!this.manifest) {
return;
}
this.name = new ManifestHelper(this.manifest).name;
this.shortName = new ManifestHelper(this.manifest).short_name;
this.name = new ManifestHelper(this.manifest).displayName;

if (this.identificationTitle) {
this.identificationTitle.textContent = this.name;
Expand Down
3 changes: 1 addition & 2 deletions apps/system/js/card.js
Expand Up @@ -126,8 +126,7 @@
*/
Card.prototype._populateViewData = function() {
var app = this.app;
this.title = (app.isBrowser() && app.title) ?
app.title : app.shortName || app.name;
this.title = (app.isBrowser() && app.title) ? app.title : app.name;
this.sslState = app.getSSLState();
this.subTitle = '';
this.iconValue = '';
Expand Down
5 changes: 3 additions & 2 deletions apps/system/test/unit/app_window_test.js
Expand Up @@ -1927,6 +1927,7 @@ suite('system/AppWindow', function() {
var spyManifestHelper = this.sinon.stub(window, 'ManifestHelper');
spyManifestHelper.returns({
name: 'Mon Application',
displayName: 'Bref',
short_name: 'Bref'
});
var stubPublish = this.sinon.stub(app1, 'publish');
Expand All @@ -1938,8 +1939,8 @@ suite('system/AppWindow', function() {
assert.isTrue(spyManifestHelper.calledWithNew());
assert.isTrue(spyManifestHelper.calledWithExactly(app1.manifest));
assert.isTrue(stubPublish.calledWithExactly('namechanged'));
assert.equal(app1.identificationTitle.textContent, 'Mon Application');
assert.equal(app1.shortName, 'Bref');
assert.equal(app1.identificationTitle.textContent, 'Bref');
assert.equal(app1.name, 'Bref');
});

test('focus event', function() {
Expand Down
12 changes: 0 additions & 12 deletions apps/system/test/unit/card_test.js
Expand Up @@ -14,7 +14,6 @@ suite('system/Card', function() {
return new AppWindow({
launchTime: 4,
name: config.name || 'dummyapp',
shortName: config.shortName,
frame: document.createElement('div'),
iframe: document.createElement('iframe'),
manifest: {
Expand Down Expand Up @@ -158,16 +157,6 @@ suite('system/Card', function() {
assert.equal(appCard.titleNode.textContent, 'otherapp');
});

test('app short name', function() {
var appCard = new Card({
app: makeApp({ name: 'shortname', shortName: 'short' }),
manager: mockManager
});
appCard.app.title = 'Some long title';
appCard.render();
assert.equal(appCard.titleNode.textContent, 'short');
});

test('app security for browser windows', function() {
var browserCard = new Card({
app: makeApp({ name: 'browserwindow' }),
Expand Down Expand Up @@ -217,7 +206,6 @@ suite('system/Card', function() {
test('subTitle when private browser splash', function() {
var app = makeApp({
name: 'shortname',
shortName: 'short',
origin: 'app://system.gaiamobile.org',
url: 'app://system.gaiamobile.org/private_browser.html'
});
Expand Down
2 changes: 1 addition & 1 deletion shared/test/unit/mocks/mock_manifest_helper.js
Expand Up @@ -9,6 +9,6 @@ function MockManifestHelper(manifest) {

Object.defineProperty(MockManifestHelper.prototype, 'displayName', {
get: function displayName() {
return this.name;
return this.short_name || this.name;
}
});

0 comments on commit b5c4bdf

Please sign in to comment.