From bef8315460dbca67765055b174ea65c48be26c0e Mon Sep 17 00:00:00 2001 From: Greg Weng Date: Wed, 25 Nov 2015 11:43:19 +0800 Subject: [PATCH] Bug 1227089 - fixed: remove overlay hidden and postpone the class adding action --- apps/system/lockscreen/js/lockscreen.js | 12 ++++-------- .../test/unit/lockscreen/lockscreen_test.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apps/system/lockscreen/js/lockscreen.js b/apps/system/lockscreen/js/lockscreen.js index 574182219b4b..f492e31fa1fe 100644 --- a/apps/system/lockscreen/js/lockscreen.js +++ b/apps/system/lockscreen/js/lockscreen.js @@ -192,7 +192,7 @@ } if (!this.locked) { - this.overlay.hidden = true; + this.overlay.classList.add('unlocked'); this.unlockDetail = undefined; } break; @@ -530,13 +530,11 @@ this.overlay.classList.toggle('no-transition', instant); this.dispatchEvent('lockscreen-request-unlock', this._unlockingMessage); this.dispatchEvent('secure-modeoff'); - this.overlay.classList.add('unlocked'); - - // If we don't unlock instantly here, - // these are run in transitioned callback. if (instant) { - this.overlay.hidden = true; + this.overlay.classList.add('unlocked'); + // Otherwise, postpone it to transitionend. } + // Clear the state after we send the request. this._unlockingMessage = {}; }; @@ -545,8 +543,6 @@ this.overlay.focus(); this.overlay.classList.toggle('no-transition', instant); this.overlay.classList.remove('unlocked'); - this.overlay.hidden = false; - }; LockScreen.prototype.lock = diff --git a/apps/system/test/unit/lockscreen/lockscreen_test.js b/apps/system/test/unit/lockscreen/lockscreen_test.js index cd9fcd2b473d..1f2b1d1276ef 100644 --- a/apps/system/test/unit/lockscreen/lockscreen_test.js +++ b/apps/system/test/unit/lockscreen/lockscreen_test.js @@ -548,6 +548,24 @@ suite('system/LockScreen >', function() { stubDispatch.restore(); }); + test('Handle event: when unlock animation ends,' + + 'it would add `unlocked` class', + function() { + assert.isFalse(subject.overlay.classList.contains('unlocked')); + subject.locked = false; + subject.handleEvent({ type: 'transitionend', target: subject.overlay }); + assert.isTrue(subject.overlay.classList.contains('unlocked')); + }); + + test('Unlock method will add `unlocked` class if it is not an' + + ' instant request', + function() { + assert.isFalse(subject.overlay.classList.contains('unlocked')); + subject.enabled = true; + subject.unlock(true); // or lock screen is already enabled + assert.isTrue(subject.overlay.classList.contains('unlocked')); + }); + test('Switch panel: to Camera; should notify SecureWindowFactory\'s method', function() { var stubDispatch = this.sinon.stub(window, 'dispatchEvent');