Overriding in JS an XPCOM contract that has a noscript method

Hello,

I’m trying to override an XPCOM contract using a Javascript-based Firefox extension. This is normally pretty painless, but the specific XPCOM contract I’m trying to override has a single method that is marked “noscript”. I don’t actually need to change the implementation of that “noscript” method – I only want to change one method, which is not marked as “noscript”. Given that I don’t need to change the “noscript” method’s behavior in any way, is there any way that I can change the behavior (using Javascript) of a scriptable method of a scriptable XPCOM interface, when that interface has one other method that is marked “noscript”?

Thanks.

PS: Yes, I’m aware that XPCOM is going away soon.

I tried to do XPCOM overriding with js and failed, can you show a quick walkthrough, like example “nsiLoginManager so I can use functions like _getForm” method here: https://groups.google.com/forum/?fromgroups=#!searchin/mozilla.dev.extensions/override/mozilla.dev.extensions/tYEBviCniB8/MnDlj1L_lgkJ

If you show me that then with that knowledge i can help you research.

Hello,

Some working code for overriding an XPCOM contract with a Javascript implementation is at https://github.com/hlandau/nczilla . This code is overriding the @mozilla.org/security/certoverride;1 contract, for which all the methods are scriptable. I’m trying to find a way to do something similar for a contract that has one unscriptable method (although the method I want to replace is scriptable).

Actually, I’d also be interested in knowledge about overriding an XPCOM contract with a C++ implementation. I imagine this would fix the specific problem I’m having, I just can’t find any current example code for such an override.

Cheers.

1 Like