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

Commit

Permalink
Bug 1155701 - merge pull request #29572 from julienw:1155701-app-no-a…
Browse files Browse the repository at this point in the history
…ctivity to mozilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed Apr 20, 2015
2 parents 50dde3f + 5fbf78e commit 11a7d84
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/system/js/activities.js
Expand Up @@ -19,6 +19,15 @@
Activities.prototype = {
/** @lends Activities */

/**
* Remove all event listeners. This is mainly used in unit tests.
*/
destroy: function() {
window.removeEventListener('mozChromeEvent', this);
window.removeEventListener('appopened', this);
window.removeEventListener('applicationinstall', this);
},

/**
* General event handler interface.
* Updates the overlay with as we receive load events.
Expand Down Expand Up @@ -48,6 +57,9 @@

_onNewAppInstalled: function(app) {
var activities = app && app.manifest && app.manifest.activities;
if (!activities) {
return;
}

Object.keys(activities).forEach(function(activity) {
var filters = activities[activity].filters;
Expand Down
14 changes: 14 additions & 0 deletions apps/system/test/unit/activities_test.js
Expand Up @@ -390,6 +390,20 @@ suite('system/Activities', function() {
subject = new Activities();
});

teardown(function() {
subject.destroy();
});

test('correctly handles apps without activities', function() {
var appWithoutActivities = {
'manifest': {}
};

assert.doesNotThrow(
() => subject._onNewAppInstalled(appWithoutActivities)
);
});

test('manages the default launch for the app\'s activities', function() {
DefaultActivityHelper.getDefaultAction
.returns({ // instead of Promise.resolve() to return in same cycle
Expand Down

0 comments on commit 11a7d84

Please sign in to comment.