Search code examples
javascriptfirefoxfirefox-addonfirefox-addon-sdk

Use Blob on newer firefox add-on


This answer is outdated:

let { Cc, Ci, Cu, CC } = require('chrome');
const {Blob, File} = Cu.import("resource://gre/modules/Services.jsm", {});
console.log(typeof Blob);//undefined

How do I import a blob?


Solution

  • Cu.importGlobalProperties(["Blob"]);
    

    This works from FF35 onwards. The older approach should work on FF34 and lower.

    Related reading at: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.importGlobalProperties