Labs/Jetpack/Reboot/JEP/108
JEP 108 - Background Page
- Champion: Daniel Buchner - daniel@mozilla.com
- Status: Under Review
- Bug Ticket: 546740
- Type: API
Proposal
Background Pages are like a more open and free sandbox for doing most anything in a traditional web page with a DOM context, but with a key difference: the page is augmented with escalated, waterfall chrome privileges. It is essentially along the same line of a Web Worker, just more open and accessible.
Key Issues
Dependencies & Requirements
- We must be able to give the code in the top window of this page chrome privileges that are strictly one-way/descending in nature.
- Dynamically generated code sent to the Background Page should be injected and executed in the Background Page's window context.
Internal Methods
- TBD
API Methods
Background Page Global: $dom
Background Page Method: run
Arguments:
- options - (object)
- bind: (mixed) a variable that will be bound as the 'this' keyword in the function
- arguments: (array > mixed) an array of mixed variables passed as the function arguments
- timeout: (number) a number that is used to set the timeout duration
- interval: (number) a number that is used to set the interval duration
- action - (function) a function to be executed within the DOM of the Background Page - by default, the Background Page's window object is the bound 'this' within the function
Returns:
user defined return value - The function's return value as specified by the user
or
If timeout or interval options are used:
array - an array whose first item is the function's user defined return value, and second is a variable the user can save to clear the timing event
Notes:
Examples:
$dom.run({ interval: 10000 }, function(){ return window.location; });
Background Page Method: clear
Arguments:
- type - (string) can be 'script', 'elements', or 'all';
Returns:
The Background Page Global object: $dom
Examples:
$dom.clear('script');
Background Page Method: reset
Arguments:
No arguments are used in accordance with this method
Returns:
The Background Page Global object: $dom
Examples:
$dom.reset();