Bug 690022 - Android back (escape) key should close the locale picker [r=wesj]

This commit is contained in:
Matt Brubeck 2011-10-06 12:34:14 -07:00
parent 0c375c8e29
commit 7d34c6746a
4 changed files with 63 additions and 0 deletions

View File

@ -204,6 +204,21 @@ let LocaleUI = {
}
},
goBack: function goBack() {
switch (this.selectedPanel) {
case this.mainPage:
// Do nothing on the "Loading..." screen.
break;
case this.pickerpage:
this.cancelPicker();
break;
case this.installerPage:
this.cancelInstall();
this.showPicker();
break;
}
},
cancelPicker: function() {
if (this.pendingInstall)
this.pendingInstall = null;

View File

@ -11,6 +11,9 @@
<script src="chrome://browser/content/Util.js" type="application/javascript;version=1.8"/>
<script src="chrome://browser/content/input.js" type="application/javascript;version=1.8"/>
<script src="chrome://browser/content/localePicker.js" type="application/javascript;version=1.8"/>
<keyset id="mainKeyset">
<key id="key_esc" keycode="VK_ESCAPE" oncommand="LocaleUI.goBack();"/>
</keyset>
<deck id="language-deck" flex="1">
<vbox id="main-page" class="pane" flex="1">
<spacer flex="1"/>

View File

@ -75,6 +75,7 @@ _BROWSER_FILES = \
$(warning browser_formsZoom.js disabled due to failures) \
browser_history.js \
browser_localepicker.js \
browser_localepicker_escape.js \
browser_mainui.js \
browser_preferences_text.js \
browser_preferences_fulltoggle.js \

View File

@ -0,0 +1,44 @@
Components.utils.import("resource://gre/modules/Services.jsm");
var gWin;
function test() {
waitForExplicitFinish();
gWin = Services.ww.openWindow(window, "chrome://browser/content/localePicker.xul", "_browser", "chrome,dialog=no,all", null);
gWin.addEventListener("load", onload, false);
}
function onload(aEvent) {
gWin.removeEventListener("load", onload, false);
ok(true, "Locale picker is opened.");
setTimeout(afterLoad, 0);
}
function afterLoad() {
let ui = gWin.LocaleUI;
is(ui.selectedPanel, ui.pickerpage, "Picker page is selected.");
ui.selectedPanel = ui.mainPage;
is(ui.selectedPanel, ui.mainPage, "Select the main page.");
sendEscape();
is(ui.selectedPanel, ui.mainPage, "Main page is still selected (escape key does nothing).");
ui.selectedPanel = ui.installerPage;
is(ui.selectedPanel, ui.installerPage, "Select the installer page.");
sendEscape();
is(ui.selectedPanel, ui.pickerpage, "Escape key goes back to the picker page.");
gWin.addEventListener("unload", windowClosed, false);
sendEscape();
}
function windowClosed() {
gWin.removeEventListener("unload", windowClosed, false);
ok(true, "Locale picker is closed.");
finish();
}
function sendEscape() {
info("Sending escape key.");
EventUtils.synthesizeKey("VK_ESCAPE", { type: "keypress" }, gWin);
}