Evaluating JavaScript in an Embedded XULRunner/Gecko Window

Feb 17, 2009 23:41


This post has moved.

I intended to write something with more substance tonight, but I'm ( Read more... )

imvu

Leave a comment

Comments 1

aegisknight February 18 2009, 22:42:47 UTC

More magic:

// This is important: we need to ensure the 'inner' DOM window is created.
// If we don't, it is initialized while XPConnect is walking the outer scope
// chain, which reinitializes the JS context. This causes JS_SetOptions to be
// called in the middle of execution, disabling our DONT_REPORT_UNCAUGHT flag,
// which prevents exceptions from propagating out.
nsCOMPtr domWindow;
rv = webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
if (NS_FAILED(rv)) {
throw GeckoError("Failed to get content DOM window");
}
nsCOMPtr outer(do_QueryInterface(domWindow));
nsCOMPtr(outer->EnsureInnerWindow());

Run this code before calling JS_SetOptions.

Reply


Leave a comment

Up