fix global handling

This commit is contained in:
Vincent Sanders 2012-07-31 14:48:53 +01:00
parent d763e57d30
commit c0aaf31f5a
3 changed files with 14 additions and 3 deletions

View File

@ -79,7 +79,6 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
if (global == NULL) {
return NULL;
}
JS_SetGlobalObject(cx, global);
return global;
}

View File

@ -92,8 +92,10 @@ JSObject *jsapi_new_document(JSContext *cx, JSObject *parent, void *doc_priv)
LOG(("setting content to %p",doc_priv));
/* private pointer to browsing context */
if (!JS_SetPrivate(cx, doc, doc_priv))
if (JS_SetPrivate(cx, doc, doc_priv) != JS_TRUE) {
LOG(("failed to set content"));
return NULL;
}
return doc;
}

View File

@ -299,8 +299,18 @@ JSObject * jsapi_new_window(JSContext *cx, JSObject *parent, void *win_priv)
return NULL;
}
/** @todo reconsider global object handling. future
* editions of spidermonkey appear to be removing the
* idea of a global so we probably need to handle
* global object references internally
*/
/* set the contexts global */
JS_SetGlobalObject(cx, window);
/* Populate the global object with the standard globals, like
Object and Array. */
* Object and Array.
*/
if (!JS_InitStandardClasses(cx, window)) {
return NULL;
}