Very helpful information here. I'm trying the JS_DefineFunction now
(can't really see the difference with JS_NewFunction).

What I do is:

>From the nsIWebBrowser I query nsIDocShell
>From nsIDocShell I get the interface nsIScriptGlobalObjectOwner
On that pointer I call GetScriptGlobalObject() for the Global JS Object
On the global Object I call GetContext()

To get the JS* objects I call GetGlobalJSObject() on the global object
and GetNativeContext() on the Context. With these two I call
JS_DefineFunction, which returns a valid pointer. But when I load a
test HTML page and call my function, nothing happens. I call:

var res = "none";
res = MyFunctionName(-22);
alert(res);

Where MyFunctionName should implement abs (just for testing). I'm
assuming that the function I define is not global to all contexts (or
runtimes) and that I get a new context when I load the page.

_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to