diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-21 14:35:01 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-21 14:35:01 +0100 |
commit | 432af50e930b7f11455fc1daec17d9c215ea88ee (patch) | |
tree | 75f8e9cc04069de32c25660298c4fce046f88b4e /tests/auto/widgets | |
parent | 809afc26fe0c47b249cf11376c8ea484a2bfaaf1 (diff) | |
parent | d5a479a720ee76fae9fa7b0f7b6b3d0a61718ff0 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: If771fabe97c4d75edc4627999f04f70ca1901060
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp | 38 | ||||
-rw-r--r-- | tests/auto/widgets/offscreen/offscreen.pro | 6 | ||||
-rw-r--r-- | tests/auto/widgets/offscreen/tst_offscreen.cpp | 60 | ||||
-rw-r--r-- | tests/auto/widgets/proxy/proxy.pro | 9 | ||||
-rw-r--r-- | tests/auto/widgets/proxy/proxy_server.cpp | 90 | ||||
-rw-r--r-- | tests/auto/widgets/proxy/proxy_server.h | 59 | ||||
-rw-r--r-- | tests/auto/widgets/proxy/tst_proxy.cpp | 69 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp | 32 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/BLACKLIST | 6 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/resources/reload.html | 8 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 68 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc | 1 | ||||
-rw-r--r-- | tests/auto/widgets/widgets.pro | 11 |
13 files changed, 440 insertions, 17 deletions
diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp index 606d05d9e..540c8d505 100644 --- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp +++ b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp @@ -62,6 +62,7 @@ private Q_SLOTS: void downloadTouchIconsEnabled_data(); void downloadTouchIconsEnabled(); void dynamicFavicon(); + void touchIconWithSameURL(); private: QWebEngineView *m_view; @@ -508,6 +509,43 @@ void tst_FaviconManager::dynamicFavicon() } } +void tst_FaviconManager::touchIconWithSameURL() +{ + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); + + const QString icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="); + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->setHtml("<html>" + "<link rel='icon' type='image/png' href='" + icon + "'/>" + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + "</html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QCOMPARE(m_page->iconUrl().toString(), icon); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + loadFinishedSpy.clear(); + iconUrlChangedSpy.clear(); + iconChangedSpy.clear(); + + m_page->setHtml("<html>" + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + "</html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon + // was loaded previously. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QVERIFY(m_page->iconUrl().toString().isEmpty()); + QTRY_COMPARE(iconChangedSpy.count(), 1); + +} + QTEST_MAIN(tst_FaviconManager) #include "tst_faviconmanager.moc" diff --git a/tests/auto/widgets/offscreen/offscreen.pro b/tests/auto/widgets/offscreen/offscreen.pro new file mode 100644 index 000000000..b8e5632f9 --- /dev/null +++ b/tests/auto/widgets/offscreen/offscreen.pro @@ -0,0 +1,6 @@ +include(../tests.pri) +QT += webengine +qpa.name = QT_QPA_PLATFORM +qpa.value = offscreen +QT_TOOL_ENV += qpa + diff --git a/tests/auto/widgets/offscreen/tst_offscreen.cpp b/tests/auto/widgets/offscreen/tst_offscreen.cpp new file mode 100644 index 000000000..98cbe55fe --- /dev/null +++ b/tests/auto/widgets/offscreen/tst_offscreen.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "qtwebengineglobal.h" +#include <QTest> +#include <QSignalSpy> +#include <QWebEngineProfile> +#include <QWebEnginePage> +#include <QWebEngineView> + +class tst_OffScreen : public QObject { + Q_OBJECT +public: + tst_OffScreen(){} + +private slots: + void offscreen(); +}; + +void tst_OffScreen::offscreen() +{ + QWebEngineProfile profile; + QWebEnginePage page(&profile); + QWebEngineView view; + QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool))); + view.setPage(&page); + page.load(QUrl("http://qt.io")); + view.show(); + QTRY_COMPARE(view.isVisible(), true); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count() > 0, true, 20000); +} + +#include "tst_offscreen.moc" +QTEST_MAIN(tst_OffScreen) + diff --git a/tests/auto/widgets/proxy/proxy.pro b/tests/auto/widgets/proxy/proxy.pro new file mode 100644 index 000000000..802dfad05 --- /dev/null +++ b/tests/auto/widgets/proxy/proxy.pro @@ -0,0 +1,9 @@ +include(../tests.pri) +QT += core-private webengine webengine-private + +HEADERS += \ + proxy_server.h + +SOURCES += \ + proxy_server.cpp + diff --git a/tests/auto/widgets/proxy/proxy_server.cpp b/tests/auto/widgets/proxy/proxy_server.cpp new file mode 100644 index 000000000..55f014914 --- /dev/null +++ b/tests/auto/widgets/proxy/proxy_server.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "proxy_server.h" +#include <QDataStream> +#include <QTcpSocket> +#include <QDebug> + +ProxyServer::ProxyServer(QObject *parent) : QObject(parent) +{ + connect(&m_server, &QTcpServer::newConnection, this, &ProxyServer::handleNewConnection); +} + +void ProxyServer::setCredentials(const QByteArray &user, const QByteArray password) +{ + m_auth.append(user); + m_auth.append(QChar(':')); + m_auth.append(password); + m_auth = m_auth.toBase64(); +} + +bool ProxyServer::isListening() +{ + return m_server.isListening(); +} + +void ProxyServer::run() +{ + if (!m_server.listen(QHostAddress::LocalHost, 5555)) + qFatal("Could not start the test server"); +} + +void ProxyServer::handleNewConnection() +{ + // do one connection at the time + Q_ASSERT(m_data.isEmpty()); + QTcpSocket *socket = m_server.nextPendingConnection(); + Q_ASSERT(socket); + connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater); + connect(socket, &QAbstractSocket::readyRead, this, &ProxyServer::handleReadReady); +} + +void ProxyServer::handleReadReady() +{ + QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender()); + Q_ASSERT(socket); + + m_data.append(socket->readAll()); + + if (!m_data.endsWith("\r\n\r\n")) + return; + + if (!m_data.contains(QByteArrayLiteral("Proxy-Authorization: Basic"))) { + socket->write("HTTP/1.1 407 Proxy Authentication Required\nProxy-Authenticate: " + "Basic realm=\"Proxy requires authentication\"\r\n" + "content-length: 0\r\n" + "\r\n"); + return; + } + + if (m_data.contains(m_auth)) { + emit success(); + } + m_data.clear(); +} diff --git a/tests/auto/widgets/proxy/proxy_server.h b/tests/auto/widgets/proxy/proxy_server.h new file mode 100644 index 000000000..cb7c30600 --- /dev/null +++ b/tests/auto/widgets/proxy/proxy_server.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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$ +** +****************************************************************************/ + +#ifndef PROXY_SERVER_H +#define PROXY_SERVER_H + +#include <QObject> +#include <QTcpServer> + +class ProxyServer : public QObject +{ + Q_OBJECT + +public: + explicit ProxyServer(QObject *parent = nullptr); + void setCredentials(const QByteArray &user, const QByteArray password); + bool isListening(); + +public slots: + void run(); + +private slots: + void handleNewConnection(); + void handleReadReady(); + +signals: + void success(); +private: + QByteArray m_data; + QTcpServer m_server; + QByteArray m_auth; +}; + +#endif // PROXY_SERVER_H diff --git a/tests/auto/widgets/proxy/tst_proxy.cpp b/tests/auto/widgets/proxy/tst_proxy.cpp new file mode 100644 index 000000000..5f5dec016 --- /dev/null +++ b/tests/auto/widgets/proxy/tst_proxy.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "proxy_server.h" +#include <QTest> +#include <QSignalSpy> +#include <QNetworkProxy> +#include <QWebEnginePage> +#include <QWebEngineView> + + +class tst_Proxy : public QObject { + Q_OBJECT +public: + tst_Proxy(){} + +private slots: + void proxyAuthentication(); +}; + +void tst_Proxy::proxyAuthentication() +{ + QByteArray user(QByteArrayLiteral("test")); + QByteArray password(QByteArrayLiteral("pass")); + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName("localhost"); + proxy.setPort(5555); + proxy.setUser(user); + proxy.setPassword(password); + QNetworkProxy::setApplicationProxy(proxy); + ProxyServer server; + server.setCredentials(user,password); + server.run(); + QTRY_VERIFY2(server.isListening(), "Could not setup authentication server"); + QWebEnginePage page; + QSignalSpy successSpy(&server, &ProxyServer::success); + page.load(QUrl("http://www.qt.io")); + QTRY_VERIFY2(successSpy.count() > 0, "Could not get authentication token"); +} + +#include "tst_proxy.moc" +QTEST_MAIN(tst_Proxy) + diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp index 32823d30d..ee1e6ee04 100644 --- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp +++ b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp @@ -70,6 +70,7 @@ private Q_SLOTS: void downloadFileNot1(); void downloadFileNot2(); void downloadDeleted(); + void downloadDeletedByProfile(); void downloadUniqueFilename_data(); void downloadUniqueFilename(); void downloadUniqueFileNameWithTimeStamp(); @@ -821,6 +822,37 @@ void tst_QWebEngineDownloadItem::downloadDeleted() QTRY_COMPARE(finishedCount, 1); } +void tst_QWebEngineDownloadItem::downloadDeletedByProfile() +{ + m_server->setExpectError(true); + + QPointer<QWebEngineProfile> profile(new QWebEngineProfile); + profile->setHttpCacheType(QWebEngineProfile::NoCache); + profile->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); + + bool downloadFinished = false; + QPointer<QWebEngineDownloadItem> downloadItem; + connect(profile, &QWebEngineProfile::downloadRequested, [&] (QWebEngineDownloadItem *item) { + connect(item, &QWebEngineDownloadItem::finished, [&] () { + downloadFinished = true; + }); + downloadItem = item; + item->accept(); + }); + + QPointer<QWebEnginePage> page(new QWebEnginePage(profile)); + page->download(m_server->url(QByteArrayLiteral("/file"))); + + QTRY_COMPARE(downloadItem.isNull(), false); + QVERIFY(downloadItem); + + page->deleteLater(); + profile->deleteLater(); + + QTRY_COMPARE(downloadFinished, true); + QTRY_COMPARE(downloadItem.isNull(), true); +} + void tst_QWebEngineDownloadItem::downloadUniqueFilename_data() { QTest::addColumn<QString>("baseName"); diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index 228efd61c..f3dc51fdd 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -1,9 +1,3 @@ -[comboBoxPopupPositionAfterMove] -* - -[comboBoxPopupPositionAfterChildMove] -* - [macCopyUnicodeToClipboard] osx diff --git a/tests/auto/widgets/qwebenginepage/resources/reload.html b/tests/auto/widgets/qwebenginepage/resources/reload.html new file mode 100644 index 000000000..d9c33dfcd --- /dev/null +++ b/tests/auto/widgets/qwebenginepage/resources/reload.html @@ -0,0 +1,8 @@ +<html> +<head> +<meta http-equiv="refresh" content="2"> +</head> +<body> +This is test content +</body> +</html> diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 0504d39fa..3792b5522 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -138,6 +138,7 @@ private Q_SLOTS: void runJavaScript(); void runJavaScriptDisabled(); + void runJavaScriptFromSlot(); void fullScreenRequested(); void quotaRequested(); @@ -561,11 +562,17 @@ void tst_QWebEnginePage::acceptNavigationRequestNavigationType() QTRY_COMPARE(loadSpy.count(), 4); QTRY_COMPARE(page.navigations.count(), 4); + page.load(QUrl("qrc:///resources/reload.html")); + QTRY_COMPARE(loadSpy.count(), 6); + QTRY_COMPARE(page.navigations.count(), 6); + QList<QWebEnginePage::NavigationType> expectedList; expectedList << QWebEnginePage::NavigationTypeTyped << QWebEnginePage::NavigationTypeTyped << QWebEnginePage::NavigationTypeBackForward - << QWebEnginePage::NavigationTypeReload; + << QWebEnginePage::NavigationTypeReload + << QWebEnginePage::NavigationTypeTyped + << QWebEnginePage::NavigationTypeOther; QVERIFY(expectedList.count() == page.navigations.count()); for (int i = 0; i < expectedList.count(); ++i) { QCOMPARE(page.navigations[i].type, expectedList[i]); @@ -1008,9 +1015,8 @@ static QWindow *findNewTopLevelWindow(const QWindowList &oldTopLevelWindows) void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() { - QScreen *screen = QGuiApplication::primaryScreen(); QWebEngineView view; - view.move(screen->availableGeometry().topLeft()); + view.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft()); view.resize(640, 480); view.show(); @@ -1026,18 +1032,29 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() QWindow *popup = nullptr; QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QPoint popupPos = popup->position(); // Close the popup by clicking somewhere into the page. QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(1, 1)); QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); + auto jsViewPosition = [&view]() { + QLatin1String script("(function() { return [window.screenX, window.screenY]; })()"); + QVariantList posList = evaluateJavaScriptSync(view.page(), script).toList(); + return QPoint(posList.at(0).toInt(), posList.at(1).toInt()); + }; + // Move the top-level QWebEngineView a little and check the popup's position. const QPoint offset(12, 13); - view.move(screen->availableGeometry().topLeft() + offset); + view.move(view.pos() + offset); + QTRY_COMPARE(jsViewPosition(), view.pos()); QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), elementCenter(view.page(), "foo")); QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + offset, popup->position()); } @@ -1047,7 +1064,6 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() mainWidget.setLayout(new QHBoxLayout); QWidget spacer; - spacer.setMinimumWidth(50); mainWidget.layout()->addWidget(&spacer); QWebEngineView view; @@ -1070,6 +1086,8 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() QWindow *popup = nullptr; QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QPoint popupPos = popup->position(); // Close the popup by clicking somewhere into the page. @@ -1077,11 +1095,22 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() view.mapTo(view.window(), QPoint(1, 1))); QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); + int originalViewWidth = view.size().width(); + auto jsViewWidth = [&view]() { + QLatin1String script("(function() { return window.innerWidth; })()"); + int viewWidth = evaluateJavaScriptSync(view.page(), script).toInt(); + return viewWidth; + }; + // Resize the "spacer" widget, and implicitly change the global position of the QWebEngineView. - spacer.setMinimumWidth(100); + const int offset = 50; + spacer.setMinimumWidth(spacer.size().width() + offset); + QTRY_COMPARE(jsViewWidth(), originalViewWidth - offset); + QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), view.mapTo(view.window(), elementCenter(view.page(), "foo"))); QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + QPoint(50, 0), popup->position()); } @@ -1644,6 +1673,28 @@ void tst_QWebEnginePage::runJavaScriptDisabled() QVariant(2)); } +// Based on https://bugreports.qt.io/browse/QTBUG-73876 +void tst_QWebEnginePage::runJavaScriptFromSlot() +{ + QWebEngineProfile profile; + QWebEnginePage page(&profile); + + QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished); + page.setHtml("<html><body>" + " <input type='text' id='input1' value='QtWebEngine' size='50' />" + "</body></html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + QVariant result(-1); + connect(&page, &QWebEnginePage::selectionChanged, [&]() { + result = evaluateJavaScriptSync(&page, QStringLiteral("2+2")); + }); + evaluateJavaScriptSync(&page, QStringLiteral("const input = document.getElementById('input1');" + "input.focus();" + "input.select();")); + QTRY_COMPARE(result, QVariant(4)); +} + void tst_QWebEnginePage::fullScreenRequested() { JavaScriptCallbackWatcher watcher; @@ -3284,10 +3335,13 @@ void tst_QWebEnginePage::sendNotification() auto notification = presenter.waitForResult(); QVERIFY(presenter.wasCalled()); - QVERIFY(!notification.isNull()); + QVERIFY(notification.isValid()); QCOMPARE(notification.title(), title); QCOMPARE(notification.message(), message); QCOMPARE(notification.origin(), origin); + QCOMPARE(notification.direction(), Qt::RightToLeft); + QCOMPARE(notification.language(), "de"); + QCOMPARE(notification.tag(), "tst"); notification.show(); QTRY_VERIFY2(page.messages.contains("onshow"), page.messages.join("\n").toLatin1().constData()); diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc index 757e151c1..cf32486e7 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc @@ -14,6 +14,7 @@ <file>resources/user.css</file> <file>resources/image.png</file> <file>resources/pasteimage.html</file> + <file>resources/reload.html</file> <file>resources/style.css</file> <file>resources/test1.html</file> <file>resources/test2.html</file> diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index 0addb9671..15b3efd3b 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -8,7 +8,9 @@ SUBDIRS += \ devtools \ faviconmanager \ loadsignals \ + offscreen \ origins \ + proxy \ proxypac \ schemes \ shutdown \ @@ -38,7 +40,8 @@ qtConfig(webengine-spellchecker):!cross_compile { # QTBUG-60268 boot2qt: SUBDIRS -= accessibility defaultsurfaceformat devtools \ - faviconmanager qwebenginepage qwebenginehistory \ - qwebengineprofile qwebenginescript \ - qwebengineview qwebenginedownloaditem qwebenginesettings \ - schemes origins loadsignals proxypac + qwebenginepage \ + qwebengineprofile \ + qwebengineview \ + qwebenginescript \ + proxypac offscreen |