Reputation: 720
I am working through the XUL School primer on XPCOM. I am having trouble accessing components. No matter what component I try to access, for example (from MDN):
// xpconnect to cookiemanager
// get the cookie manager component in JavaScript
var cmgr = Components.classes["@mozilla.org/cookiemanager;1"].getService();
cmgr = cmgr.QueryInterface(Components.interfaces.nsICookieManager);
I keep getting the error "TypeError: Components.classes is undefined.". Other places say this could be a problem with other add-ons being problematic, so I restarted Firefox in safe mode but I still got this problem.
Other questions on here seem similar to this, stating that components need to be registered in the manifest file; however, these seem to be in reference to user-added components. Is this the case here? What am I doing wrong?
edit: I have XPCOMViewer installed and I can see that the components are there. When I use XPCOMViewer to generate the JavaScript to access the component, it is giving the exact same thing as I am posting above. What in the world is going on here?
Upvotes: 3
Views: 1708
Reputation: 5171
Try this:
const {Cc,Ci,Cu} = require("chrome");
var cmgr = Cc["@mozilla.org/cookiemanager;1"].getService();
cmgr = cmgr.QueryInterface(Ci.nsICookieManager);
Upvotes: 1