Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Illegal or deprecated access to the 'scriptloader' global

59 views
Skip to first unread message

Roger Hünen

unread,
Nov 24, 2011, 2:18:01 AM11/24/11
to
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

Jorge Villalobos

unread,
Nov 24, 2011, 12:25:10 PM11/24/11
to Roger Hünen
Don't worry about those warnings. They are mostly false positives. We
have been discussing removing the loadSubScript warning altogether,
since it is no longer dangerous (it used to be possible to load remote
scripts with it).

- Jorge

Roger Hünen

unread,
Nov 28, 2011, 2:18:21 PM11/28/11
to
OK. Thank you for the clarification!

I have seen a few more cases where validator warnings are potentially false
positive (but may not always be false positives!).

I therefore have a suggestion for the add-on validator.

You may want to change the validator to run in two modes:
- Author mode: flag errors that the author must fix as well as warnings that
the author should fix (at least in certain cases).
- Editor mode: additionally generate warnings pointing editors to potentential
issues. These would be cases where there can be both appropriate use and
inappropriate use of certain features which can only be resolved by more
in-depth investigation.

This approach could help to prevent unnessary confusion with authors as well as
help editors to direct their attention where it is needed most.

Just my two cents.

Regards,
-Roger
0 new messages