const MYCOMPONENT_CONTRACTID = '@mozilla.org/MyComponent;1';
const MYCOMPONENT_CID = Components.ID('{F443406C-961D-4ecc-BF39-
C0E9943C72AE}');
const MYCOMPONENT_IID = Components.interfaces.nsIMyComponent;

function nsMyComponent() { }
nsMyComponent.prototype = {
    reverseIt: function(s) {
        var a = s.split("");
        a = a.reverse();
        return a.join("");
    },
    QueryInterface: function(iid) {
        if (!iid.equals(Components.interfaces.nsISupports) &&
            !iid.equals(MYCOMPONENT_IID))
            throw Components.results.NS_ERROR_NO_INTERFACE;
        return this;
    }
};

var nsMyComponentModule = {
    registerSelf: function(compMgr, fileSpec, location, type) {
        compMgr =
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
        compMgr.registerFactoryLocation(MYCOMPONENT_CID,
                                        "MyComponent test",
                                        MYCOMPONENT_CONTRACTID,
                                        fileSpec,
                                        location,
                                        type);
    },
    getClassObject: function(compMgr, cid, iid) {
        if (!cid.equals(MYCOMPONENT_CID))
            throw Components.results.NS_ERROR_NO_INTERFACE;
        if (!iid.equals(Components.interfaces.nsIFactory))
            throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
        return nsMyComponentFactory;   
    },
    canUnload: function(compMgr) { return true; }
};
var nsMyComponentFactory = {
    createInstance: function(outer, iid) {
        if (outer != null)
            throw Components.results.NS_ERROR_NO_AGGREGATION;
        if (!iid.equals(MYCOMPONENT_IID) &&
            !iid.equals(Components.interfaces.nsISupports))
            throw Components.results.NS_ERROR_INVALID_ARG;
        return new nsMyComponent();
    }
};

function NSGetModule(comMgr, fileSpec) { return nsMyComponentModule; }