Following OS.file example it uses TextEncoder however from bootstrap scope this is not available.
Only way I could access it is by going decoder = new Services.appShell.hiddenDOMWindow.TextDecoder();
but is thi the only way?
Following OS.file example it uses TextEncoder however from bootstrap scope this is not available.
Only way I could access it is by going decoder = new Services.appShell.hiddenDOMWindow.TextDecoder();
but is thi the only way?
You can use TextEncoder
and friends inside a javascript module. But doing so might be an overkill, if all you want is a couple of missing globals (putting aside the fact that jsm
are cached and this might not work well with a restartless addon).
Conveniently Addon SDK's loader delivers what you need.
const { TextDecoder, TextEncoder } = Cu.import('resource://gre/modules/commonjs/toolkit/loader.js', {});