Changes

Jump to: navigation, search

Labs/Jetpack/JEP/25

289 bytes removed, 15:40, 15 September 2009
XULRunner extension, in a JS module: culled unnecessary comments
<pre class="brush:js;">
// The same file we loaded in-page in the last example can actually be
// loaded as a JS module, too:
var SecurableModule = {};
Components.utils.import("resource://some_extension/content/booster.js",
SecurableModule);
// Create a loader for SecurableModules that gives them chrome
// privileges by default and roots the filesystem at
// chrome://some_extension/content/lib/. We can't provide a
// relative directory name here because JS modules don't conventionally
// have a concept of relative directories (and we won't introduce such
// a concept here to reduce potential confusion).
var loader = SecurableModule.Loader({
defaultPrincipal: "system",
});
// Load the 'foo' SecurableModule and call its exported doSomething()
// function.
loader.require('blarg').doSomething();
</pre>
Note that unlike the previous example, we can't provide a relative directory name for <tt>rootPath</tt> because JS modules don't conventionally have a concept of relative directories (and we won't introduce such a concept here to reduce potential confusion). Note also that while we could unload the module if we want, we don't really
have any pressing reason to, since JS modules themselves are never
unloaded.
874
edits

Navigation menu