Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#23404 from alivedise/bugzilla/1039955/…
Browse files Browse the repository at this point in the history
…circular-activity

Bug 1039955 - Fix direct circular activity, r=etienne
(cherry picked from commit 3f59dcd)
  • Loading branch information
alivedise authored and etiennesegonzac committed Aug 29, 2014
1 parent e466549 commit 58f6b58
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 6 additions & 2 deletions apps/system/js/app_window_manager.js
Expand Up @@ -656,8 +656,12 @@
var caller;
var callee = this.getApp(config.origin);
caller = this._activeApp.getTopMostWindow();
callee.callerWindow = caller;
caller.calleeWindow = callee;
if (caller.getBottomMostWindow() === callee) {
callee.frontWindow.kill();
} else {
callee.callerWindow = caller;
caller.calleeWindow = callee;
}
},

debug: function awm_debug() {
Expand Down
20 changes: 19 additions & 1 deletion apps/system/test/unit/app_window_manager_test.js
Expand Up @@ -758,7 +758,6 @@ suite('system/AppWindowManager', function() {
// callee is app7, caller is app2
injectRunningApps(app7);
AppWindowManager._activeApp = app1;
fakeAppConfig.parentApp = '';
this.sinon.stub(app1, 'getTopMostWindow').returns(app2);

AppWindowManager.linkWindowActivity(fakeAppConfig);
Expand All @@ -767,6 +766,25 @@ suite('system/AppWindowManager', function() {
assert.deepEqual(app7.callerWindow, app2);
assert.isFalse(homescreenLauncher.getHomescreen.called);
});

test('If there is a direct circular activity, ' +
'close the frontwindow to reveal the callee',
function() {
// callee is app1, caller is app3(a front window)
injectRunningApps(app1);
AppWindowManager._activeApp = app1;
fakeAppConfig.parentApp = '';
app1.frontWindow = app3;
this.sinon.stub(app1, 'getTopMostWindow').returns(app3);
this.sinon.stub(app3, 'getBottomMostWindow').returns(app1);
var stubKill = this.sinon.stub(app3, 'kill');

AppWindowManager.linkWindowActivity(fakeAppConfig1);

assert.isTrue(stubKill.called);
assert.isUndefined(app1.callerWindow);
app1.frontWindow = null;
});
});

test('getApp', function() {
Expand Down
1 change: 1 addition & 0 deletions apps/system/test/unit/mock_app_window.js
Expand Up @@ -75,6 +75,7 @@
modifyURLatBackground: function() {},
getFrameForScreenshot: function() { return this.browser.element; },
getTopMostWindow: function() { return this; },
getBottomMostWindow: function() { return this; },
determineClosingRotationDegree: function() { return 0; },
isTransitioning: function() { return false; },
calibratedHeight: function() { return false; },
Expand Down

0 comments on commit 58f6b58

Please sign in to comment.