Bug 1493546 - Only uppercase printable keys when shift modifier is set. r=ato

Differential Revision: https://phabricator.services.mozilla.com/D6776

--HG--
extra : rebase_source : eee9c7ef3fa76599de434c9826f404d8bac1e781
extra : histedit_source : 3c5cc32843d88ccc4c2d8efc360f384889e0ba08
This commit is contained in:
Henrik Skupin 2018-09-25 13:01:21 +01:00
parent 0d889dc646
commit 01cffaf96b
3 changed files with 25 additions and 1 deletions

View File

@ -456,6 +456,8 @@ function createKeyboardEventDictionary_(key, keyEvent, win) {
keyEvent.keyCode : 0;
let keyName = "Unidentified";
let printable = false;
if (key.indexOf("KEY_") == 0) {
keyName = key.substr("KEY_".length);
result.flags |= Ci.nsITextInputProcessor.KEY_NON_PRINTABLE_KEY;
@ -479,6 +481,7 @@ function createKeyboardEventDictionary_(key, keyEvent, win) {
// only force printable if "raw character" and event key match, like "a"
if (!("key" in keyEvent && key != keyEvent.key)) {
result.flags |= Ci.nsITextInputProcessor.KEY_FORCE_PRINTABLE_KEY;
printable = true;
}
}
@ -488,7 +491,7 @@ function createKeyboardEventDictionary_(key, keyEvent, win) {
}
let resultKey = "key" in keyEvent ? keyEvent.key : keyName;
if (!MODIFIER_KEYCODES_LOOKUP[key] && keyEvent.shiftKey) {
if (printable && keyEvent.shiftKey) {
resultKey = resultKey.toUpperCase();
}

View File

@ -16,6 +16,14 @@ def test_no_browsing_context(session, closed_window, key_chain):
key_chain.key_up("a").perform()
def test_element_not_focused(session, test_actions_page, key_chain):
key_reporter = session.find.css("#keys", all=False)
key_chain.key_down("a").key_up("a").perform()
assert get_keys(key_reporter) == ""
def test_backspace_erases_keys(session, key_reporter, key_chain):
key_chain \
.send_keys("efcd") \

View File

@ -3,6 +3,19 @@ import pytest
from tests.perform_actions.support.keys import Keys
@pytest.mark.parametrize("modifier", [Keys.SHIFT, Keys.R_SHIFT])
def test_shift_modifier_and_non_printable_keys(session, key_reporter, key_chain, modifier):
key_chain \
.send_keys("foo") \
.key_down(modifier) \
.key_down(Keys.BACKSPACE) \
.key_up(modifier) \
.key_up(Keys.BACKSPACE) \
.perform()
assert key_reporter.property("value") == "fo"
@pytest.mark.parametrize("modifier", [Keys.SHIFT, Keys.R_SHIFT])
def test_shift_modifier_generates_capital_letters(session, key_reporter, key_chain, modifier):
key_chain \