Chrome Boosters are third-party modules that can be used to provide functionality to Jetpack Features or Firefox Add-ons. As their name implies, they are chrome-privileged and use dependency injection to offer functionality to non-chrome-privileged Jetpacks.
These modules essentially formalize the mechanism used within Jetpack to provide the jetpack namespace to Jetpacks.
Chrome Boosters have the following characteristics:
- They are a superset of the SecurableModule standard.
- They can be loaded and unloaded multiple times throughout the lifetime of their containing application (yes, leaks are an unfortunate possibility).
- They have access to an onUnload() function that allows them to register callbacks to perform cleanup tasks when unloaded.
- They have full access to XPConnect's Components object, and all its sub-objects.
For security purposes, Chrome Boosters can only be accessed either
- locally, through a containing addon, or
- over secure HTTP to a trusted host.
Additionally, to encourage good coding practices and documentation, Chrome Boosters must have:
- A simple, straightforward mechanism for writing and executing test cases.
- An easy-to-learn documentation system capable of producing beautiful documentation.
- A mechanism for tracking objects of interest belonging to the Chrome Booster to aid in memory profiling and leak detection.
Potential Code
This code doesn't actually work; it's just aspirational.
Assume that the following code is contained in a file at chrome://some_extension/content/foo.html.
<html>
<!-- This script makes the SecurableModule global available. -->
<script src="securable-module.js"></script>
<script>
// Create a loader for SecurableModules that gives them chrome
// privileges by default and roots the filesystem at (our URL)/lib.
var loader = SecurableModule.Loader({defaultPrincipal: "system",
rootPath: "lib"});
// Load the 'foo' SecurableModule and call its exported doSomething()
// function.
loader.require('blarg').doSomething();
window.addEventListener(
"unload",
function() {
// Send an unload signal to free any resources created by modules so
// far.
loader.require('unload').send();
},
false
);
</script>
</html>
Note that the unload module conventions are laid out by the Narwhal CommonJS-based platform.