Skip to content
brettz9 edited this page Dec 20, 2012 · 16 revisions

Frequently asked questions

## **How can I use regular XPCOM APIs?**

Firstly, I discourage this if at all possible, since one of the reasons for AsYouWish is to move toward the future-looking API of the Addons SDK, both for the hope of cross-browser support down the road (since other browsers will not agree to making calls with @mozilla.org) and given that Firefox itself is moving in this direction. That being said, the APIs may not yet be adequate for your needs, in which case, see AMO SDK Docs on XPCOM on how to gain XPCOM access. If you don't want other browsers to choke at the object destructuring involved with var {Cc, Ci} = require("chrome"); used in the example there, you can use this longer form instead: var chrome = require('chrome'), Cc = chrome.Cc, Ci = chrome.Ci;. Please also know that since my code is wrapping the APIs I have exposed to you (in order to avoid complaints from Firefox which would prevent their usage in the future if not already), you cannot use instanceof with such objects and get the expected result. (I also found one cannot use the word Components at all within SDK code, but there seems to be no problem when accessed within HTML via my add-on. (If you do need the Components object, you can do require('chrome').components.) If you come across other issues, feel free to add an explanation here, or at least report under Issues.

Clone this wiki locally