diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-09-18 15:56:57 +0200 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2023-09-28 10:09:28 +0200 |
commit | ba20f9e892746639ebf888ef2e86add8839c3631 (patch) | |
tree | 26444fb29735f6ce02563fb2a31a25b88c78a27e /tests | |
parent | b4b709a5d9f44b3d16ae42c7831dcd45c64c1c30 (diff) |
Improve QWebEngineDownloadRequest::isSavePageDownload()
WebContentsImpl::IsSavable() decides which file formats are saveable,
but it allows this only for text-based files. All other files will go
around on the code path of downloading. MHTML (multipart) and PDF files
are saved like this, which means they aren't marked as isSavePageDownload.
Just simply set this flag if the save was requested by the user even if
it was a download.
This fixes the flag for saving MHTML and PDF files from context menu,
and leaves the flag false when a PDF download was initiated by the
button of the web UI.
Pick-to: 6.6
Task-number: QTBUG-114859
Change-Id: Id65f26a96952c5a43876338ad37f40570e544f3a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_save.qml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_save.qml b/tests/auto/quick/qmltests/data/tst_save.qml index 9757f8fac..f07a5f212 100644 --- a/tests/auto/quick/qmltests/data/tst_save.qml +++ b/tests/auto/quick/qmltests/data/tst_save.qml @@ -14,6 +14,7 @@ TestWebEngineView { property int receivedBytes: 0 property string downloadDir: "" property string downloadFileName: "" + property bool isSavePageDownload: false property var downloadState: [] property int savePageFormat: WebEngineDownloadRequest.MimeHtmlSaveFormat; @@ -42,6 +43,7 @@ TestWebEngineView { savePageFormat = download.savePageFormat downloadDir = download.downloadDirectory; downloadFileName = download.downloadFileName + isSavePageDownload = download.isSavePageDownload } onDownloadFinished: function(download) { receivedBytes = download.receivedBytes @@ -73,6 +75,7 @@ TestWebEngineView { receivedBytes = 0 downloadDir = "" downloadFileName = "" + isSavePageDownload = false downloadState = [] downloadUrl = "" } @@ -104,6 +107,7 @@ TestWebEngineView { compare(savePageFormat, saveFormat) compare(downloadDir, fileDir) compare(downloadFileName, fileName) + compare(isSavePageDownload, true) compare(downloadState[0], WebEngineDownloadRequest.DownloadInProgress) downloadFinishedSpy.wait() compare(downloadFinishedSpy.count, 1) @@ -119,5 +123,22 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()) verify(verifyData()) } + + function test_saveImage() { + var fileDir = tempDir.path() + var fileName = "favicon.png" + var filePath = fileDir + "/"+ fileName + + // Load an image + webEngineView.url = Qt.resolvedUrl("icons/favicon.png") + verify(webEngineView.waitForLoadSucceeded()) + + webEngineView.save(filePath) + downLoadRequestedSpy.wait() + compare(downLoadRequestedSpy.count, 1) + compare(downloadUrl, webEngineView.url) + compare(isSavePageDownload, true) + compare(downloadState[0], WebEngineDownloadRequest.DownloadRequested) + } } } |