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 #18100 from timdream/window-homescreen-restart-v1.3t
Browse files Browse the repository at this point in the history
Bug 992749 - Prevent homescreen from being restarted when visibility state is noy synced yet, r=alive
  • Loading branch information
timdream committed Apr 9, 2014
2 parents 643f3e6 + 8bf29fa commit d735928
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions apps/system/js/homescreen_window.js
Expand Up @@ -36,6 +36,7 @@
HomescreenWindow.prototype.render = function hw_render() {
// reset transition state.
this._transitionState = 'closed';
this._selfVisibilityState = 'background';
this.publish('willrender');
this.containerElement.insertAdjacentHTML('beforeend', this.view());
this.browser = new BrowserFrame(this.browser_config);
Expand Down Expand Up @@ -122,8 +123,10 @@

// If we're displayed, restart immediately.
this.debug(this._visibilityState);
if (this._visibilityState == 'foreground' ||
this.element.classList.contains('active')) {
this.debug(this._selfVisibilityState);
this.debug(AttentionScreen.isVisible());
if (this._selfVisibilityState == 'foreground' &&
!AttentionScreen.isVisible()) {
this.kill();

// XXX workaround bug 810431.
Expand Down
12 changes: 12 additions & 0 deletions apps/system/js/window.js
Expand Up @@ -66,6 +66,16 @@
*/
AppWindow.prototype._visibilityState = 'foreground';

/**
* Represent the current page visibility state from system app side,
* i.e. what is currently visible. Possible value:
* 'foreground': setVisible(true)
* 'background': setVisible(false)
*
* Default value is background.
*/
AppWindow.prototype._selfVisibilityState = 'background';

/**
* The rotating degree of current frame.
*/
Expand Down Expand Up @@ -106,10 +116,12 @@
function aw_setVisible(visible, screenshotIfInvisible) {
this.debug('set visibility -> ', visible);
if (visible) {
this._selfVisibilityState = 'foreground';
this.frame.removeAttribute('aria-hidden');
this._screenshotOverlayState = 'frame';
this._showFrame();
} else {
this._selfVisibilityState = 'background';
this.frame.setAttribute('aria-hidden', 'true');
if (screenshotIfInvisible) {
this._screenshotOverlayState = 'screenshot';
Expand Down
4 changes: 2 additions & 2 deletions apps/system/test/unit/homescreen_window_test.js
Expand Up @@ -183,7 +183,7 @@ suite('system/HomescreenWindow', function() {

test('Homescreen is crashed at foreground:' +
'rerender right away.', function() {
homescreenWindow._visibilityState = 'foreground';
homescreenWindow._selfVisibilityState = 'foreground';
homescreenWindow.restart();
assert.isTrue(stubKill.called);
clock.tick(1);
Expand All @@ -192,7 +192,7 @@ suite('system/HomescreenWindow', function() {
});

test('Homescreen is crashed at background: killed', function() {
homescreenWindow._visibilityState = 'background';
homescreenWindow._selfVisibilityState = 'background';
homescreenWindow.restart();
assert.isTrue(stubKill.called);
});
Expand Down

0 comments on commit d735928

Please sign in to comment.