diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-09-29 16:08:34 +0200 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-10-17 20:13:05 +0200 |
commit | 02675c653eb1b03ba84409e20a15f4a502b88bab (patch) | |
tree | 4955253e061e8f5106b044f9799ce94b703a81b5 /tests | |
parent | a4caf162f0b93e994cf96d8b8e451b468c272fd1 (diff) |
Allow cancelling automatically accepted download requests
Calling QWebEngineDownloadRequest::cancel() had no effect if the download
request was accepted by default. These downloads had no corresponding
internal DownloadItem yet, but we tried to cancel them using the
DownloadManager. The safest option is to always check if the DownloadItem
exists in Chromium.
Pick-to: 6.6
Task-number: QTBUG-117624
Change-Id: I8f92d45e00e088aea7d22d5b7271b5b09adf6cbb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_save.qml | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_save.qml b/tests/auto/quick/qmltests/data/tst_save.qml index e9e6d5d83..3289dbd8b 100644 --- a/tests/auto/quick/qmltests/data/tst_save.qml +++ b/tests/auto/quick/qmltests/data/tst_save.qml @@ -17,6 +17,7 @@ TestWebEngineView { property bool isSavePageDownload: false property var downloadState: [] property int savePageFormat: WebEngineDownloadRequest.MimeHtmlSaveFormat; + property bool autoCancel: false TempDir { id: tempDir @@ -44,6 +45,9 @@ TestWebEngineView { downloadDir = download.downloadDirectory; downloadFileName = download.downloadFileName isSavePageDownload = download.isSavePageDownload + + if (autoCancel) + download.cancel() } onDownloadFinished: function(download) { receivedBytes = download.receivedBytes @@ -78,6 +82,7 @@ TestWebEngineView { isSavePageDownload = false downloadState = [] downloadUrl = "" + autoCancel = false } function test_savePage_data() { @@ -124,7 +129,16 @@ TestWebEngineView { verify(verifyData()) } - function test_saveImage() { + function test_saveImage_data() { + return [ + { tag: "Auto accept", autoCancel: false }, + { tag: "Cancel", autoCancel: true }, + ]; + } + + function test_saveImage(row) { + autoCancel = row.autoCancel + var fileDir = tempDir.path() var fileName = "favicon.png" var filePath = fileDir + "/"+ fileName @@ -143,8 +157,13 @@ TestWebEngineView { compare(downloadState[0], WebEngineDownloadRequest.DownloadInProgress) downloadFinishedSpy.wait() compare(downloadFinishedSpy.count, 1) - compare(totalBytes, receivedBytes) - compare(downloadState[1], WebEngineDownloadRequest.DownloadCompleted) + if (autoCancel) { + compare(receivedBytes, 0) + compare(downloadState[1], WebEngineDownloadRequest.DownloadCancelled) + } else { + compare(totalBytes, receivedBytes) + compare(downloadState[1], WebEngineDownloadRequest.DownloadCompleted) + } } function test_saveWebAction() { |