diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-08-31 10:20:42 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-07 10:49:06 +0200 |
commit | 4444cae6e06c45e8f1f3d8702abde655f6175ba9 (patch) | |
tree | f35cce1682c6500ecc8b6bb5ec6ad61d480310d8 /tests/auto/quick/qmltests/data | |
parent | 40d808b53ded6bc091d7f642450c5fb9b09d6131 (diff) | |
parent | 7aa99d8d5b0dbf024019e70bf39b7d15796e1080 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
.qmake.conf
src/core/compositor/display_gl_output_surface_qsg.cpp
src/core/web_engine_context.cpp
tests/auto/quick/quick.pro
Change-Id: Iaf03434696788c89f5d3b524969513a89cb0a235
Diffstat (limited to 'tests/auto/quick/qmltests/data')
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_certificateError.qml | 114 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_newViewRequest.qml | 78 |
2 files changed, 51 insertions, 141 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_certificateError.qml b/tests/auto/quick/qmltests/data/tst_certificateError.qml deleted file mode 100644 index a4bd9597a..000000000 --- a/tests/auto/quick/qmltests/data/tst_certificateError.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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.2 -import QtTest 1.0 -import QtWebEngine 1.9 - -import Test.Shared 1.0 as Shared - -TestWebEngineView { - id: view; width: 320; height: 320 - - property bool deferError: false - property bool acceptCertificate: false - - onCertificateError: function(error) { - if (deferError) - error.defer() - else if (acceptCertificate) - error.acceptCertificate() - else - error.rejectCertificate() - } - - SignalSpy { - id: spyError - target: view - signalName: 'certificateError' - } - - TestCase { - name: 'CertificateError' - when: windowShown - - function initTestCase() { - Shared.HttpsServer.setExpectError(true) - Shared.HttpsServer.newRequest.connect(function (request) { - request.setResponseBody('<html><body>Test</body></html>') - request.sendResponse() - }) - view.settings.errorPageEnabled = false - } - - function init() { - verify(Shared.HttpsServer.start()) - } - - function cleanup() { - Shared.HttpsServer.stop() - view.deferError = false - view.acceptCertificate = false - spyError.clear() - } - - function test_error_data() { - return [ - { tag: 'reject', deferError: false, acceptCertificate: false, expectedContent: '' }, - { tag: 'defer_reject', deferError: true, acceptCertificate: false, expectedContent: '' }, - { tag: 'defer_accept', deferError: true, acceptCertificate: true, expectedContent: 'Test' }, - ] - } - - function test_error(data) { - view.deferError = data.deferError - view.acceptCertificate = data.acceptCertificate - view.url = Shared.HttpsServer.url() - - if (data.deferError) { - spyError.wait() - compare(spyError.count, 1) - compare('', view.getBodyText()) - - let error = spyError.signalArguments[0][0] - if (data.acceptCertificate) - error.acceptCertificate() - else - error.rejectCertificate() - } - - if (data.acceptCertificate) - verify(view.waitForLoadSucceeded()) - else - verify(view.waitForLoadFailed()) - - compare(spyError.count, 1) - compare(data.expectedContent, view.getBodyText()) - } - } -} diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml index a671c2ec7..80389e9f8 100644 --- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml +++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml @@ -37,6 +37,7 @@ TestWebEngineView { property var newViewRequest: null property var dialog: null + property string viewType: "" SignalSpy { id: newViewRequestedSpy @@ -60,7 +61,12 @@ TestWebEngineView { " TestWebEngineView { id: webView; anchors.fill: parent }\n" + "}", webEngineView); - request.openIn(dialog.webEngineView); + if (viewType === "dialog") + request.openIn(dialog.webEngineView); + else if (viewType === "null") + request.openIn(0); + else if (viewType === "webEngineView") + request.openIn(webEngineView); } TestCase { @@ -74,6 +80,7 @@ TestWebEngineView { newViewRequestedSpy.clear(); newViewRequest = null; + viewType = ""; } function cleanup() { @@ -81,7 +88,17 @@ TestWebEngineView { dialog.destroy(); } - function test_jsWindowOpen() { + function test_loadNewViewRequest_data() { + return [ + { tag: "dialog", viewType: "dialog" }, + { tag: "invalid", viewType: "null" }, + { tag: "unhandled", viewType: "" }, + { tag: "webEngineView", viewType: "webEngineView" }, + ]; + } + + function test_loadNewViewRequest(row) { + viewType = row.viewType; var url = 'data:text/html,%3Chtml%3E%3Cbody%3ETest+Page%3C%2Fbody%3E%3C%2Fhtml%3E'; // Open an empty page in a new tab @@ -96,12 +113,14 @@ TestWebEngineView { compare(newViewRequest.destination, WebEngineView.NewViewInTab); verify(!newViewRequest.userInitiated); - verify(dialog.webEngineView.waitForLoadSucceeded()); - compare(dialog.webEngineView.url, ""); + if (viewType === "dialog") { + verify(dialog.webEngineView.waitForLoadSucceeded()); + compare(dialog.webEngineView.url, ""); + dialog.destroy(); + } // https://chromium-review.googlesource.com/c/chromium/src/+/1300395 compare(newViewRequest.requestedUrl, 'about:blank#blocked'); newViewRequestedSpy.clear(); - dialog.destroy(); // Open a page in a new dialog webEngineView.loadHtml( @@ -115,30 +134,35 @@ TestWebEngineView { compare(newViewRequest.destination, WebEngineView.NewViewInDialog); compare(newViewRequest.requestedUrl, url); verify(!newViewRequest.userInitiated); - verify(dialog.webEngineView.waitForLoadSucceeded()); + if (viewType === "dialog") { + verify(dialog.webEngineView.waitForLoadSucceeded()); + dialog.destroy(); + } newViewRequestedSpy.clear(); - dialog.destroy(); - // Open a page in a new dialog by user - webEngineView.loadHtml( - "<html><head><script>" + - " function popup() { window.open('" + url + "', '_blank', 'width=200,height=100'); }" + - "</script></head>" + - "<body onload=\"document.getElementById('popupButton').focus();\">" + - " <button id='popupButton' onclick='popup()'>Pop Up!</button>" + - "</body></html>"); - verify(webEngineView.waitForLoadSucceeded()); - verifyElementHasFocus("popupButton"); - keyPress(Qt.Key_Enter); - tryCompare(newViewRequestedSpy, "count", 1); - compare(newViewRequest.requestedUrl, url); - - compare(newViewRequest.destination, WebEngineView.NewViewInDialog); - verify(newViewRequest.userInitiated); - verify(dialog.webEngineView.waitForLoadSucceeded()); - newViewRequestedSpy.clear(); - dialog.destroy(); + if (viewType !== "webEngineView") { + // Open a page in a new dialog by user + webEngineView.loadHtml( + "<html><head><script>" + + " function popup() { window.open('" + url + "', '_blank', 'width=200,height=100'); }" + + "</script></head>" + + "<body onload=\"document.getElementById('popupButton').focus();\">" + + " <button id='popupButton' onclick='popup()'>Pop Up!</button>" + + "</body></html>"); + verify(webEngineView.waitForLoadSucceeded()); + verifyElementHasFocus("popupButton"); + keyPress(Qt.Key_Enter); + tryCompare(newViewRequestedSpy, "count", 1); + compare(newViewRequest.requestedUrl, url); + + compare(newViewRequest.destination, WebEngineView.NewViewInDialog); + verify(newViewRequest.userInitiated); + if (viewType === "dialog") { + verify(dialog.webEngineView.waitForLoadSucceeded()); + dialog.destroy(); + } + newViewRequestedSpy.clear(); + } } } } - |