I’m a developer of VimFx. VimFx has a public API, that can be used to customize it. We provide some super simple boilerplate for a restartless extension allowing users to write a JavaScript config file if they wish, which for example can be used to add custom keyboard commands (JavaScript functions).
This has worked pretty nicely for several months now.
However, because of extension signing, users can’t install their config file/addon anymore (well, for now they can by toggling the xpinstall.signatures.required
pref).
I’m therefore looking into other ways of allowing advanced users to customize VimFx through a JavaScript file. The current idea is to add a pref with the path to the file, and then load it:
let {Cc, Ci, Cu} = Components
let vimfx = { /* Addon config API... */ }
// Imagine the following path being read from the prefs of my addon:
let path = 'file:///home/user/.config/VimFx/config.js'
// Is it allowed to do this?
Services.scriptLoader.loadSubScript(path, {vimfx}, 'UTF-8')
// Or this?
let {config} = Cu.import(path, {})
config(vimfx)
// Or this?
let principal = Cc['@mozilla.org/systemprincipal;1'].createInstance(Ci.nsIPrincipal)
let sandbox = Cu.Sandbox(principal, {
wantComponents: false,
})
sandbox.vimfx = vimfx
Services.scriptLoader.loadSubScript(path, sandbox, 'UTF-8')
Which of the above three methods would pass a Full Review on AMO? (Ideally I’d like to make Components
available in the config file for maximum flexibility, but I understand if that isn’t allowed.) I guess this also depends on what the vimfx
API object exposes.
If none of the above are OK, is there anything else we can do other than telling users to switch to Firefox Developer Edition if they’d like to use a VimFx config file?