Bug 226509

Summary: [iOS] Need API to save currently-displayed PDF blob
Product: WebKit Reporter: Ali Juma <ajuma>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: achristensen, beidson, gambard, ggaren, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ali Juma 2021-06-01 12:59:56 PDT
Steps to reproduce:
1. Visit https://alijuma.github.io/test-pdf.html
2. Tap on “Generate”

This produces a PDF blob and then loads this PDF.

In Safari, it’s possible to save this PDF (tap on the sharing icon, and then “Save to Files”).

However, a WKWebView embedder like Chrome cannot implement the same functionality since there’s no API to save the currently-displayed PDF. Since the blob object no longer exists (since we navigated away from it), the WKWebView download API doesn’t work (the load fails with a WebKitBlobResource error).

Also, since the blob link produced in step (2) doesn’t have a ‘download’ attribute, WKNavigationAction’s |shouldPerformDownload| attribute was false on navigation to the PDF, so the embedder would not have preemptively downloaded the file.

Safari seems to be using SPI to save the PDF after it’s displayed.

WKWebView’s |_getMainResourceDataWithCompletionHandler:| SPI does work in this case, so making this public would be one way to address this issue.

I've also filed FB9124664 for this.
Comment 1 Radar WebKit Bug Importer 2021-06-08 13:00:21 PDT
<rdar://problem/79029343>
Comment 2 Sam Sneddon [:gsnedders] 2022-05-09 07:42:28 PDT
rdar://78728238