User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393 Steps to reproduce: 1) Initiate a download from an extension using the downloads.download(). 2) Try to analyse the dowloadItem in the downloads.onCreated event. 3) Look for the byExtensionId & byExtensionName attributes of the downloadItem. Actual results: Both attributes are always "undefined" Expected results: Both attributes should contain the extensions ID & Name respectively.
Created attachment 8884672 [details] downloads-byExtensionId.zip Confirmed in Firefox 55.0b5. 1. Install the attached add-on (via about:debugging for example). 2. Click on the extension button in the toolbar that appears after installing the extension. 3. Open the global browser console and look at the printed messages. Result: onCreated at 7/9/2017, 10:42:31 PM background.js:2:5 id = 8 background.js:4:9 ... (cut) ... byExtensionId = undefined background.js:4:9 byExtensionName = undefined background.js:4:9 downloads.download callback with ID: 8 background.js:12:9 Note hat byExtensionId and byExtensionName are both undefined, while they should have a sensible value. The only place where the extension is set for a DownloadItem is for the callback of downloads.download . However, the downloads.onCreated event fires before that  and causes a DownloadItem to be created without extension. The result is cached too, so when the download.download callback is invoked, the DownloadItem is not cached (nor updated with the extension). Even if the above bug were to be fixed, the whole implementation would only work for downloads created in the current session; if the browser is restarted, the byExtensionId/byExtensionName fields would be cleared. Though if the browser is restarted, the downloads list would be empty anyway, because of bug 1255507. And, if an extension is uninstalled, the byExtensionId and byExtensionName fields are cleared too (contrary to Chrome, which shows the ID and the last known name if the extension has been uninstalled).  https://searchfox.org/mozilla-central/rev/4aaa08513911c3cfe750611a6c087b438bb1f88e/toolkit/components/extensions/ext-downloads.js#551  https://searchfox.org/mozilla-central/rev/4aaa08513911c3cfe750611a6c087b438bb1f88e/toolkit/components/extensions/ext-downloads.js#163-165
(updating bug flags based on previous comment)