summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests/data/tst_newViewRequest.qml')
-rw-r--r--tests/auto/quick/qmltests/data/tst_newViewRequest.qml95
1 files changed, 47 insertions, 48 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
index 80389e9f8..68350d107 100644
--- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
@@ -1,34 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtTest 1.0
-import QtWebEngine 1.5
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQuick
+import QtTest
+import QtWebEngine
TestWebEngineView {
id: webEngineView
@@ -38,14 +13,21 @@ TestWebEngineView {
property var newViewRequest: null
property var dialog: null
property string viewType: ""
+ property var loadRequestArray: []
+
+ onLoadingChanged: function(load) {
+ loadRequestArray.push({
+ "status": load.status,
+ });
+ }
SignalSpy {
id: newViewRequestedSpy
target: webEngineView
- signalName: "newViewRequested"
+ signalName: "newWindowRequested"
}
- onNewViewRequested: {
+ onNewWindowRequested: function(request) {
newViewRequest = {
"destination": request.destination,
"userInitiated": request.userInitiated,
@@ -53,7 +35,7 @@ TestWebEngineView {
};
dialog = Qt.createQmlObject(
- "import QtQuick.Window 2.0\n" +
+ "import QtQuick.Window\n" +
"Window {\n" +
" width: 100; height: 100\n" +
" visible: true; flags: Qt.Dialog\n" +
@@ -70,8 +52,8 @@ TestWebEngineView {
}
TestCase {
- id: test
- name: "NewViewRequest"
+ id: testCase
+ name: "NewWindowRequest"
when: windowShown
function init() {
@@ -81,6 +63,7 @@ TestWebEngineView {
newViewRequestedSpy.clear();
newViewRequest = null;
viewType = "";
+ loadRequestArray = [];
}
function cleanup() {
@@ -88,7 +71,7 @@ TestWebEngineView {
dialog.destroy();
}
- function test_loadNewViewRequest_data() {
+ function test_loadNewWindowRequest_data() {
return [
{ tag: "dialog", viewType: "dialog" },
{ tag: "invalid", viewType: "null" },
@@ -97,7 +80,7 @@ TestWebEngineView {
];
}
- function test_loadNewViewRequest(row) {
+ function test_loadNewWindowRequest(row) {
viewType = row.viewType;
var url = 'data:text/html,%3Chtml%3E%3Cbody%3ETest+Page%3C%2Fbody%3E%3C%2Fhtml%3E';
@@ -110,16 +93,15 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
tryCompare(newViewRequestedSpy, "count", 1);
- compare(newViewRequest.destination, WebEngineView.NewViewInTab);
+ compare(newViewRequest.destination, WebEngineNewWindowRequest.InNewTab);
verify(!newViewRequest.userInitiated);
if (viewType === "dialog") {
- verify(dialog.webEngineView.waitForLoadSucceeded());
- compare(dialog.webEngineView.url, "");
+ tryVerify(dialog.webEngineView.loadSucceeded)
+ compare(dialog.webEngineView.url, Qt.url("about:blank"));
dialog.destroy();
}
- // https://chromium-review.googlesource.com/c/chromium/src/+/1300395
- compare(newViewRequest.requestedUrl, 'about:blank#blocked');
+ compare(newViewRequest.requestedUrl, 'about:blank');
newViewRequestedSpy.clear();
// Open a page in a new dialog
@@ -131,11 +113,11 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded());
tryCompare(newViewRequestedSpy, "count", 1);
- compare(newViewRequest.destination, WebEngineView.NewViewInDialog);
+ compare(newViewRequest.destination, WebEngineNewWindowRequest.InNewDialog);
compare(newViewRequest.requestedUrl, url);
verify(!newViewRequest.userInitiated);
if (viewType === "dialog") {
- verify(dialog.webEngineView.waitForLoadSucceeded());
+ tryVerify(dialog.webEngineView.loadSucceeded)
dialog.destroy();
}
newViewRequestedSpy.clear();
@@ -150,19 +132,36 @@ TestWebEngineView {
" <button id='popupButton' onclick='popup()'>Pop Up!</button>" +
"</body></html>");
verify(webEngineView.waitForLoadSucceeded());
- verifyElementHasFocus("popupButton");
+ webEngineView.verifyElementHasFocus("popupButton");
keyPress(Qt.Key_Enter);
tryCompare(newViewRequestedSpy, "count", 1);
compare(newViewRequest.requestedUrl, url);
- compare(newViewRequest.destination, WebEngineView.NewViewInDialog);
+ compare(newViewRequest.destination, WebEngineNewWindowRequest.InNewDialog);
verify(newViewRequest.userInitiated);
if (viewType === "dialog") {
- verify(dialog.webEngineView.waitForLoadSucceeded());
+ tryVerify(dialog.webEngineView.loadSucceeded)
dialog.destroy();
}
newViewRequestedSpy.clear();
}
+
+ loadRequestArray = [];
+ compare(loadRequestArray.length, 0);
+ webEngineView.url = Qt.resolvedUrl("test2.html");
+ verify(webEngineView.waitForLoadSucceeded());
+ var center = webEngineView.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, WebEngineNewWindowRequest.InNewBackgroundTab);
+ 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();
}
}
}