Commit b0474a66 authored by Peter Varga's avatar Peter Varga
Browse files

Speculative stabilization of test_focusOnNavigation quick auto test


Reimplement setting focus on a HTML element in JavaScript.

Change-Id: I1db53bcb526fd52df1fa23527089f8186dfd0ea3
Reviewed-by: default avatarAllan Sandfeld Jensen <allan.jensen@qt.io>
Showing with 19 additions and 13 deletions
...@@ -10,9 +10,6 @@ osx ...@@ -10,9 +10,6 @@ osx
[WebViewGeopermission::test_geoPermissionRequest] [WebViewGeopermission::test_geoPermissionRequest]
osx osx
[WebEngineViewFocusOnNavigation::test_focusOnNavigation]
*
[WebEngineViewLoadUrl::test_urlProperty] [WebEngineViewLoadUrl::test_urlProperty]
windows windows
......
...@@ -67,8 +67,6 @@ Item { ...@@ -67,8 +67,6 @@ Item {
TestCase { TestCase {
name: "WebEngineViewFocusOnNavigation" name: "WebEngineViewFocusOnNavigation"
when: windowShown when: windowShown
function init() {
}
function test_focusOnNavigation_data() { function test_focusOnNavigation_data() {
return [ return [
...@@ -79,18 +77,29 @@ Item { ...@@ -79,18 +77,29 @@ Item {
] ]
} }
function triggerJavascriptFocus() { function getActiveElementId() {
var callbackCalled = false; var activeElementId;
webView.runJavaScript("document.getElementById(\"input\").focus()", function(result) { webView.runJavaScript("document.activeElement.id", function(result) {
callbackCalled = true; activeElementId = result;
}); });
wait(100); tryVerify(function() { return activeElementId != undefined });
verify(callbackCalled); return activeElementId;
}
function verifyElementHasFocus(element) {
tryVerify(function() { return getActiveElementId() == element; }, 5000,
"Element \"" + element + "\" has focus");
}
function setFocusToElement(element) {
webView.runJavaScript("document.getElementById('" + element + "').focus()");
verifyElementHasFocus(element);
} }
function loadAndTriggerFocusAndCompare(data) { function loadAndTriggerFocusAndCompare(data) {
verify(webView.waitForLoadSucceeded()); verify(webView.waitForLoadSucceeded());
triggerJavascriptFocus(); setFocusToElement("input");
compare(webView.activeFocus, data.viewReceivedFocus); compare(webView.activeFocus, data.viewReceivedFocus);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment