Closed Bug 1512363 Opened 7 years ago Closed 7 years ago

history.onVisited can not log historyItem.id of a download item

Categories

(WebExtensions :: General, defect)

Desktop
All
defect
Not set
normal

Tracking

(firefox63 affected, firefox64 ?, firefox65 ?)

RESOLVED INVALID
Tracking Status
firefox63 --- affected
firefox64 --- ?
firefox65 --- ?

People

(Reporter: lolipopplus, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0 Steps to reproduce: try to log id of a download item with these lines: function onVisited(historyItem) { console.log(historyItem.id); } browser.history.onVisited.addListener(onVisited); Actual results: history items are logged properly but not download items Expected results: download items shall be logged as well
OS: Unspecified → All
Hardware: Unspecified → Desktop
How are you triggering the download? Can you provide a full example, test extension and test URL? When I trigger a download by requesting a URL whose response includes Content-Disposition:attachment, I do observe the creation of a history entry AND the triggering of browser.history.onVisited. This only happens when the download actually starts (i.e. user confirms a destination for a download; when the download is canceled before a destination is chosen, there is no history entry).
Flags: needinfo?(lolipopplus)
(In reply to Rob Wu [:robwu] from comment #1) > How are you triggering the download? Can you provide a full example, test > extension and test URL? > I want to create an extension that clears download history upon users visit. It works as follows: 1. users click on an **COMPLETE** download item, either open folder or open directly 2. extension catch the action and clear the corresponding download history item. Per API docs history.onVisited will be also fired for downloads. Is there anything wrong?
Flags: needinfo?(lolipopplus)
(In reply to lolipopplus from comment #2) > I want to create an extension that clears download history upon users visit. > It works as follows: > 1. users click on an **COMPLETE** download item, either open folder or open > directly > 2. extension catch the action and clear the corresponding download history > item. The URL of a downloadable resource (e.g. as described in comment 1) is added to the history as soon as the file is starting to be saved. If a download is opened outside of the browser (e.g. what you described as "open directly"), then it won't be added to the history. This is working as intended. To re-iterate: There is no extension event when the user opens a local file via Firefox or its download manager. > Per API docs history.onVisited will be also fired for downloads. Where can you see that? I can't see any mention of "download" at the documentation of history.onVisited: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history/onVisited
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
Attached image docs about API
> Where can you see that? I can't see any mention of "download" at the > documentation of history.onVisited: Right here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history Also see the attachment. So how can I finish my purpose? Shall I file a new bug ticket about onVisited event to download()? > 1. users click on an **COMPLETE** download item, either open folder or open > directly > 2. extension catch the action and clear the corresponding download history > item.
Flags: needinfo?(robert.wultsch)
(In reply to lolipopplus from comment #5) > > Where can you see that? I can't see any mention of "download" at the > > documentation of history.onVisited: > > Right here: > https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history This note was added in response to bug 1337880, and refers to the behavior that I described in comment 3. > So how can I finish my purpose? Shall I file a new bug ticket about > onVisited event to download()? It is not likely for us to add an event to notify when a downloaded file is opened. If you really want to delete the download from history upon opening it, then you can consider implementing this behavior yourself, with your own UI. For example, add a click listener to your extension button or popup, and call browser.downloads.show (to open the directory) or browser.downloads.open (to open the file), followed by calling the history API to remove the download. PS: when using needinfo, make sure to select my address instead of someone else's.
Flags: needinfo?(robert.wultsch)
See Also: → 1337880
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: