Labs/Jetpack/Reboot/JEP/108: Difference between revisions
Jump to navigation
Jump to search
Dandonkulous (talk | contribs) |
Dandonkulous (talk | contribs) |
||
Line 25: | Line 25: | ||
=== API Methods === | === API Methods === | ||
* $Moz.background({ interval: 10000, bind:jetpack.tabs[0] }, function(){ | * <pre>$Moz.background({ interval: 10000, bind:jetpack.tabs[0] }, function(){ | ||
return window.document; | return window.document; | ||
}); | });</pre> | ||
** Background Page work units are bound with the Background Page's window object by default | ** Background Page work units are bound with the Background Page's window object by default | ||
** If interval option is present, the function is wrapped with setInterval(); and the $Moz.background method returns the interval timer so that it may be cleared outside of the Background Page. | ** If interval option is present, the function is wrapped with setInterval(); and the $Moz.background method returns the interval timer so that it may be cleared outside of the Background Page. | ||
** Functional context for the function passed to the background page can be passed as an option | ** Functional context for the function passed to the background page can be passed as an option |
Revision as of 20:57, 2 February 2010
JEP 108 - Background Pages
- Champion: Daniel Buchner - daniel@mozilla.com
- Status: Accepted/In-Queue
- Bug Ticket:
- 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, descending, chrome privileges. It is essentially along the same line of a Web Worker, just more open and accessible.
Key Issues
Ensure script and styles injected into the page is evaluated by the parser in the normal load cycle. Perhaps we achieve this by dynamically creating resource URIs that take the styles and script blocks entered via the Background Page API methods and dynamically create css/js files out of them for injection in the appropriate places (CSS files in the doc head, JS files just after the close of the body tag)
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
$Moz.background({ interval: 10000, bind:jetpack.tabs[0] }, function(){
return window.document;
});
- Background Page work units are bound with the Background Page's window object by default
- If interval option is present, the function is wrapped with setInterval(); and the $Moz.background method returns the interval timer so that it may be cleared outside of the Background Page.
- Functional context for the function passed to the background page can be passed as an option