summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2020-01-10 10:24:52 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2020-01-15 16:13:55 +0100
commit075050991bbdc8c165b5ccf809516e3eaa5ee859 (patch)
tree3ba92da38d6cfa3eb4313d724789f5a0f25219b2 /tests
parenta76801c8aa19c8328fe4f90426a5783a78b3c348 (diff)
Fix overriding shortcuts in password input fields on Windows
Windows IME does not support hidden text therefore IME input is disabled on password fields. The shortcuts are supposed to be overridden in input fields. Checking the keyboard focus on an input field is done by verifying if the IME is enabled. This won't work with password fields on platforms where hidden text is not supported, so also check if the Qt::ImhHiddenText IME hint is set. Fixes: QTBUG-81206 Change-Id: I81870beb556a9dda67295496dad8b672fbc5eba2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 0b11be355..b5f038bba 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -1829,6 +1829,7 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts()
view.setHtml(QString("<html><body>"
"<button id=\"btn1\" type=\"button\">push it real good</button>"
"<input id=\"input1\" type=\"text\" value=\"x\">"
+ "<input id=\"pass1\" type=\"password\" value=\"x\">"
"</body></html>"));
QVERIFY(loadFinishedSpy.wait());
@@ -1840,6 +1841,11 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts()
"document.getElementById('input1').value").toString();
};
+ auto passwordFieldValue = [&view] () -> QString {
+ return evaluateJavaScriptSync(view.page(),
+ "document.getElementById('pass1').value").toString();
+ };
+
// The input form is not focused. The action is triggered on pressing Shift+Delete.
action->setShortcut(Qt::SHIFT + Qt::Key_Delete);
QTest::keyClick(view.windowHandle(), Qt::Key_Delete, Qt::ShiftModifier);
@@ -1863,8 +1869,20 @@ void tst_QWebEngineView::inputFieldOverridesShortcuts()
QTRY_COMPARE(inputFieldValue(), QString("yxx"));
QVERIFY(!actionTriggered);
+ // The password input form is focused. The action is not triggered, and the form's text changed.
+ evaluateJavaScriptSync(view.page(), "document.getElementById('pass1').focus();");
+ QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("pass1"));
+ actionTriggered = false;
+ QTest::keyClick(view.windowHandle(), Qt::Key_Y);
+ QTRY_COMPARE(passwordFieldValue(), QString("yx"));
+ QTest::keyClick(view.windowHandle(), Qt::Key_X);
+ QTRY_COMPARE(passwordFieldValue(), QString("yxx"));
+ QVERIFY(!actionTriggered);
+
// The input form is focused. Make sure we don't override all short cuts.
// A Ctrl-1 action is no default Qt key binding and should be triggerable.
+ evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus();");
+ QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
action->setShortcut(Qt::CTRL + Qt::Key_1);
QTest::keyClick(view.windowHandle(), Qt::Key_1, Qt::ControlModifier);
QTRY_VERIFY(actionTriggered);