fune/toolkit/components/extensions/ext-c-downloads.js
Mark Striemer f785de42e9 Bug 1369782 - Require user interaction for downloads.open() r=aswan
MozReview-Commit-ID: 9RkIOfZEfnf

--HG--
extra : rebase_source : 0fa336cb476cb560fc2bb0117be32d463d11b414
2017-06-02 18:34:08 -05:00

22 lines
555 B
JavaScript

"use strict";
var {
ExtensionError,
} = ExtensionUtils;
this.downloads = class extends ExtensionAPI {
getAPI(context) {
return {
downloads: {
open(downloadId) {
let winUtils = context.contentWindow.getInterface(Ci.nsIDOMWindowUtils);
if (!winUtils.isHandlingUserInput) {
throw new ExtensionError("May only open downloads from a user input handler");
}
return context.childManager.callParentAsyncFunction("downloads.open_parent", [downloadId]);
},
},
};
}
};