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 #25099 from cctuan/1081860
Browse files Browse the repository at this point in the history
Bug 1081860 - [NFC][KK] Wording on shrinking UI truncate when keyboard shows up
  • Loading branch information
cctuan committed Oct 15, 2014
2 parents 80db58e + 036c28b commit a18559e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 23 deletions.
10 changes: 9 additions & 1 deletion apps/system/js/app_window.js
Expand Up @@ -692,7 +692,7 @@
'mozbrowsertitlechange', 'mozbrowserlocationchange',
'mozbrowsermetachange', 'mozbrowsericonchange', 'mozbrowserasyncscroll',
'_localized', '_swipein', '_swipeout', '_kill_suspended',
'_orientationchange', '_focus', '_hidewindow', '_sheetdisplayed',
'_orientationchange', '_focus', '_blur', '_hidewindow', '_sheetdisplayed',
'_sheetsgestureend', '_cardviewbeforeshow', '_cardviewclosed',
'_closed', '_shrinkingstart', '_shrinkingstop'];

Expand Down Expand Up @@ -2056,6 +2056,14 @@
}
};

AppWindow.prototype._handle__blur = function() {
var win = this;
while (win.frontWindow && win.frontWindow.isActive()) {
win = win.frontWindow;
}
win.blur();
};

AppWindow.prototype._handle__focus = function() {
var win = this;
while (win.frontWindow && win.frontWindow.isActive()) {
Expand Down
8 changes: 8 additions & 0 deletions apps/system/js/app_window_manager.js
Expand Up @@ -301,6 +301,8 @@
window.addEventListener('permissiondialoghide', this);
window.addEventListener('appopening', this);
window.addEventListener('localized', this);
window.addEventListener('shrinking-start', this);
window.addEventListener('shrinking-stop', this);

window.addEventListener('mozChromeEvent', this);

Expand Down Expand Up @@ -387,6 +389,8 @@
window.removeEventListener('appopening', this);
window.removeEventListener('localized', this);
window.removeEventListener('mozChromeEvent', this);
window.removeEventListener('shrinking-start', this);
window.removeEventListener('shrinking-stop', this);

for (var name in this._settingsObserveHandler) {
SettingsListener.unobserve(
Expand All @@ -403,6 +407,10 @@
var activeApp = this._activeApp;
var detail = evt.detail;
switch (evt.type) {
case 'shrinking-start':
activeApp && activeApp.broadcast('blur');
break;
case 'shrinking-stop':
case 'permissiondialoghide':
activeApp && activeApp.broadcast('focus');
break;
Expand Down
6 changes: 0 additions & 6 deletions apps/system/js/keyboard_manager.js
Expand Up @@ -106,7 +106,6 @@ var KeyboardManager = {
window.addEventListener('mozmemorypressure', this);
window.addEventListener('sheets-gesture-begin', this);
window.addEventListener('lockscreen-appopened', this);
window.addEventListener('screenchange', this);

// To handle keyboard layout switching
window.addEventListener('mozChromeEvent', this);
Expand Down Expand Up @@ -278,11 +277,6 @@ var KeyboardManager = {
case 'activityclosing':
this.hideKeyboardImmediately();
break;
case 'screenchange':
if (!evt.detail.screenEnabled) {
this.hideKeyboardImmediately();
}
break;
case 'mozbrowsererror': // OOM
this.removeKeyboard(evt.target.dataset.frameManifestURL, true);
break;
Expand Down
20 changes: 20 additions & 0 deletions apps/system/test/unit/app_window_manager_test.js
Expand Up @@ -221,6 +221,26 @@ suite('system/AppWindowManager', function() {
'inputmethod-contextchange', detail));
});

test('When receiving shrinking-start, we need to blur the active app',
function() {
var stubFocus = this.sinon.stub(app1, 'broadcast');
appWindowManager._activeApp = app1;
appWindowManager.handleEvent({
type: 'shrinking-start'
});
assert.isTrue(stubFocus.calledWith('blur'));
});

test('When receiving shrinking-stop, we need to focus the active app',
function() {
var stubFocus = this.sinon.stub(app1, 'broadcast');
appWindowManager._activeApp = app1;
appWindowManager.handleEvent({
type: 'shrinking-stop'
});
assert.isTrue(stubFocus.calledWith('focus'));
});

test('When permission dialog is closed, we need to focus the active app',
function() {
var stubFocus = this.sinon.stub(app1, 'broadcast');
Expand Down
22 changes: 22 additions & 0 deletions apps/system/test/unit/app_window_test.js
Expand Up @@ -1599,6 +1599,28 @@ suite('system/AppWindow', function() {
assert.equal(app1.identificationTitle.textContent, 'Mon Application');
});

test('focus event', function() {
var app1 = new AppWindow(fakeAppConfig1);
var stubFocus = this.sinon.stub(app1, 'focus');

app1.handleEvent({
type: '_focus'
});

assert.isTrue(stubFocus.calledOnce);
});

test('blur event', function() {
var app1 = new AppWindow(fakeAppConfig1);
var stubBlur = this.sinon.stub(app1, 'blur');

app1.handleEvent({
type: '_blur'
});

assert.isTrue(stubBlur.calledOnce);
});

test('Titilechange event', function() {
var app1 = new AppWindow(fakeWrapperConfig);
var stubPublish = this.sinon.stub(app1, 'publish');
Expand Down
16 changes: 0 additions & 16 deletions apps/system/test/unit/keyboard_manager_test.js
Expand Up @@ -687,22 +687,6 @@ suite('KeyboardManager', function() {
assert.ok(removeKeyboard.calledWith(fakeManifestURL));
});

test('screenchange event', function() {
trigger('screenchange', {
screenEnabled: true
});

sinon.assert.callCount(hideKeyboardImmediately, 0, 'should not be ' +
'called if screen is turned on');

trigger('screenchange', {
screenEnabled: false
});

sinon.assert.callCount(hideKeyboardImmediately, 1, 'should be called ' +
'once if screen is turned off');
});

test('attentionrequestopen event', function() {
trigger('attentionrequestopen');

Expand Down

0 comments on commit a18559e

Please sign in to comment.