Bug 858101 - Run the DefaultValue algorithm directly on the wrapper for Xrays. r=mrbkap

This commit is contained in:
Bobby Holley 2013-05-31 10:36:01 -07:00
parent 9755fce1d6
commit c72d0f8113
5 changed files with 24 additions and 5 deletions

View File

@ -1717,6 +1717,11 @@ SetObjectMetadata(JSContext *cx, JSHandleObject obj, JSHandleObject metadata);
JS_FRIEND_API(JSObject *)
GetObjectMetadata(JSObject *obj);
/* ES5 8.12.8. */
extern JS_FRIEND_API(JSBool)
DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp);
} /* namespace js */
extern JS_FRIEND_API(JSBool)

View File

@ -4609,7 +4609,7 @@ MaybeCallMethod(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue
return Invoke(cx, ObjectValue(*obj), vp, 0, NULL, vp.address());
}
JSBool
JS_FRIEND_API(JSBool)
js::DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp)
{
JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);

View File

@ -203,10 +203,6 @@ DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, JSBool *succeeded);
} /* namespace js::baseops */
/* ES5 8.12.8. */
extern JSBool
DefaultValue(JSContext *cx, HandleObject obj, JSType hint, MutableHandleValue vp);
extern Class ArrayClass;
extern Class ArrayBufferClass;
extern Class BlockClass;

View File

@ -1885,6 +1885,20 @@ XrayWrapper<Base, Traits>::construct(JSContext *cx, HandleObject wrapper, const
return Traits::construct(cx, wrapper, args, Base::singleton);
}
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::defaultValue(JSContext *cx, HandleObject wrapper,
JSType hint, MutableHandleValue vp)
{
// Even if this isn't a security wrapper, Xray semantics dictate that we
// run the DefaultValue algorithm directly on the Xray wrapper.
//
// NB: We don't have to worry about things with special [[DefaultValue]]
// behavior like Date because we'll never have an XrayWrapper to them.
return js::DefaultValue(cx, wrapper, hint, vp);
}
/*
* The Permissive / Security variants should be used depending on whether the
* compartment of the wrapper is guranteed to subsume the compartment of the

View File

@ -103,6 +103,10 @@ class XrayWrapper : public Base {
virtual bool construct(JSContext *cx, JS::Handle<JSObject*> wrapper,
const JS::CallArgs &args) MOZ_OVERRIDE;
virtual bool defaultValue(JSContext *cx, JS::HandleObject wrapper,
JSType hint, JS::MutableHandleValue vp)
MOZ_OVERRIDE;
static XrayWrapper singleton;
private: