Question

Example: I want to use the interface of nsILocalFile in Javascript, how to find the corresponding Contract ID("@mozilla.org/file/local;1")? Is there a map in the source code?

Was it helpful?

Solution

You don't. This isn't a one-to-one relationship between contracts and interfaces but a many-to-many one:

  • A single component as accessible by a contract can implement multiple interfaces.
  • A single interface can have multiple components implementing it and therefore multiple contracts.

But, often it is a one-to-one relationship in practice. E.g. if I wanted to find out about what components implement nsILocalFile, I'd search it in the sources, for instance:

Other times, the contract ids are even specified in the idl itself, e.g. in nsITimer.idl (at the bottom).

The most commonly used interfaces usually are also present on MDN incl. contracts, e.g. nsILocalFile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top