diff options
Diffstat (limited to 'tests/auto/quick/qmltests/data')
-rw-r--r-- | tests/auto/quick/qmltests/data/TestWebEngineView.qml | 6 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/test2.html | 2 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_newViewRequest.qml | 25 |
3 files changed, 30 insertions, 3 deletions
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml index 6db076ae8..f2bc09e4b 100644 --- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml +++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml @@ -85,12 +85,14 @@ WebEngineView { function getElementCenter(element) { var center; - runJavaScript("(function() {" + + testCase.tryVerify(function() { + runJavaScript("(function() {" + " var elem = document.getElementById('" + element + "');" + " var rect = elem.getBoundingClientRect();" + " return { 'x': (rect.left + rect.right) / 2, 'y': (rect.top + rect.bottom) / 2 };" + "})();", function(result) { center = result } ); - testCase.tryVerify(function() { return center !== undefined; }); + return center !== undefined; + }); return center; } diff --git a/tests/auto/quick/qmltests/data/test2.html b/tests/auto/quick/qmltests/data/test2.html index 629c2a063..7a02bf1f2 100644 --- a/tests/auto/quick/qmltests/data/test2.html +++ b/tests/auto/quick/qmltests/data/test2.html @@ -1,6 +1,6 @@ <html> <head><title>Test page with huge link area</title></head> <body> -<a title="A title" href="test1.html"><img width=200 height=200></a> +<a id="link" title="A title" href="test1.html"><img width=200 height=200></a> </body> </html> diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml index 80389e9f8..08d63d956 100644 --- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml +++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml @@ -38,6 +38,13 @@ TestWebEngineView { property var newViewRequest: null property var dialog: null property string viewType: "" + property var loadRequestArray: [] + + onLoadingChanged: { + loadRequestArray.push({ + "status": loadRequest.status, + }); + } SignalSpy { id: newViewRequestedSpy @@ -81,6 +88,7 @@ TestWebEngineView { newViewRequestedSpy.clear(); newViewRequest = null; viewType = ""; + loadRequestArray = []; } function cleanup() { @@ -163,6 +171,23 @@ TestWebEngineView { } newViewRequestedSpy.clear(); } + + loadRequestArray = []; + compare(loadRequestArray.length, 0); + webEngineView.url = Qt.resolvedUrl("test2.html"); + verify(webEngineView.waitForLoadSucceeded()); + var center = getElementCenter("link"); + mouseClick(webEngineView, center.x, center.y, Qt.LeftButton, Qt.ControlModifier); + tryCompare(newViewRequestedSpy, "count", 1); + compare(newViewRequest.requestedUrl, Qt.resolvedUrl("test1.html")); + compare(newViewRequest.destination, WebEngineView.NewViewInBackgroundTab); + verify(newViewRequest.userInitiated); + if (viewType === "" || viewType === "null") { + compare(loadRequestArray[0].status, WebEngineView.LoadStartedStatus); + compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus); + compare(loadRequestArray.length, 2); + } + newViewRequestedSpy.clear(); } } } |