Open Bug 1890187 Opened 5 months ago Updated 5 months ago

browser.downloads.erase not removing from Library

Categories

(WebExtensions :: General, defect, P3)

Firefox 125
defect

Tracking

(firefox125 affected, firefox126 affected, firefox127 affected)

Tracking Status
firefox125 --- affected
firefox126 --- affected
firefox127 --- affected

People

(Reporter: mozilla-bugzilla, Unassigned)

References

(Depends on 2 open bugs, Blocks 1 open bug)

Details

(Keywords: dev-doc-needed)

Attachments

(1 file)

Attached file test-download.zip

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0

Steps to reproduce:

Download any file using browser.downloads.download(), and then run browser.downloads.erase() in the WebExtension.

Test using the attached WebExtension.

Actual results:

The download(s) are not removed from the listing in the Library.

If the extension subsequently downloads another file only then is the previous download removed from the Library.

Expected results:

Downloads should be removed from Library upon calling browser.downloads.erase().

The Bugbug bot thinks this bug should belong to the 'Firefox::Downloads Panel' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Downloads Panel
Product: WebExtensions → Firefox

Bug #1670407 could be the same issue.

Component: Downloads Panel → General
Product: Firefox → WebExtensions

Hello,

I reproduced the issue on the latest Nightly (126.0a1/20240414212202), Beta (125.0/20240408174943) and Release (124.0.2/20240401114208) under Windows 10 x64 and Ubuntu 22.04 LTS.

Clicking the attached extension button will initiate a file download and the extension console will log a message stating that the download will be erased. However, the downloads library still shows the downloaded file.
Any subsequent download will replace the pervious downloaded file in the Library i.e. the previous download is removed from the Library, but the current one remains listed there.

Status: UNCONFIRMED → NEW
Ever confirmed: true

I believe this used to work at some point, Alex can you try for a regression range please?

Flags: needinfo?(acornestean)

I’ve went back until Firefox 51 and the issue is still reproducible on that version using the attached extension and the STR I mentioned in Comment 3.
If you need me to go further back let me know.

Flags: needinfo?(acornestean)

After taking a look to the implementation and other bugzilla issue related to the downloads API I see that this is actually a pre-existing limitation of the initial implementation of the downloads API (as also confirmed by Alex in comment 5):

the downloads API is currently only seeing the downloads listed in the downloads list (which is the panel that appears in the toolbar when a downloads is triggered in the current session), but it doesn't see the downloads history (which is what is going to be listed in the downloads part of the Library dialog)

Due to that:

  • downloads.search API method doesn't return downloads from previous sessions that may be instead visible in the Library dialog (Bug 125507 seems to be already tracking that)
  • and downloads.erase method does remove the download item from the downloads list only but not from the downloads listed in the Library (which is now tracked by this bugzilla issue)

Bug 125507 depends also from Bug 1834451 "Support add/remove in DownloadHistoryList", which seems to be also something that fixing this bug would need and so I'm going to add it as a dependency for this bug too.

Blocks: 1213445
Severity: -- → S3
Depends on: 1834451, 1255507
Priority: -- → P3

I'm also adding the dev-docs-needed keyword to this issue, as a reminder for updates to the API reference and to the notes related to this API method in the browser compat data.

It would be actually good to update the browser compat data even before this bug will get fixed, to highlight the current limitations of this API (at the moment there is no note to hightligh this in the compat table as currently visible here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/erase#browser_compatibility).

Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: