diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h index 32a56bfce798d8f739729db0642ccc09c320ca20..02bee8ed67aa9583da7b53b7132c4400f715cfcb 100644 --- a/src/core/browser_context_adapter_client.h +++ b/src/core/browser_context_adapter_client.h @@ -69,6 +69,13 @@ public: MimeHtmlSaveFormat }; + enum DownloadType { + Attachment = 0, + DownloadAttribute, + UserRequested, + SavePage + }; + // Keep in sync with content::DownloadInterruptReason enum DownloadInterruptReason { NoReason = 0, @@ -113,7 +120,7 @@ public: bool accepted; bool paused; bool done; - bool isSavePageDownload; + int downloadType; int downloadInterruptReason; }; diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 191bb2267a5d5fece17d470b42b1e0bd96d1dd2a..40df9b3a81627707199eb804d31ca6acbe152fab 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -65,6 +65,7 @@ DownloadManagerDelegateQt::DownloadManagerDelegateQt(BrowserContextAdapter *cont : m_contextAdapter(contextAdapter) , m_currentId(0) , m_weakPtrFactory(this) + , m_nextDownloadIsUserRequested(false) { Q_ASSERT(m_contextAdapter); } @@ -122,6 +123,18 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i QString suggestedFilename = toQt(item->GetSuggestedFilename()); QString mimeTypeString = toQt(item->GetMimeType()); + int downloadType = 0; + if (m_nextDownloadIsUserRequested) { + downloadType = BrowserContextAdapterClient::UserRequested; + m_nextDownloadIsUserRequested = false; + } else { + bool isAttachment = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).is_attachment(); + if (isAttachment) + downloadType = BrowserContextAdapterClient::Attachment; + else + downloadType = BrowserContextAdapterClient::DownloadAttribute; + } + if (suggestedFilename.isEmpty()) suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename()); @@ -167,7 +180,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i false /* accepted */, false /* paused */, false /* done */, - false /* isSavePageDownload */, + downloadType, item->GetLastReason() }; @@ -262,7 +275,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content acceptedByDefault, false, /* paused */ false, /* done */ - true /* isSavePageDownload */, + BrowserContextAdapterClient::SavePage, BrowserContextAdapterClient::NoReason }; @@ -302,7 +315,7 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa true /* accepted */, download->IsPaused(), download->IsDone(), - download->IsSavePackageDownload(), + 0 /* downloadType (unused) */, download->GetLastReason() }; diff --git a/src/core/download_manager_delegate_qt.h b/src/core/download_manager_delegate_qt.h index dd8ebf6c4bbc837cbc0c9f26619db6685cf9c18e..df43211ed3d11a24590a93a69d4c6da257879849 100644 --- a/src/core/download_manager_delegate_qt.h +++ b/src/core/download_manager_delegate_qt.h @@ -86,6 +86,8 @@ public: void pauseDownload(quint32 downloadId); void resumeDownload(quint32 downloadId); + void markNextDownloadAsUserRequested() { m_nextDownloadIsUserRequested = true; } + // Inherited from content::DownloadItem::Observer void OnDownloadUpdated(content::DownloadItem *download) override; void OnDownloadDestroyed(content::DownloadItem *download) override; @@ -97,6 +99,7 @@ private: uint64_t m_currentId; base::WeakPtrFactory<DownloadManagerDelegateQt> m_weakPtrFactory; + bool m_nextDownloadIsUserRequested; friend class DownloadManagerDelegateInstance; DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegateQt); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 5b7e437bf16ac1723211c2708fe6a1d6d7569634..c7b2e6e93a76314f9a646b1ac0ac8c8ca26526ab 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -979,10 +979,14 @@ void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileN Q_D(WebContentsAdapter); content::BrowserContext *bctx = webContents()->GetBrowserContext(); content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx); + DownloadManagerDelegateQt *dlmd = d->browserContextAdapter->downloadManagerDelegate(); if (!dlm) return; + dlmd->markNextDownloadAsUserRequested(); + dlm->SetDelegate(dlmd); + net::NetworkTrafficAnnotationTag traffic_annotation = net::DefineNetworkTrafficAnnotation( "WebContentsAdapter::download", R"( diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 8d7550d6c32fcb3a39de5c09d1addf5392b63386..d40ca732a2da85995a9e9931eb8f3a71cd443753 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -101,7 +101,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb , downloadId(-1) , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat) - , isSavePageDownload(false) + , type(QQuickWebEngineDownloadItem::Attachment) , interruptReason(QQuickWebEngineDownloadItem::NoReason) , totalBytes(-1) , receivedBytes(0) @@ -401,14 +401,27 @@ void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem: Describes the requested download's type. - Unfortunately, this property only ever worked correctly for \c SavePage - downloads. In other cases, it followed the documented semantics rather - loosely, sometimes non-deterministically. Use \l isSavePageDownload instead. - */ + \note This property works unreliably, except for \c SavePage + downloads. Use \l isSavePageDownload instead. + + \value WebEngineDownloadItem.Attachment The web server's response includes a + \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition + is present in the reply, the web server is indicating that the client should prompt the + user to save the content regardless of the content type. + See \l {RFC 2616 section 19.5.1} for details. + \value WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download + attribute. See \l {HTML download attribute} for details. + \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by + selecting a web action. + \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by + the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action). + +*/ QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const { - return isSavePageDownload() ? SavePage : UserRequested; + Q_D(const QQuickWebEngineDownloadItem); + return d->type; } /*! @@ -423,7 +436,7 @@ QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() co bool QQuickWebEngineDownloadItem::isSavePageDownload() const { Q_D(const QQuickWebEngineDownloadItem); - return d->isSavePageDownload; + return d->type == QQuickWebEngineDownloadItem::SavePage; } /*! diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 922b0379c831c0de2903c6e752d4b582dcd2886a..6b4f7c8d3d2be054792913593a3fd5f922af1d79 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -73,7 +73,7 @@ public: quint32 downloadId; QQuickWebEngineDownloadItem::DownloadState downloadState; QQuickWebEngineDownloadItem::SavePageFormat savePageFormat; - bool isSavePageDownload; + QQuickWebEngineDownloadItem::DownloadType type; QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason; qint64 totalBytes; qint64 receivedBytes; diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 17c9738fb6504e79bf145e95e0f30e379948121c..c89e4d5228a8803298931cd6b453ebaf0633fb58 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -193,7 +193,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>( info.savePageFormat); - itemPrivate->isSavePageDownload = info.isSavePageDownload; + itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType); QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q); diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index 8f097df6cdcef222db93c6a08d4dbd62d2793619..1dbfc9f51e630e23724cd0feada03b4a9670d357 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -115,7 +115,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr , downloadId(-1) , downloadState(QWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat) - , isSavePageDownload(false) + , type(QWebEngineDownloadItem::Attachment) , interruptReason(QWebEngineDownloadItem::NoReason) , downloadUrl(url) , downloadPaused(false) @@ -321,6 +321,18 @@ quint32 QWebEngineDownloadItem::id() const \obsolete Describes the requested download's type. + + \value Attachment The web server's response includes a + \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition + is present in the reply, the web server is indicating that the client should prompt the + user to save the content regardless of the content type. + See \l {RFC 2616 section 19.5.1} for details. + \value DownloadAttribute The user clicked a link with the \c download + attribute. See \l {HTML download attribute} for details. + \value UserRequested The user initiated the download, for example by + selecting a web action. + \value SavePage Saving of the current page was requested (for example by + the \l{QWebEnginePage::WebAction}{QWebEnginePage::SavePage} web action). */ /*! @@ -504,14 +516,14 @@ void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageF \since 5.8 \obsolete - Unfortunately, this property only ever worked correctly for \c SavePage - downloads. In other cases, it followed the documented semantics rather - loosely, sometimes non-deterministically. Use \l isSavePageDownload instead. + \note This property works unreliably, except for \c SavePage + downloads. Use \l isSavePageDownload() instead. */ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const { - return isSavePageDownload() ? SavePage : UserRequested; + Q_D(const QWebEngineDownloadItem); + return d->type; } /*! @@ -521,7 +533,7 @@ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const bool QWebEngineDownloadItem::isSavePageDownload() const { Q_D(const QWebEngineDownloadItem); - return d->isSavePageDownload; + return d->type == QWebEngineDownloadItem::SavePage; } /*! diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index 812a3f98b65de93a4fb1fedfc597965209088ad8..da765e5c5a8a2f0a48b4fe59fe57d9d3e8b0b2b9 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -72,7 +72,7 @@ public: quint32 downloadId; QWebEngineDownloadItem::DownloadState downloadState; QWebEngineDownloadItem::SavePageFormat savePageFormat; - bool isSavePageDownload; + QWebEngineDownloadItem::DownloadType type; QWebEngineDownloadItem::DownloadInterruptReason interruptReason; QString downloadPath; const QUrl downloadUrl; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index a619a10c3b4b6b026a983b070b032ceb68278bbb..746fe55e8b4c89cfe4eb741e797f5d5902b8d116 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -193,7 +193,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->mimeType = info.mimeType; itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat); - itemPrivate->isSavePageDownload = info.isSavePageDownload; + itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType); QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q); diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp index ee11bab9d5ed6e7d89ab7f732984d63b94ec134d..e6db114b13342e2dfe0dce3e3d5a1e2cb1c634b5 100644 --- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp +++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp @@ -88,6 +88,7 @@ void tst_QWebEngineDownloads::downloadLink_data() QTest::addColumn<QByteArray>("fileDisposition"); QTest::addColumn<bool>("fileHasReferer"); QTest::addColumn<DownloadTestFileAction>("fileAction"); + QTest::addColumn<QWebEngineDownloadItem::DownloadType>("downloadType"); // SaveLink should always trigger a download, even for empty files. QTest::newRow("save link to empty file") @@ -99,7 +100,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // SaveLink should always trigger a download, also for text files. QTest::newRow("save link to text file") @@ -111,7 +113,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // ... adding the "download" attribute should have no effect. QTest::newRow("save link to text file (attribute)") @@ -123,7 +126,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // ... adding the "attachment" content disposition should also have no effect. QTest::newRow("save link to text file (attachment)") @@ -135,7 +139,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // ... even adding both should have no effect. QTest::newRow("save link to text file (attribute+attachment)") @@ -147,7 +152,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // Navigating to an empty file should show an empty page. QTest::newRow("navigate to empty file") @@ -159,7 +165,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDisplayed; + /* fileAction */ << FileIsDisplayed + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // Navigating to a text file should show the text file. QTest::newRow("navigate to text file") @@ -171,7 +178,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDisplayed; + /* fileAction */ << FileIsDisplayed + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // ... unless the link has the "download" attribute: then the file should be downloaded. QTest::newRow("navigate to text file (attribute)") @@ -183,7 +191,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << false // crbug.com/455987 - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; // ... same with the content disposition header save for the download type. QTest::newRow("navigate to text file (attachment)") @@ -195,7 +204,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::Attachment; // ... and both. QTest::newRow("navigate to text file (attribute+attachment)") @@ -207,7 +217,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain") /* fileDisposition */ << QByteArrayLiteral("attachment") /* fileHasReferer */ << false // crbug.com/455987 - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::Attachment; // The file's extension has no effect. QTest::newRow("navigate to supposed zip file") @@ -219,7 +230,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDisplayed; + /* fileAction */ << FileIsDisplayed + /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; // ... the file's mime type however does. QTest::newRow("navigate to supposed zip file (application/zip)") @@ -231,7 +243,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/zip") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; // ... but we're not very picky about the exact type. QTest::newRow("navigate to supposed zip file (application/octet-stream)") @@ -243,7 +256,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/octet-stream") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; // empty zip file (consisting only of "end of central directory record") QByteArray zipFile = QByteArrayLiteral("PK\x05\x06") + QByteArray(18, 0); @@ -258,7 +272,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/octet-stream") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; // The mime type is not guessed automatically if provided by the server. QTest::newRow("navigate to actual zip file (application/zip)") @@ -270,7 +285,8 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileMimeTypeDetected */ << QByteArrayLiteral("application/zip") /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true - /* fileAction */ << FileIsDownloaded; + /* fileAction */ << FileIsDownloaded + /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; } void tst_QWebEngineDownloads::downloadLink() @@ -284,6 +300,7 @@ void tst_QWebEngineDownloads::downloadLink() QFETCH(QByteArray, fileDisposition); QFETCH(bool, fileHasReferer); QFETCH(DownloadTestFileAction, fileAction); + QFETCH(QWebEngineDownloadItem::DownloadType, downloadType); HttpServer server; QWebEngineProfile profile; @@ -381,7 +398,7 @@ void tst_QWebEngineDownloads::downloadLink() QCOMPARE(item->totalBytes(), -1); QCOMPARE(item->receivedBytes(), 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), QWebEngineDownloadItem::UserRequested); + QCOMPARE(item->type(), downloadType); QCOMPARE(item->isSavePageDownload(), false); QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected)); QCOMPARE(item->path(), suggestedPath); @@ -400,7 +417,7 @@ void tst_QWebEngineDownloads::downloadLink() QCOMPARE(item->totalBytes(), fileContents.size()); QCOMPARE(item->receivedBytes(), fileContents.size()); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), QWebEngineDownloadItem::UserRequested); + QCOMPARE(item->type(), downloadType); QCOMPARE(item->isSavePageDownload(), false); QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected)); QCOMPARE(item->path(), downloadPath); @@ -510,15 +527,17 @@ void tst_QWebEngineDownloads::downloadTwoLinks() if (item1->url().fileName() == QByteArrayLiteral("file2")) qSwap(item1, item2); - QTRY_COMPARE(item1->state(), QWebEngineDownloadItem::DownloadCompleted); + QCOMPARE(item1->type(), QWebEngineDownloadItem::DownloadAttribute); QCOMPARE(item1->mimeType(), QStringLiteral("text/plain")); QCOMPARE(item1->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); QCOMPARE(item1->url(), server.url(QByteArrayLiteral("/file1"))); + QTRY_COMPARE(item1->state(), QWebEngineDownloadItem::DownloadCompleted); - QTRY_COMPARE(item2->state(), QWebEngineDownloadItem::DownloadCompleted); + QCOMPARE(item2->type(), QWebEngineDownloadItem::Attachment); QCOMPARE(item2->mimeType(), QStringLiteral("text/plain")); QCOMPARE(item2->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); QCOMPARE(item2->url(), server.url(QByteArrayLiteral("/file2"))); + QTRY_COMPARE(item2->state(), QWebEngineDownloadItem::DownloadCompleted); } void tst_QWebEngineDownloads::downloadPage_data()