Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correcting keycodes sent for lowercase characters

  • Loading branch information...
commit 395af9cada0c41f3a8186e7c3a8e502730244fca 1 parent c2df526
@jimevans jimevans authored committed
Showing with 25 additions and 2 deletions.
  1. +2 −2 src/webpage.cpp
  2. +23 −0 test/webpage-spec.js
View
4 src/webpage.cpp
@@ -1035,12 +1035,12 @@ void WebPage::sendEvent(const QString &type, const QVariant &arg1, const QVarian
if (arg1.type() == QVariant::Char) {
// a single char was given
text = arg1.toChar();
- key = text.at(0).unicode();
+ key = text.at(0).toUpper().unicode();
} else if (arg1.type() == QVariant::String) {
// javascript invokation of a single char
text = arg1.toString();
if (!text.isEmpty()) {
- key = text.at(0).unicode();
+ key = text.at(0).toUpper().unicode();
}
} else {
// assume a raw integer char code was given
View
23 test/webpage-spec.js
@@ -288,6 +288,29 @@ describe("WebPage object", function() {
});
});
+ it("should send proper key codes for text", function () {
+ runs(function() {
+ page.content = '<input type="text">';
+ page.evaluate(function() {
+ document.querySelector('input').focus();
+ });
+ page.sendEvent('keypress', "ABCD");
+ // 0x02000000 is the Shift modifier.
+ page.sendEvent('keypress', page.event.key.Home, null, null, 0x02000000);
+ // 0x04000000 is the Control modifier.
+ page.sendEvent('keypress', 'x', null, null, 0x04000000);
+ var text = page.evaluate(function() {
+ return document.querySelector('input').value;
+ });
+ expect(text).toEqual("");
+ page.sendEvent('keypress', 'v', null, null, 0x04000000);
+ text = page.evaluate(function() {
+ return document.querySelector('input').value;
+ });
+ expect(text).toEqual("ABCD");
+ });
+ });
+
it("should handle keypress event of umlaut char with inputs", function() {
runs(function() {
page.content = '<input type="text">';
Please sign in to comment.
Something went wrong with that request. Please try again.