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

Commit

Permalink
Bug 1124265 - Wait for app to install before inspecting it's manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
timdream authored and rvandermeulen committed Jan 23, 2015
1 parent 2ac9e58 commit 34f1dd6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
36 changes: 36 additions & 0 deletions apps/system/test/unit/input_app_list_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,42 @@ suite('InputAppList', function() {
});
});

test('install app -- mark as downloading', function(done) {
var newApp = Object.create(INPUT_APP);
var manifest = newApp.manifest;

newApp.manifestURL = 'app://myfunnykeyboard.org/manifest.webapp';
newApp.downloading = true;
newApp.manifest = undefined;

// XXX: newApp should be a MockEventTarget instance,
// but we are too lazy to make a real MockDOMApplication here.
newApp.addEventListener = this.sinon.stub();

list.onupdate = function(inputApps) {
assert.deepEqual(inputApps, [ INPUT_APP, newApp ]);
assert.deepEqual(list.getListSync(), [ INPUT_APP, newApp ]);

done();
};

navigator.mozApps.mgmt.dispatchEvent({
type: 'install',
application: newApp
});

assert.isTrue(
newApp.addEventListener.calledWith('downloadsuccess', list));

newApp.downloading = false;
newApp.manifest = manifest;

list.handleEvent({
type: 'downloadsuccess',
target: newApp
});
});

test('install non-input app', function() {
var newApp = Object.create(INPUT_APP);
newApp.manifest = Object.create(INPUT_APP.manifest);
Expand Down
15 changes: 14 additions & 1 deletion shared/js/input_mgmt/input_app_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,20 @@ InputAppList.prototype.handleEvent = function(evt) {

switch (evt.type) {
case 'install':
updated = this._addInputApp(evt.application);
var app = evt.application;
if (app.downloading) {
// App is currently being downloaded;
// wait for download to complete as manifest is not available now.
app.addEventListener('downloadsuccess', this);
return;
}

updated = this._addInputApp(app);

break;

case 'downloadsuccess':
updated = this._addInputApp(evt.target);

break;

Expand Down

0 comments on commit 34f1dd6

Please sign in to comment.