summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2017-11-14 16:23:18 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-02 20:45:07 +0000
commit7219986a18d45dd0e32a8004c748ce91d22a535b (patch)
tree1162c8e7050eba4afe833109b00f814ec76ec75c /tests
parent9214f8e6092b48e7b596f343b5e9bb7afd430078 (diff)
Deprecate download type
This patch removes the download type property from QtWebEngineCore and replaces it with a simple boolean 'isSavePageDownload'. On the public API boundary the type property is reimplemented via this boolean and documented as obsolete. Rationale being that 1. This feature seems to lack practical use cases, other than perhaps distinguishing save-page downloads from normal file downloads, which can be done in a much simpler way. 2. This feature does not work as documented and never has. So far nobody has complained, hinting again at a lack of practical use cases. 3. In order to fix it we would need to maintain patches on top of Chromium and Blink (we would, for example, need to propagate the DownloadAttribute type from Blink to Chromium to WebEngine). [ChangeLog][Deprecation Notice] (QWebEngine)DownloadItem::type() is deprecated and replaced with the newly introduced isSavePageDownload() property. Task-number: QTBUG-62640 Change-Id: Icf4e1e5a635028986df7eab979f4c0527902ff0c Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp57
1 files changed, 21 insertions, 36 deletions
diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
index 7094c8e4b..5df722340 100644
--- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
+++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp
@@ -86,7 +86,6 @@ 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")
@@ -98,8 +97,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// SaveLink should always trigger a download, also for text files.
QTest::newRow("save link to text file")
@@ -111,8 +109,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// ... adding the "download" attribute should have no effect.
QTest::newRow("save link to text file (attribute)")
@@ -124,8 +121,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// ... adding the "attachment" content disposition should also have no effect.
QTest::newRow("save link to text file (attachment)")
@@ -137,8 +133,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("attachment")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::UserRequested;
+ /* fileAction */ << FileIsDownloaded;
// ... even adding both should have no effect.
QTest::newRow("save link to text file (attribute+attachment)")
@@ -150,8 +145,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("attachment")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::UserRequested;
+ /* fileAction */ << FileIsDownloaded;
// Navigating to an empty file should show an empty page.
QTest::newRow("navigate to empty file")
@@ -163,8 +157,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDisplayed
- /* downloadType */ << /* unused */ QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDisplayed;
// Navigating to a text file should show the text file.
QTest::newRow("navigate to text file")
@@ -176,8 +169,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDisplayed
- /* downloadType */ << /* unused */ QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDisplayed;
// ... unless the link has the "download" attribute: then the file should be downloaded.
QTest::newRow("navigate to text file (attribute)")
@@ -189,8 +181,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << false // crbug.com/455987
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// ... same with the content disposition header save for the download type.
QTest::newRow("navigate to text file (attachment)")
@@ -202,8 +193,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("attachment")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::Attachment;
+ /* fileAction */ << FileIsDownloaded;
// ... and both.
QTest::newRow("navigate to text file (attribute+attachment)")
@@ -215,8 +205,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("text/plain")
/* fileDisposition */ << QByteArrayLiteral("attachment")
/* fileHasReferer */ << false // crbug.com/455987
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::Attachment;
+ /* fileAction */ << FileIsDownloaded;
// The file's extension has no effect.
QTest::newRow("navigate to supposed zip file")
@@ -228,8 +217,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDisplayed
- /* downloadType */ << /* unused */ QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDisplayed;
// ... the file's mime type however does.
QTest::newRow("navigate to supposed zip file (application/zip)")
@@ -241,8 +229,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("application/zip")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// ... but we're not very picky about the exact type.
QTest::newRow("navigate to supposed zip file (application/octet-stream)")
@@ -254,8 +241,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("application/octet-stream")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// empty zip file (consisting only of "end of central directory record")
QByteArray zipFile = QByteArrayLiteral("PK\x05\x06") + QByteArray(18, 0);
@@ -270,8 +256,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("application/octet-stream")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
// The mime type is not guessed automatically if provided by the server.
QTest::newRow("navigate to actual zip file (application/zip)")
@@ -283,8 +268,7 @@ void tst_QWebEngineDownloads::downloadLink_data()
/* fileMimeTypeDetected */ << QByteArrayLiteral("application/zip")
/* fileDisposition */ << QByteArrayLiteral("")
/* fileHasReferer */ << true
- /* fileAction */ << FileIsDownloaded
- /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute;
+ /* fileAction */ << FileIsDownloaded;
}
void tst_QWebEngineDownloads::downloadLink()
@@ -298,7 +282,6 @@ void tst_QWebEngineDownloads::downloadLink()
QFETCH(QByteArray, fileDisposition);
QFETCH(bool, fileHasReferer);
QFETCH(DownloadTestFileAction, fileAction);
- QFETCH(QWebEngineDownloadItem::DownloadType, downloadType);
HttpServer server;
QWebEngineProfile profile;
@@ -395,7 +378,8 @@ void tst_QWebEngineDownloads::downloadLink()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), downloadType);
+ QCOMPARE(item->type(), QWebEngineDownloadItem::UserRequested);
+ QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(item->path(), suggestedPath);
QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
@@ -413,7 +397,8 @@ void tst_QWebEngineDownloads::downloadLink()
QCOMPARE(item->totalBytes(), fileContents.size());
QCOMPARE(item->receivedBytes(), fileContents.size());
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), downloadType);
+ QCOMPARE(item->type(), QWebEngineDownloadItem::UserRequested);
+ QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(item->path(), downloadPath);
QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
@@ -485,7 +470,6 @@ void tst_QWebEngineDownloads::downloadTwoLinks()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::DownloadAttribute);
QCOMPARE(item->mimeType(), QStringLiteral("text/plain"));
QCOMPARE(item->path(), standardDir + QByteArrayLiteral("/file1"));
QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
@@ -504,7 +488,6 @@ void tst_QWebEngineDownloads::downloadTwoLinks()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::DownloadAttribute);
QCOMPARE(item->mimeType(), QStringLiteral("text/plain"));
QCOMPARE(item->path(), standardDir + QByteArrayLiteral("/file2"));
QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat);
@@ -565,6 +548,7 @@ void tst_QWebEngineDownloads::downloadPage()
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
+ QCOMPARE(item->isSavePageDownload(), true);
// FIXME why is mimeType always the same?
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
QCOMPARE(item->path(), downloadPath);
@@ -583,6 +567,7 @@ void tst_QWebEngineDownloads::downloadPage()
QVERIFY(item->receivedBytes() > 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
+ QCOMPARE(item->isSavePageDownload(), true);
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
QCOMPARE(item->path(), downloadPath);
QCOMPARE(item->savePageFormat(), savePageFormat);