I had it working for a while, but now it's not anymore...
My situation is that I have an object implementing
nsIWebProgressListener and in OnStateChange I check:
if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_DOCUMENT))
which should mean that loading was stopped as far as I could find out
(Status != 0 is filtered out earlier).
When the above is true, I call this subroutine. All returned pointers
are valid all the time. I guess I'm inserting my object into the wrong
context somehow. The thing is that it did work for a while with this
code.
nsCOMPtr<nsIScriptGlobalObjectOwner>
theGlobalObjectOwner(do_GetInterface(iWebBrowser));
if (theGlobalObjectOwner) {
nsIScriptGlobalObject *theGlobalObject =
theGlobalObjectOwner->GetScriptGlobalObject();
nsIScriptContext *theScriptContext = theGlobalObject->GetContext();
JSObject *theGlobalJSObject = theGlobalObject->GetGlobalJSObject();
JSContext *theJSContext = (JSContext
*)theScriptContext->GetNativeContext();
// Register our C++ class
JSObject *newObj = JS_InitClass(theJSContext, theGlobalJSObject,
NULL, &JSTT::TTClass, JSTT::JSConstructor, 0, JSTT::tt_properties,
NULL, JSTT::tt_properties, NULL);
// Create the object. The JavaScript GC should destroy this when out
of scope.
JS_DefineObject(theJSContext, theGlobalJSObject, "ttds",
&JSTT::TTClass, NULL, JSPROP_READONLY | JSPROP_ENUMERATE |
JSPROP_EXPORTED);
}
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding