Correcting keycodes sent for lowercase characters

http://code.google.com/p/phantomjs/issues/detail?id=852

Conflicts:

	src/webpage.cpp
1.7
Ariya Hidayat 2012-11-09 22:14:46 -08:00
parent 72c574938a
commit 8cdd708812
2 changed files with 25 additions and 2 deletions

View File

@ -1031,12 +1031,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).toAscii();
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).toAscii();
key = text.at(0).toUpper().unicode();
}
} else {
// assume a raw integer char code was given

View File

@ -271,6 +271,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">';