Bug 478433 - Use a better method to create this function. r+sr=jst

This commit is contained in:
Blake Kaplan 2009-02-25 17:33:54 -08:00
Родитель 2936afe95f
Коммит 69aa2d6536
1 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -645,8 +645,20 @@ XPC_NW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
if (id == GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING)) {
*objp = obj;
return JS_DefineFunction(cx, obj, "toString",
XPC_NW_toString, 0, 0) != nsnull;
// See the comment in XPC_NW_WrapFunction for why we create this function
// like this.
JSFunction *fun = JS_NewFunction(cx, XPC_NW_toString, 0, 0, nsnull,
"toString");
if (!fun) {
return JS_FALSE;
}
JSObject *funobj = JS_GetFunctionObject(fun);
STOBJ_SET_PARENT(funobj, obj);
return JS_DefineProperty(cx, obj, "toString", OBJECT_TO_JSVAL(funobj),
nsnull, nsnull, 0);
}
if (!EnsureLegalActivity(cx, obj)) {