On Mon, Jul 14, 2014 at 7:22 AM, Ryan Litvak <[email protected]> wrote:
> My goal is to allow our users to upload custom scripts to extend the
> functionality of our existing system. Essentially, at specific trigger
> points they can tie in scripts. For those triggers I want to run their
> code in caja so I can sandbox it.
> …
> (function f(x) {
> return x;
> });
>
> The system has a local endpoint where it can retrieve the scripts they
> have configured. Here is a simplified version of the problem I am running
> into:
> …
> caja.load(undefined, undefined, function (frame) {
> frame.code("/scripts/application/scripting/script.js",
> 'application/javascript')
> .run(function(r) {
> debugger;
> });
> });
>
> At this point, the value of r is undefined. I expected to get the
> sandboxed function from my custom script.
>
Unfortunately, getting the “completion value” of a script is not supported
in current Caja due to technical infeasibility. (The value returned to the
run callback is a legacy of the static rewrite-based design where it was
possible, but code executed much slower.)
Instead of trying to collect a return value from the script, use the "API"
facility to provide an object/function to the script which it calls to pass
the user-defined function in. There is an example for this at:
https://developers.google.com/caja/docs/callingguestcode/
--
---
You received this message because you are subscribed to the Google Groups
"Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.