diff options
-rw-r--r-- | tests/auto/quick/qmltests/data/geolocation.html | 9 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_geopermission.qml | 40 |
2 files changed, 29 insertions, 20 deletions
diff --git a/tests/auto/quick/qmltests/data/geolocation.html b/tests/auto/quick/qmltests/data/geolocation.html index 8b116c8ee..e8c54bc58 100644 --- a/tests/auto/quick/qmltests/data/geolocation.html +++ b/tests/auto/quick/qmltests/data/geolocation.html @@ -3,16 +3,21 @@ <title>Geolocation Permission API Test</title> <script> +var errorMessage; +var handled = false; + function successHandler(location) { var message = document.getElementById("message"); message.innerHTML = "Latitude: " + location.coords.latitude + "<br>Longitude: " + location.coords.longitude; - console.error("Success"); + errorMessage = ""; + handled = true; } function errorHandler(error) { - console.error(error.message); + errorMessage = error.message; + handled = true; } <!-- One shot example --> diff --git a/tests/auto/quick/qmltests/data/tst_geopermission.qml b/tests/auto/quick/qmltests/data/tst_geopermission.qml index c935ac0b4..9f613abf3 100644 --- a/tests/auto/quick/qmltests/data/tst_geopermission.qml +++ b/tests/auto/quick/qmltests/data/tst_geopermission.qml @@ -37,7 +37,6 @@ TestWebEngineView { property bool deniedGeolocation: false property bool geoPermissionRequested: false - signal consoleErrorMessage(string message) SignalSpy { id: featurePermissionSpy @@ -45,12 +44,6 @@ TestWebEngineView { signalName: "featurePermissionRequested" } - SignalSpy { - id: consoleErrorMessageSpy - target: webEngineView - signalName: "consoleErrorMessage" - } - onFeaturePermissionRequested: { if (feature === WebEngineView.Geolocation) { geoPermissionRequested = true @@ -63,19 +56,31 @@ TestWebEngineView { } } - onJavaScriptConsoleMessage: { - if (level === WebEngineView.ErrorMessageLevel) - consoleErrorMessage(message) - } - TestCase { name: "WebViewGeopermission" when: windowShown + function isHandled() { + var handled; + runJavaScript("handled", function(result) { + handled = result; + }); + tryVerify(function() { return handled != undefined; }, 5000); + return handled; + } + + function getErrorMessage() { + var errorMessage; + runJavaScript("errorMessage", function(result) { + errorMessage = result; + }); + tryVerify(function() { return errorMessage != undefined; }, 5000); + return errorMessage; + } + function init() { deniedGeolocation = false featurePermissionSpy.clear() - consoleErrorMessageSpy.clear() } function test_geoPermissionRequest() { @@ -84,17 +89,16 @@ TestWebEngineView { featurePermissionSpy.wait() verify(geoPermissionRequested) compare(featurePermissionSpy.count, 1) - consoleErrorMessageSpy.wait() - verify(consoleErrorMessageSpy.signalArguments[0][0] === "Success" || - consoleErrorMessageSpy.signalArguments[0][0] === "") + tryVerify(isHandled, 5000) + verify(getErrorMessage() === "") } function test_deniedGeolocationByUser() { deniedGeolocation = true webEngineView.url = Qt.resolvedUrl("geolocation.html") featurePermissionSpy.wait() - consoleErrorMessageSpy.wait() - compare(consoleErrorMessageSpy.signalArguments[0][0], "User denied Geolocation") + tryVerify(isHandled, 5000) + compare(getErrorMessage(), "User denied Geolocation") } } } |