Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sandbox calling functions

16 views
Skip to first unread message

gigasof...@gmail.com

unread,
Apr 17, 2013, 7:05:06 PM4/17/13
to
Hi,

I have an existing code base that I want to use in a sandbox and I want to call a function periodically (from the extension) that is in my existing sandbox code. How do I do that? I have tried about everything and I get function undefined.

Something like...

var sb = new Components.utils.Sandbox(urlwithjscode);
sb.ExistingFunction('blah');

How can this be done?

Any help is appreciated?

Thanks!


Tom -

Dave Townsend

unread,
Apr 17, 2013, 9:09:50 PM4/17/13
to
On 4/17/2013 4:05 PM, gigasof...@gmail.com wrote:
> Hi,
>
> I have an existing code base that I want to use in a sandbox and I want to call a function periodically (from the extension) that is in my existing sandbox code. How do I do that? I have tried about everything and I get function undefined.
>
> Something like...
>
> var sb = new Components.utils.Sandbox(urlwithjscode);

This line creates an empty sandbox, the url passed gives the sandbox its
privileges. You have to load some code into it. The subscript loader is
useful for this:

Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.createInstance(Ci.mozIJSSubScriptLoader)
.loadSubScript(urlwithjscode, sb);

gigasof...@gmail.com

unread,
Apr 18, 2013, 9:50:11 AM4/18/13
to
On Wednesday, April 17, 2013 8:09:50 PM UTC-5, Dave Townsend wrote:
Thanks Dave for the reply.

Okay - can I use a chrome file as the URL to instantiate the sandbox? I would like to use a resource in the extension. In other words something like

var sb = new Components.utils.Sandbox("chrome://bla");
or
var sb = new Components.utils.Sandbox("file://bla");

Dave Townsend

unread,
Apr 18, 2013, 3:09:48 PM4/18/13
to
If you just want to give it full privileges like the rest of chrome then
pass it the system principal
(Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal))
0 new messages