summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/browser_context_adapter_client.h9
-rw-r--r--src/core/download_manager_delegate_qt.cpp19
-rw-r--r--src/core/download_manager_delegate_qt.h3
-rw-r--r--src/core/web_contents_adapter.cpp4
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp27
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp24
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp2
-rw-r--r--tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp57
11 files changed, 111 insertions, 40 deletions
diff --git a/src/core/browser_context_adapter_client.h b/src/core/browser_context_adapter_client.h
index 32a56bfce..02bee8ed6 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 191bb2267..40df9b3a8 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 dd8ebf6c4..df43211ed 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 5b7e437bf..c7b2e6e93 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 8d7550d6c..d40ca732a 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 922b0379c..6b4f7c8d3 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 17c9738fb..c89e4d522 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 8f097df6c..1dbfc9f51 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 812a3f98b..da765e5c5 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 a619a10c3..746fe55e8 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 ee11bab9d..e6db114b1 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()