Brendan Eich wrote:
ALBANI damiano wrote:

Hello,

I am trying to use the autoconfig feature of Mozilla to register new MIME handlers at browser *startup*.
To avoid duplicating code, I am using the logic from "chrome://communicator/content/pref/overrideHandler.js", the one used by the preferences panel dealing with helper applications.
However, as there's no 'include' or 'import' feature in JavaScript, I have to fetch the file and then eval() the code.



You should instead use the subscript loader (http://lxr.mozilla.org/mozilla/search?string=subscriptloader, see in particular the IDL at http://lxr.mozilla.org/mozilla/source/js/src/xpconnect/idl/mozIJSSubScriptLoader.idl).



Using eval this way, you end up with all the functions loaded from the file scoped by the activation object for the call to addMIMEHandler that called eval. To override this scoping, pass window as the optional second argument to eval.

As stated in a previous post, I'm not in a XUL environment, so I want the 'include' to behave like a classic <script src="file.js"/> include.


I can successfully create a HandlerOverride object, but any call on the setter/getter of this class fails (silently unfortunately). Where could this come from ?

I have no idea. If there's nothing on the JS console, could you try running under a debugger? Put a breakpoint in js_ErrorToException in js/src/jsexn.c.

Sorry to sound ignorant, but how do I do that ? I've rebuild Mozilla with --enable-debug but it seems a bit light on messages. How can I enable *full* debug (including JavaScript engine) ?

What is strange is that this process works in a <script> included in an HTML page (though it needs XPConnect privileges).



That is strange, and it suggests a bug in XUL content code somewhere.

Instead of the distribution's overrideHandler.js file, I've used a small
test case JavaScript instead, and it *does* fails on setter/getter calls, but not on normal "name: function(arg)" function calls.


--
Damiano ALBANI

_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to