Can somebody tell me how to register a Mozilla/Firefox DownloadList view?
This is what I am using:, but it completely breaks the download manager:
const {Cc,Ci,Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
XPCOMUtils.defineLazyModuleGetter(this, "Downloads", "resource://gre/modules/Downloads.jsm");
let view = {
onDownloadAdded: download => console.log("Added", download),
onDownloadChanged: download => console.log("Changed", download),
onDownloadRemoved: download => console.log("Removed", download),
};
console.log('Test1');
Downloads.getList(Downloads.ALL)
.then(list => {
console.log('Test2');
list.addView(view);
console.log('Test3');
});
Unfortunately, after executing this code, downloading seems to be thoroughly broken: it does not even allow downloading any more.
Everything seems to go well:
I/GeckoConsole( 8723): Test1
I/GeckoConsole( 8723): Test2
I/GeckoConsole( 8723): Test3
But I am not seeing the Downloads
in the DownloadList
which should also have been logged.
When I then try to download another file, I get:
W/GeckoConsole( 8723): [JavaScript Error: "[Exception... "Component returned fai
lure code: 0x80004005 (NS_ERROR_FAILURE) [nsITransfer.init]" nsresult: "0x80004
005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/contentA
reaUtils.js :: internalPersist :: line 47" data: no]" {file: "resource://gre/mo
dules/Promise.jsm -> resource://gre/modules/Promise-backend.js" line: 79}]