// 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());
Comments 1
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