summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2020-10-14 14:56:47 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-10 11:02:57 +0100
commitbbf7226ace4d9bbcff4d68c063dc598c2d3f2ff0 (patch)
tree922e100467cc80f1dd6d794b07a35c12cf314bee /tests/auto/quick/qmltests
parentf93900ec2e5e4289f562b630821650f7c3f8f906 (diff)
Fix new view request handling
Ignore url loading if the request is not from a data url and the Q(Quick)WebEngineNewViewRequest.openIn() is not called on newViewRequested(). Set the missing Q(Quick)WebEngineNewViewRequest::requestedUrl property. Fixes: QTBUG-87378 Change-Id: Idddc9cf075db68dcf5825b3e746d16419d02cfa0 Reviewed-by: Tamas Zakor <ztamas@inf.u-szeged.hu> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/quick/qmltests')
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml6
-rw-r--r--tests/auto/quick/qmltests/data/test2.html2
-rw-r--r--tests/auto/quick/qmltests/data/tst_newViewRequest.qml25
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();
}
}
}