Use the currently active scope to find the prototype. bug 408639, r=jst sr=brendan

This commit is contained in:
mrbkap@gmail.com 2008-01-04 17:25:35 -08:00
parent c68b8f41c1
commit e458b8b61d

View File

@ -485,14 +485,18 @@ XPC_XOW_WrapObject(JSContext *cx, JSObject *parent, jsval *vp)
return JS_TRUE;
}
outerObj = JS_NewObject(cx, &sXPC_XOW_JSClass.base, nsnull, parent);
// FIXME: bug 408871, Note that we create outerObj with a null parent
// here. We set it later so that we find our nominal prototype in the
// same scope as the one that is calling us.
outerObj = JS_NewObject(cx, &sXPC_XOW_JSClass.base, nsnull, nsnull);
if (!outerObj) {
return JS_FALSE;
}
// Sever the prototype link from Object.prototype so we don't
// accidentally inherit properties like __proto__ and __parent__.
if (!JS_SetPrototype(cx, outerObj, nsnull)) {
if (!JS_SetParent(cx, outerObj, parent) ||
!JS_SetPrototype(cx, outerObj, nsnull)) {
return JS_FALSE;
}