chrome privs from page-mod

31 views
Skip to first unread message

Joe Walker

unread,
Feb 3, 2011, 5:23:50 AM2/3/11
to mozilla-la...@googlegroups.com

I have a page-mod, from which I would like access to some things (specifically x-d stylesheets) normally denied to web applications. Clearly I don't have access to require('chrome'). How do I work around this?
Thanks,

Joe.

Hernan Rodriguez Colmeiro

unread,
Feb 3, 2011, 9:26:23 AM2/3/11
to mozilla-la...@googlegroups.com

You have to send messages to the parent page-mod, using the
postMessage method and onMessage listener.

Hernán

Joe Walker

unread,
Feb 3, 2011, 10:12:15 AM2/3/11
to mozilla-la...@googlegroups.com

On 03/02/2011 14:26, Hernan Rodriguez Colmeiro wrote:
> On Thu, Feb 3, 2011 at 07:23, Joe Walker<jwa...@mozilla.com> wrote:
>> I have a page-mod, from which I would like access to some things
>> (specifically x-d stylesheets) normally denied to web applications. Clearly
>> I don't have access to require('chrome'). How do I work around this?
>> Thanks
> You have to send messages to the parent page-mod, using the
> postMessage method and onMessage listener.

But I want chrome privs to elevated access the DOM of the page in which
the page-mod exists - the point of using a page-mod is to get access to
the DOM.

Joe.

Hernan Rodriguez Colmeiro

unread,
Feb 3, 2011, 11:19:07 AM2/3/11
to mozilla-la...@googlegroups.com

Well, you can send messages from the content-script of the page-mod
(that has access to the DOM, thus you can add handlers there) to the
parent page-mod object (that has chrome privileges). The page-mod does
what you need, and sends back a message to its content script -in case
you need a callback- saying that its done or returning a result. Keep
in mind that you can only send JSON messages through the
content-script and the page-mod.

The reason scripts with DOM access don't have chrome privileges other
than security reasons is that in the near future the Jetpack code will
run in a different process than content (this is what the Electrolisys
project has been doing, a.k.a. E10s). Thus the SDK has to be
E10s-compatible and chrome privileges where stripped from
content-scripts.

Hernán

KWierso

unread,
Feb 3, 2011, 4:46:32 PM2/3/11
to mozilla-labs-jetpack
FWIW, you can use the Stylesheet service from the addon code outside
of the pagemod.

Joe Walker

unread,
Feb 4, 2011, 4:00:09 AM2/4/11
to mozilla-la...@googlegroups.com
On 03/02/2011 16:19, Hernan Rodriguez Colmeiro wrote:
> On Thu, Feb 3, 2011 at 12:12, Joe Walker<jwa...@mozilla.com> wrote:
>> On 03/02/2011 14:26, Hernan Rodriguez Colmeiro wrote:
>>> On Thu, Feb 3, 2011 at 07:23, Joe Walker<jwa...@mozilla.com> wrote:
>>>> I have a page-mod, from which I would like access to some things
>>>> (specifically x-d stylesheets) normally denied to web applications.
>>>> Clearly
>>>> I don't have access to require('chrome'). How do I work around this?
>>>> Thanks
>>> You have to send messages to the parent page-mod, using the
>>> postMessage method and onMessage listener.
>> But I want chrome privs to elevated access the DOM of the page in which the
>> page-mod exists - the point of using a page-mod is to get access to the DOM.
> Well, you can send messages from the content-script of the page-mod
> (that has access to the DOM, thus you can add handlers there) to the
> parent page-mod object (that has chrome privileges).

The parent of the page-mod object is the addon, which does have chrome
privs, but which does not have access to the DOM. I need both to be able
to look at the contents of cross domain stylesheets.
Thanks,

Joe.

Joe Walker

unread,
Feb 4, 2011, 4:01:24 AM2/4/11
to mozilla-la...@googlegroups.com
On 03/02/2011 21:46, KWierso wrote:
> FWIW, you can use the Stylesheet service from the addon code outside
> of the pagemod.
Thanks. As far as I'm aware though, that doesn't let you look at the
rules of existing stylesheets??
Joe.

Reply all
Reply to author
Forward
0 new messages