Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 823150 - App update - fixing the ondownloadavailable callback

r=vingtetun
  • Loading branch information...
commit 66b059946585160c12b4bdedb8ca6e17015e8855 1 parent 0dcc657
@etiennesegonzac etiennesegonzac authored
View
4 apps/system/js/updatable.js
@@ -16,7 +16,9 @@ function AppUpdatable(app) {
this._mgmt = navigator.mozApps.mgmt;
this.app = app;
- this.name = new ManifestHelper(app.manifest).name;
+ var manifest = app.manifest ? app.manifest : app.updateManifest;
+ this.name = new ManifestHelper(manifest).name;
+
this.size = app.updateManifest ? app.updateManifest.size : null;
app.ondownloadavailable = this.availableCallBack.bind(this);
}
View
17 apps/system/test/unit/updatable_test.js
@@ -24,6 +24,9 @@ if (!this.WindowManager) {
if (!this.UtilityTray) {
this.UtilityTray = null;
}
+if (!this.ManifestHelper) {
+ this.ManifestHelper = null;
+}
suite('system/Updatable', function() {
var subject;
@@ -35,6 +38,7 @@ suite('system/Updatable', function() {
var realDispatchEvent;
var realCustomDialog;
var realL10n;
+ var realManifestHelper;
var lastDispatchedEvent = null;
var fakeDispatchEvent;
@@ -58,6 +62,11 @@ suite('system/Updatable', function() {
return key;
}
};
+
+ realManifestHelper = window.ManifestHelper;
+ window.ManifestHelper = function mockMH(manifest) {
+ return manifest;
+ };
});
suiteTeardown(function() {
@@ -67,6 +76,7 @@ suite('system/Updatable', function() {
window.UtilityTray = realUtilityTray;
navigator.mozL10n = realL10n;
+ window.ManifestHelper = realManifestHelper;
});
setup(function() {
@@ -98,6 +108,13 @@ suite('system/Updatable', function() {
test('should keep a reference to the app', function() {
assert.equal(mockApp, subject.app);
});
+
+ test('should handle fresh app with just an updateManifest', function() {
+ var freshApp = new MockApp();
+ freshApp.manifest = undefined;
+ subject = new AppUpdatable(freshApp);
+ assert.equal(freshApp, subject.app);
+ });
});
suite('infos', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.