summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests_ssl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qmltests_ssl')
-rw-r--r--tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml122
-rw-r--r--tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml134
-rw-r--r--tests/auto/quick/qmltests_ssl/qmltests_ssl.pro10
-rw-r--r--tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp160
4 files changed, 0 insertions, 426 deletions
diff --git a/tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml b/tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml
deleted file mode 100644
index 6db076ae8..000000000
--- a/tests/auto/quick/qmltests_ssl/data/TestWebEngineView.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** 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.1
-import QtWebEngine 1.7
-
-WebEngineView {
- property var loadStatus: null
- property bool windowCloseRequestedSignalEmitted: false
- settings.focusOnNavigationEnabled: true
-
- function waitForLoadSucceeded(timeout) {
- var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }, timeout)
- loadStatus = null
- return success
- }
- function waitForLoadFailed(timeout) {
- var failure = _waitFor(function() { return loadStatus == WebEngineView.LoadFailedStatus }, timeout)
- loadStatus = null
- return failure
- }
- function waitForLoadStopped(timeout) {
- var stop = _waitFor(function() { return loadStatus == WebEngineView.LoadStoppedStatus }, timeout)
- loadStatus = null
- return stop
- }
- function waitForWindowCloseRequested() {
- return _waitFor(function() { return windowCloseRequestedSignalEmitted; });
- }
- function _waitFor(predicate, timeout) {
- if (timeout === undefined)
- timeout = 12000;
- var i = 0
- while (i < timeout && !predicate()) {
- testResult.wait(50)
- i += 50
- }
- return predicate()
- }
-
- function getActiveElementId() {
- var activeElementId;
- runJavaScript("document.activeElement.id", function(result) {
- activeElementId = result;
- });
- testCase.tryVerify(function() { return activeElementId != undefined });
- return activeElementId;
- }
-
- function verifyElementHasFocus(element) {
- testCase.tryVerify(function() { return getActiveElementId() == element; }, 5000,
- "Element \"" + element + "\" has focus");
- }
-
- function setFocusToElement(element) {
- runJavaScript("document.getElementById('" + element + "').focus()");
- verifyElementHasFocus(element);
- }
-
- function getElementCenter(element) {
- var center;
- 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;
- }
-
- function getTextSelection() {
- var textSelection;
- runJavaScript("window.getSelection().toString()", function(result) { textSelection = result });
- testCase.tryVerify(function() { return textSelection !== undefined; });
- return textSelection;
- }
-
- TestResult { id: testResult }
- TestCase { id: testCase }
-
- onLoadingChanged: {
- loadStatus = loadRequest.status
- }
-
- onWindowCloseRequested: {
- windowCloseRequestedSignalEmitted = true;
- }
-
- function getBodyText() {
- let text
- runJavaScript('document.body.innerText', function(t) { text = t })
- testCase.tryVerify(function() { return text !== undefined })
- return text
- }
-}
-
diff --git a/tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml b/tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml
deleted file mode 100644
index 4c252e210..000000000
--- a/tests/auto/quick/qmltests_ssl/data/tst_certificateError.qml
+++ /dev/null
@@ -1,134 +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
-
- 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
- var handleCertificateError = function(error) {
- if (deferError)
- error.defer()
- else if (acceptCertificate)
- error.ignoreCertificateError()
- else
- error.rejectCertificate()
- }
- view.certificateError.connect(handleCertificateError)
-
- 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.ignoreCertificateError()
- else
- error.rejectCertificate()
- }
-
- if (data.acceptCertificate)
- verify(view.waitForLoadSucceeded())
- else
- verify(view.waitForLoadFailed())
-
- compare(spyError.count, 1)
- compare(data.expectedContent, view.getBodyText())
-
- view.certificateError.disconnect(handleCertificateError)
- }
-
- function test_fatalError() {
- var handleCertificateError = function(error) {
- verify(!error.overrideable);
- // QQuickWebEngineViewPrivate::allowCertificateError() will implicitly reject
- // fatal errors and it should not crash if already rejected in handler.
- error.rejectCertificate();
- }
- view.certificateError.connect(handleCertificateError);
-
- view.url = Qt.resolvedUrl('https://revoked.badssl.com');
- if (!view.waitForLoadFailed(10000))
- skip("Couldn't load page from network, skipping test.");
- compare(spyError.count, 1);
-
- view.certificateError.disconnect(handleCertificateError);
- }
- }
-}
diff --git a/tests/auto/quick/qmltests_ssl/qmltests_ssl.pro b/tests/auto/quick/qmltests_ssl/qmltests_ssl.pro
deleted file mode 100644
index a8325e497..000000000
--- a/tests/auto/quick/qmltests_ssl/qmltests_ssl.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-include(../tests.pri)
-include(../../shared/https.pri)
-QT += qmltest
-
-IMPORTPATH += $$PWD/data
-
-OTHER_FILES += $$PWD/data/tst_certificateError.qml
-
-load(qt_build_paths)
-DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$PWD$${QMAKE_DIR_SEP}data)\\\"
diff --git a/tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp b/tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp
deleted file mode 100644
index 1f54ffd8e..000000000
--- a/tests/auto/quick/qmltests_ssl/tst_qmltests_ssl.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#include <QtWebEngineCore/qtwebenginecoreglobal.h>
-#include <QtNetwork/qtnetwork-config.h>
-
-#if QT_CONFIG(ssl)
-#include <httpsserver.h>
-#endif
-
-#include <QtCore/QScopedPointer>
-#include <QTemporaryDir>
-#include <QtQuickTest/quicktest.h>
-#include <QtWebEngine/QQuickWebEngineProfile>
-#include <QQmlEngine>
-#include "qt_webengine_quicktest.h"
-
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
-#include <fcntl.h>
-#include <signal.h>
-#include <unistd.h>
-#endif
-
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
-static bool debuggerPresent()
-{
- int fd = open("/proc/self/status", O_RDONLY);
- if (fd == -1)
- return false;
- char buffer[2048];
- ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
- if (size == -1) {
- close(fd);
- return false;
- }
- buffer[size] = 0;
- const char tracerPidToken[] = "\nTracerPid:";
- char *tracerPid = strstr(buffer, tracerPidToken);
- if (!tracerPid) {
- close(fd);
- return false;
- }
- tracerPid += sizeof(tracerPidToken);
- long int pid = strtol(tracerPid, &tracerPid, 10);
- close(fd);
- return pid != 0;
-}
-
-static void stackTrace()
-{
- bool ok = false;
- const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
- if (ok && disableStackDump == 1)
- return;
-
- if (debuggerPresent())
- return;
-
- fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
- char cmd[512];
- qsnprintf(cmd, 512, "gdb --pid %d 2>/dev/null <<EOF\n"
- "set prompt\n"
- "set height 0\n"
- "thread apply all where full\n"
- "detach\n"
- "quit\n"
- "EOF\n",
- (int)getpid());
-
- if (system(cmd) == -1)
- fprintf(stderr, "calling gdb failed\n");
- fprintf(stderr, "========= End of stack trace ==============\n");
-}
-
-static void sigSegvHandler(int signum)
-{
- stackTrace();
- qFatal("Received signal %d", signum);
-}
-#endif
-
-class TempDir : public QObject {
- Q_OBJECT
-
-public:
- Q_INVOKABLE QString path() {
- Q_ASSERT(tempDir.isValid());
- return tempDir.isValid() ? tempDir.path() : QString();
- }
-
-private:
- QTemporaryDir tempDir;
-};
-
-int main(int argc, char **argv)
-{
-#if defined(Q_OS_LINUX) && defined(QT_DEBUG)
- struct sigaction sigAction;
-
- sigemptyset(&sigAction.sa_mask);
- sigAction.sa_handler = &sigSegvHandler;
- sigAction.sa_flags = 0;
-
- sigaction(SIGSEGV, &sigAction, 0);
-#endif
-
- QScopedPointer<Application> app;
-
- // Force to use English language for testing due to error message checks
- QLocale::setDefault(QLocale("en"));
-
- static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
- QVector<const char *> w_argv(argc); \
- for (int i = 0; i < argc; ++i) \
- w_argv[i] = argv[i]; \
- for (int i = 0; i < params.size(); ++i) \
- w_argv.append(params[i].data()); \
- int w_argc = w_argv.size(); \
-
- if (!QCoreApplication::instance()) {
- app.reset(new Application(w_argc, const_cast<char **>(w_argv.data())));
- }
- QtWebEngine::initialize();
- QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true);
- qmlRegisterType<TempDir>("Test.util", 1, 0, "TempDir");
-
- QTEST_SET_MAIN_SOURCE_PATH
-#if QT_CONFIG(ssl)
- qmlRegisterSingletonType<HttpsServer>("Test.Shared", 1, 0, "HttpsServer", [&] (QQmlEngine *, QJSEngine *) { return new HttpsServer; });
-#endif
- int i = quick_test_main(argc, argv, "qmltests", QUICK_TEST_SOURCE_DIR);
- return i;
-}
-
-#include "tst_qmltests_ssl.moc"