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 #20121 from timdream/keyboard-hide-lock
Browse files Browse the repository at this point in the history
Bug 1018335 - removeFocus() when the screen is locked, r=rudyl
  • Loading branch information
timdream committed Jun 9, 2014
2 parents 4b40c62 + 0ec259c commit deed49c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/system/js/keyboard_manager.js
Expand Up @@ -140,6 +140,7 @@ var KeyboardManager = {
window.addEventListener('applicationsetupdialogshow', this);
window.addEventListener('mozmemorypressure', this);
window.addEventListener('sheetstransitionstart', this);
window.addEventListener('lock', this);

// To handle keyboard layout switching
window.addEventListener('mozChromeEvent', function(evt) {
Expand Down Expand Up @@ -473,6 +474,8 @@ var KeyboardManager = {
this._debug('mozmemorypressure event; keyboard removed');
}
break;
case 'lock':
/* falls through */
case 'sheetstransitionstart':
if (this.hasActiveKeyboard) {
// Instead of hideKeyboard(), we should removeFocus() here.
Expand Down
16 changes: 16 additions & 0 deletions apps/system/test/unit/keyboard_manager_test.js
Expand Up @@ -518,6 +518,22 @@ suite('KeyboardManager', function() {

KeyboardManager.hasActiveKeyboard = realActive;
});

test('lock event: do nothing if no keyboard', function() {
var spy = this.sinon.spy(navigator.mozInputMethod, 'removeFocus');
trigger('lock');
assert.ok(spy.notCalled);
});

test('lock event: hide keyboard if needed', function() {
var realActive = KeyboardManager.hasActiveKeyboard;
KeyboardManager.hasActiveKeyboard = true;
var spy = this.sinon.spy(navigator.mozInputMethod, 'removeFocus');
trigger('lock');
sinon.assert.calledOnce(spy);

KeyboardManager.hasActiveKeyboard = realActive;
});
});

suite('Hide Keyboard', function() {
Expand Down

0 comments on commit deed49c

Please sign in to comment.