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 #25300 from cctuan/1081860-r-v21
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
rvandermeulen committed Oct 20, 2014
2 parents 9d5d4d8 + d728872 commit 6456e9d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
10 changes: 9 additions & 1 deletion apps/system/js/app_window.js
Expand Up @@ -690,7 +690,7 @@
'mozbrowsertitlechange', 'mozbrowserlocationchange',
'mozbrowsermetachange', 'mozbrowsericonchange', 'mozbrowserasyncscroll',
'_localized', '_swipein', '_swipeout', '_kill_suspended',
'_orientationchange', '_focus', '_hidewindow', '_sheetdisplayed',
'_orientationchange', '_focus', '_blur', '_hidewindow', '_sheetdisplayed',
'_sheetsgestureend', '_closed', '_shrinkingstart', '_shrinkingstop'];

AppWindow.SUB_COMPONENTS = {
Expand Down Expand Up @@ -2043,6 +2043,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 @@ -293,6 +293,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 @@ -364,6 +366,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 @@ -380,6 +384,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
20 changes: 20 additions & 0 deletions apps/system/test/unit/app_window_manager_test.js
Expand Up @@ -229,6 +229,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 @@ -1581,6 +1581,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
Expand Up @@ -9,8 +9,8 @@
class TestLaunchViaManifest(GaiaTestCase):

def test_launch_manifest(self):
browser_manifest_url = 'app://browser.gaiamobile.org/manifest.webapp'
browser_manifest_url = 'app://search.gaiamobile.org/manifest.webapp'

app = self.apps.launch('Browser', manifest_url=browser_manifest_url)
self.assertTrue(app.frame)
Wait(self.marionette).until(lambda m: 'browser' in m.get_url())
Wait(self.marionette).until(lambda m: 'search' in m.get_url())

0 comments on commit 6456e9d

Please sign in to comment.