Search code examples
firefoxfirefox-addonfirefox-addon-sdk

Add-on SDK Require Location


require('chrome');

When requiring, from which location Firefox gets the requested module?

Is there any relevant source file for the modules?


Solution

  • require('chrome'); is a special module defined within the loader. Its source is

        'chrome': { Cc: Cc, Ci: Ci, Cu: Cu, Cr: Cr, Cm: Cm,
                    CC: bind(CC, Components), components: Components,
                    // `ChromeWorker` has to be inject in loader global scope.
                    // It is done by bootstrap.js:loadSandbox for the SDK.
                    ChromeWorker: ChromeWorker

    This is copy pasted from here. Cc is Components.classes, Ci is Components.interfaces, Cu is Components.utils, Cr is Components.results, Cm is Components.manager and CC is Components.Constructor which are defined earlier on. You can find documentation for all these on MDN.