Download attribute not working in web extension popup

Hi in my web extension I have a button, which I programmatically create a file for download when the user clicks it.

Here is my code:
Code Block
const a = document.createElement('a');
const file = new Blob(['test'], { type: 'text' });
a.href = URL.createObjectURL(file);
a.download = "test.txt"
a.click()

However, this does nothing when I do it within the popup. It works fine on the main Safari webpage. Am I doing something wrong?


Please file some feedback at https://feedbackassistant.apple.com , including what you are trying to do (the type of download you are trying to perform).

Are there any updates to this?

This also affects bundled html extension pages within a web extension. Using the Safari App Extension API (as compared to the Web Extension API), it is possible to download arbitrary files using the method above, but with the Web Extension API, the download attribute is not respect and a new tab opens with the download content.

Download attribute not working in web extension popup
 
 
Q