Greetings,
I am working on an extension that contains a number of JavaScript files. The main
script is 'bootstrap.js' which (conditionally) includes a number of subscripts.
This appears to cause AMO validation issues.
* Initially I used the following code:
(function (scope) {
var scriptloader = Components.classes["@
mozilla.org/moz/jssubscript-
loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
scope.include = function (path) {
scriptloader.loadSubScript(thisAddon.getResourceURI(path).spec, scope);
};
})(this);
This caused AMO validation to generate a "Illegal or deprecated access to the
'mozIJSSubScriptLoader' global" warning.
* I then tried the following code:
Components.utils.import("resource://gre/modules/Services.jsm");
(function (scope) {
scope.include = function (path) {
Services.scriptloader.loadSubScript(thisAddon.getResourceURI(path).spec, scope);
};
})(this);
as suggested in Erik Vold's blog post
http://erikvold.com/blog/index.cfm/2011/1/2/restartless-firefox-addons-part-2-includes
This causes AMO validation to generate a "Illegal or deprecated access to the
'scriptloader' global" warning.
Q: What is the proper way to include subscripts? Is there a way to include subscripts
without causing AMO validation warnings? Where is this documented?
Regards,
-Roger