summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebengineprofile
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@theqtcompany.com>2016-06-20 11:15:20 +0200
committerAndy Shaw <andy.shaw@qt.io>2016-07-26 18:47:58 +0000
commit808ca6e6917cf17e4c30fcd3ac609164b36594cc (patch)
tree5a9a23f095f924a15ba7c07c3a6f282f79f40ad8 /tests/auto/widgets/qwebengineprofile
parent5cb2aa149bbbdbaf45c1085b0736bb4501896827 (diff)
Prevent a crash after having downloaded a file
Since the profile owns the QWebEngineDownloadItem then it is likely that it will still be around when the QWebEngineProfile is deleted. As the QWebEngineDownloadItem is a child of the QWebEngineProfile then it will try to delete it when deleting the QWebEngineProfile which means it cannot trigger a function call into QWebEngineProfilePrivate. Change-Id: I51077a7857fb49a6708224a9e9942d17de6f6778 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/widgets/qwebengineprofile')
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 287e2364..23a56a9c 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -42,6 +42,7 @@
#include <QtWebEngineWidgets/qwebengineprofile.h>
#include <QtWebEngineWidgets/qwebenginesettings.h>
#include <QtWebEngineWidgets/qwebengineview.h>
+#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
class tst_QWebEngineProfile : public QObject
{
@@ -54,6 +55,7 @@ private Q_SLOTS:
void urlSchemeHandlerFailRequest();
void customUserAgent();
void httpAcceptLanguage();
+ void downloadItem();
};
void tst_QWebEngineProfile::defaultProfile()
@@ -245,5 +247,16 @@ void tst_QWebEngineProfile::httpAcceptLanguage()
QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("navigator.languages")).toStringList(), QStringList(testLang));
}
+void tst_QWebEngineProfile::downloadItem()
+{
+ qRegisterMetaType<QWebEngineDownloadItem *>();
+ QWebEngineProfile testProfile;
+ QWebEnginePage page(&testProfile);
+ QSignalSpy downloadSpy(&testProfile, SIGNAL(downloadRequested(QWebEngineDownloadItem *)));
+ connect(&testProfile, &QWebEngineProfile::downloadRequested, this, [=] (QWebEngineDownloadItem *item) { item->accept(); });
+ page.load(QUrl::fromLocalFile(QCoreApplication::applicationFilePath()));
+ QTRY_COMPARE(downloadSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QWebEngineProfile)
#include "tst_qwebengineprofile.moc"