Bug 226440

Summary: Blob url downloads fail when triggered from webextension
Product: WebKit Reporter: Victor <victorhlin>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: achristensen, karlcow, timothy, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Apple Silicon)   
OS: macOS 11   
See Also: https://bugs.webkit.org/show_bug.cgi?id=216918

Description Victor 2021-05-30 16:59:22 PDT
Blob url downloads fail when triggered from a webextension tab. The tab is created with `chrome.tabs.create({ url: /wordlist.html })`. wordlist.html embeds a script with the following code to trigger downloads when clicking on a button:


```
        let saveBlob = new Blob(['content'], { "type": "text/plain" });
        let a = document.getElementById('savelink'); // tab html contains "<a id="savelink" download="download.txt"></a>"
        const blobLink = URL.createObjectURL(saveBlob);
        a.href = blobLink;
        a.click();
```


This opens in the existing tab (replacing its content) and fails with the following safari error:

```
Safari can’t open the page “blob:safari-web-extension://20101d16-cc55-4a3f-a307-a03b6e2df273/07f5a98e-8fbd-409e-9113-58afe3c748c8”.

The error is: “The operation couldn’t be completed. (WebKitBlobResource error 1.)” (WebKitBlobResource:1)
```

I found some related bugs on non-extension pages, e.g https://bugs.webkit.org/show_bug.cgi?id=190351 (usage of target="_blank"), https://bugs.webkit.org/show_bug.cgi?id=211234 (bugs with immediately revoked object urls) ,  The presence of the `target` attribute doesn't seem to matter, and it seems like whatever was fixed in the latter bug doesn't apply to this extension tab case.
Comment 1 Radar WebKit Bug Importer 2021-06-06 17:00:22 PDT
<rdar://problem/78929424>