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

Commit

Permalink
Merge pull request #14422 from etiennesegonzac/bug-943236-edge-gestur…
Browse files Browse the repository at this point in the history
…e-logic

Bug 943236 - Move the current app to the top of the stack if the app opens a window. r=alive
  • Loading branch information
etiennesegonzac committed Dec 10, 2013
2 parents 60dc82e + 65db7ce commit c952e27
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/system/js/stack_manager.js
Expand Up @@ -53,23 +53,24 @@ var StackManager = {
if (app.stayBackground) {
this._insertBelow(app);
} else {
this._moveToTop(this._current);
this._insertOnTop(app);
}
break;
case 'launchapp':
case 'launchwrapper':
var config = e.detail;
if (!config.stayBackground) {
this._moveToTop(this._current);

var idx = this._indexOfURL(config.url);
if (idx !== undefined) {
this._moveToTop(idx);
}
}
break;
case 'home':
if (this._stack.length > 1) {
this._moveToTop(this._current);
}
this._moveToTop(this._current);
break;
case 'appterminated':
var manifestURL = e.detail.manifestURL;
Expand All @@ -92,6 +93,10 @@ var StackManager = {
},

_moveToTop: function sm_moveToTop(index) {
if (index >= this._stack.length) {
return;
}

var sheet = this._stack.splice(index, 1)[0];
this._current = this._stack.push(sheet) - 1;
},
Expand Down
24 changes: 24 additions & 0 deletions apps/system/test/unit/stack_manager_test.js
Expand Up @@ -175,6 +175,22 @@ suite('system/StackManager >', function() {
assert.deepEqual(StackManager.getPrev(), dialer);
assert.deepEqual(StackManager.getCurrent(), contact);
});

suite('then we go back and launch a third app', function() {
setup(function() {
StackManager.goPrev();
appLaunch(settings);
});

test('the current app at the time of the launch should move to the top',
function() {
assert.deepEqual(StackManager.getPrev(), dialer);
});

test('the new app should go on the top', function() {
assert.deepEqual(StackManager.getCurrent(), settings);
});
});
});

suite('if it\'s already in the stack', function() {
Expand All @@ -185,10 +201,18 @@ suite('system/StackManager >', function() {

test('it should go on top of the stack', function() {
appLaunch(dialer, true);

assert.deepEqual(StackManager.getCurrent(), dialer);
assert.deepEqual(StackManager.getPrev(), settings);
});

test('it should bring the current app on top too', function() {
StackManager.goPrev();
appLaunch(dialer, true);

assert.deepEqual(StackManager.getPrev(), contact);
});

test('it should not be duplicated', function() {
appLaunch(dialer, true);

Expand Down

0 comments on commit c952e27

Please sign in to comment.