summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml')
-rw-r--r--tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
index 75b45bfac..4294c5ba3 100644
--- a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
+++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
@@ -42,11 +42,26 @@
import QtQuick 2.0
import QtTest 1.0
import QtWebEngine 1.2
+import QtWebEngine.testsupport 1.0
import "../mock-delegates/TestParams" 1.0
TestWebEngineView {
id: webEngineView
+ testSupport: WebEngineTestSupport {
+ property bool windowCloseRejectedSignalEmitted: false
+
+ function waitForWindowCloseRejected() {
+ return _waitFor(function () {
+ return testSupport.windowCloseRejectedSignalEmitted;
+ });
+ }
+
+ onWindowCloseRejected: {
+ windowCloseRejectedSignalEmitted = true;
+ }
+ }
+
TestCase {
id: test
name: "WebEngineViewJavaScriptDialogs"
@@ -80,6 +95,24 @@ TestWebEngineView {
}
+ function test_confirmClose() {
+ webEngineView.url = Qt.resolvedUrl("confirmclose.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ webEngineView.windowCloseRequestedSignalEmitted = false;
+ JSDialogParams.shouldAcceptDialog = true;
+ webEngineView.triggerWebAction(WebEngineView.RequestClose);
+ verify(webEngineView.waitForWindowCloseRequested());
+ }
+
+ function test_rejectClose() {
+ webEngineView.url = Qt.resolvedUrl("confirmclose.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ webEngineView.testSupport.windowCloseRejectedSignalEmitted = false;
+ JSDialogParams.shouldAcceptDialog = false;
+ webEngineView.triggerWebAction(WebEngineView.RequestClose);
+ verify(webEngineView.testSupport.waitForWindowCloseRejected());
+ }
+
function test_prompt() {
JSDialogParams.inputForPrompt = "tQ olleH"
webEngineView.url = Qt.resolvedUrl("prompt.html")