From 87e401ef61d0de61d13fb1b7c0faeb2516a9b9d3 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Sat, 29 Dec 2007 20:36:37 -0800 Subject: [PATCH] Preserve interesting attributes on same-origin XOWs. bug 393267, r+sr=jst a=beltzner --- js/src/xpconnect/src/XPCWrapper.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/js/src/xpconnect/src/XPCWrapper.cpp b/js/src/xpconnect/src/XPCWrapper.cpp index c219c77ba409..d2660d587c55 100644 --- a/js/src/xpconnect/src/XPCWrapper.cpp +++ b/js/src/xpconnect/src/XPCWrapper.cpp @@ -295,9 +295,19 @@ XPCWrapper::NewResolve(JSContext *cx, JSObject *wrapperObj, JSBool isXOW = (JS_GET_CLASS(cx, wrapperObj) == &sXPC_XOW_JSClass.base); uintN attrs = JSPROP_ENUMERATE; - if (OBJ_IS_NATIVE(innerObjp)) { + JSPropertyOp getter = nsnull; + JSPropertyOp setter = nsnull; + if (isXOW && OBJ_IS_NATIVE(innerObjp)) { JSScopeProperty *sprop = reinterpret_cast(prop); + attrs = sprop->attrs; + if (attrs & JSPROP_GETTER) { + getter = sprop->getter; + } + if (attrs & JSPROP_SETTER) { + setter = sprop->setter; + } + if ((preserveVal || isXOW) && SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(innerObjp))) { v = OBJ_GET_SLOT(cx, innerObjp, sprop->slot); @@ -326,8 +336,16 @@ XPCWrapper::NewResolve(JSContext *cx, JSObject *wrapperObj, return JS_FALSE; } - JSBool ok = OBJ_DEFINE_PROPERTY(cx, wrapperObj, interned_id, v, nsnull, - nsnull, (attrs & JSPROP_ENUMERATE), nsnull); + const uintN interesting_attrs = isXOW + ? (JSPROP_ENUMERATE | + JSPROP_READONLY | + JSPROP_PERMANENT | + JSPROP_SHARED | + JSPROP_GETTER | + JSPROP_SETTER) + : JSPROP_ENUMERATE; + JSBool ok = OBJ_DEFINE_PROPERTY(cx, wrapperObj, interned_id, v, getter, + setter, (attrs & interesting_attrs), nsnull); if (ok && (ok = ::JS_SetReservedSlot(cx, wrapperObj, sResolvingSlot, oldSlotVal))) {