5 views
Skip to first unread message

Lloyd Hilaiel

unread,
Jul 30, 2010, 9:49:41 AM7/30/10
to mozilla-la...@googlegroups.com
Is there any mechanism implemented or planned that would allow a
jetpack to expose an api to page javascript that was available at page
load time?

best,
lloyd

Hernan Rodriguez Colmeiro

unread,
Jul 30, 2010, 9:53:31 AM7/30/10
to mozilla-la...@googlegroups.com

You mean like adding an API to run chrome privileged code from the web
page? I think is not possible due to security restrictions. If you're
thinking on another thing, please explain yourself a little longer
because I didn't get it very well :)

Hernán

Lloyd Hilaiel

unread,
Jul 30, 2010, 10:17:05 AM7/30/10
to mozilla-la...@googlegroups.com

Hi Hern�n,

Sorry for being so terse! Certainly not chrome priviledged code, but
yes, some secure abstraction or pattern to let unpriviledged code call
into jetpacks. Perhaps it's built on top of message passing? The
high level feature I'm curious about here would be to be able to
implement emergent standards or new ideas for page accesible
javascript APIs in jetpacks.

lloyd

> Hern�n
>
> --
> You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
> To post to this group, send email to mozilla-la...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-jet...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-jetpack?hl=en.
>

Benjamin Smedberg

unread,
Jul 30, 2010, 10:31:30 AM7/30/10
to mozilla-la...@googlegroups.com, Lloyd Hilaiel

Absolutely, the page mods API should make this possible.

--BDS

Hernan Rodriguez Colmeiro

unread,
Jul 30, 2010, 10:49:43 AM7/30/10
to mozilla-la...@googlegroups.com
On Fri, Jul 30, 2010 at 11:17, Lloyd Hilaiel <ll...@hilaiel.com> wrote:
> Sorry for being so terse!  Certainly not chrome priviledged code, but
> yes, some secure abstraction or pattern to let unpriviledged code call
> into jetpacks.  Perhaps it's built on top of message passing?  The
> high level feature I'm curious about here would be to be able to
> implement emergent standards or new ideas for page accesible
> javascript APIs in jetpacks.
>

I think message-passing is on the pipeline but still not yet
completely implemented. The thing here is the Electrolysis project,
that will move the page content and jetpack code into different
threads, so the implementation wasn't so trivial.
Anyway, hopefully someone with more knowledge in the subject than I
will comment here.

Hernán

Lloyd Hilaiel

unread,
Jul 30, 2010, 11:22:02 AM7/30/10
to Benjamin Smedberg, mozilla-la...@googlegroups.com

I see, use case 4:
https://wiki.mozilla.org/Labs/Jetpack/Reboot/JEP/107#Use_Cases

I understand now how one would actually implement the top half, the
page visibile API, but not the plumbing which allows the javascript
executing in the page context to communicate with the chrome
privileged jetpack. I expect JSON message passing would be a future
proof (electrolysis) underlying transport... Is there any more
thought on how this would work?

lloyd

> --BDS

Atul Varma

unread,
Jul 30, 2010, 1:31:33 PM7/30/10
to mozilla-la...@googlegroups.com, Lloyd Hilaiel
Hi Lloyd!

The addons-builder-helper adds an object called window.mozFlightDeck to
pages on certain trusted domains:

http://github.com/toolness/addons-builder-helper

It's not necessarily ideal, though. Chrome Object Wrappers, or COWs,
were made to make this really easy:

https://wiki.mozilla.org/XPConnect_Chrome_Object_Wrappers

I think the addons-builder-helper was originally written to run on
versions of Firefox that didn't have COWs, but any new implementations
could probably use them and require much less code.

- Atul

Ben

unread,
Jul 31, 2010, 11:55:44 AM7/31/10
to mozilla-labs-jetpack
I am currently using sessionStorage to communicate with pages on a
specific domain. This works well because all content pages on that
domain will get a "storage" event. I am currently using a PageWorker
with a dummy page, but there's probably an easier way to get to the
localStorage object for a domain.

So for example in the phantom page you would do:
page.contentWindow.sessionStorage.message = { /* json */ };

And in content pages:
addEventListener("storage", function(e) {
if (e.key == "message" && e.newValue) {
processMessage(e.newValue);
}
}, false);

HTML5 rocks. Hope this helps!
Reply all
Reply to author
Forward
0 new messages