if (!JS_InitStandardClasses(cx, mScriptObject)) return NS_ERROR_FAILURE; }
nsXULPrototypeDocument::GetScriptObject(nsIScriptContext *aContext, void **aObject){    // The prototype document will have its own special secret script    // object that can be used to compile scripts and event handlers.    if (!mScriptObject) {        JSContext *cx = (JSContext *)aContext->GetNativeContext();        if (!cx)            return NS_ERROR_UNEXPECTED;        mScriptObject = JS_NewObject(cx, &null_class, nsnull, nsnull);        if (!mScriptObject)            return NS_ERROR_OUT_OF_MEMORY;        // Be sure to unlink the script object from the parent global        // object. This ensures that we don't end up with a circular        // reference back to the first document.        JS_SetPrototype(cx, mScriptObject, nsnull);        JS_SetParent(cx, mScriptObject, nsnull);        JS_AddNamedRoot(cx, &mScriptObject, "nsXULPrototypeDocument::mScriptObject");        // We need standard classes, in particular RegExp, to compile JS.        if (!JS_InitStandardClasses(cx, mScriptObject))            return NS_ERROR_FAILURE;    }    *aObject = mScriptObject;    return NS_OK;}