Bug 226440 - Blob url downloads fail when triggered from webextension
Summary: Blob url downloads fail when triggered from webextension
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Safari 14
Hardware: Mac (Apple Silicon) macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-30 16:59 PDT by Victor
Modified: 2023-12-20 16:25 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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>