зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1107443 part 3. Stop defining non-configurable properties on the window in xpconnect sandbox code. r=peterv,jorendorff
This commit is contained in:
Родитель
cbb271e250
Коммит
3c92a4bdd7
|
@ -224,10 +224,19 @@ JS_CopyPropertiesFrom(JSContext *cx, JS::HandleObject target, JS::HandleObject o
|
||||||
* property of the given name exists on |obj|.
|
* property of the given name exists on |obj|.
|
||||||
*
|
*
|
||||||
* On entry, |cx| must be same-compartment with |obj|.
|
* On entry, |cx| must be same-compartment with |obj|.
|
||||||
|
*
|
||||||
|
* The copyBehavior argument controls what happens with
|
||||||
|
* non-configurable properties.
|
||||||
*/
|
*/
|
||||||
|
typedef enum {
|
||||||
|
MakeNonConfigurableIntoConfigurable,
|
||||||
|
CopyNonConfigurableAsIs
|
||||||
|
} PropertyCopyBehavior;
|
||||||
|
|
||||||
extern JS_FRIEND_API(bool)
|
extern JS_FRIEND_API(bool)
|
||||||
JS_CopyPropertyFrom(JSContext *cx, JS::HandleId id, JS::HandleObject target,
|
JS_CopyPropertyFrom(JSContext *cx, JS::HandleId id, JS::HandleObject target,
|
||||||
JS::HandleObject obj);
|
JS::HandleObject obj,
|
||||||
|
PropertyCopyBehavior copyBehavior = CopyNonConfigurableAsIs);
|
||||||
|
|
||||||
extern JS_FRIEND_API(bool)
|
extern JS_FRIEND_API(bool)
|
||||||
JS_WrapPropertyDescriptor(JSContext *cx, JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS_WrapPropertyDescriptor(JSContext *cx, JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
|
|
|
@ -1639,7 +1639,8 @@ JSObject::nonNativeSetElement(JSContext *cx, HandleObject obj, HandleObject rece
|
||||||
|
|
||||||
JS_FRIEND_API(bool)
|
JS_FRIEND_API(bool)
|
||||||
JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target,
|
JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target,
|
||||||
HandleObject obj)
|
HandleObject obj,
|
||||||
|
PropertyCopyBehavior copyBehavior)
|
||||||
{
|
{
|
||||||
// |obj| and |cx| are generally not same-compartment with |target| here.
|
// |obj| and |cx| are generally not same-compartment with |target| here.
|
||||||
assertSameCompartment(cx, obj, id);
|
assertSameCompartment(cx, obj, id);
|
||||||
|
@ -1655,6 +1656,11 @@ JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target,
|
||||||
if (desc.setter() && !desc.hasSetterObject())
|
if (desc.setter() && !desc.hasSetterObject())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (copyBehavior == MakeNonConfigurableIntoConfigurable) {
|
||||||
|
// Mask off the JSPROP_PERMANENT bit.
|
||||||
|
desc.attributesRef() &= ~JSPROP_PERMANENT;
|
||||||
|
}
|
||||||
|
|
||||||
JSAutoCompartment ac(cx, target);
|
JSAutoCompartment ac(cx, target);
|
||||||
RootedId wrappedId(cx, id);
|
RootedId wrappedId(cx, id);
|
||||||
if (!cx->compartment()->wrap(cx, &desc))
|
if (!cx->compartment()->wrap(cx, &desc))
|
||||||
|
|
|
@ -454,7 +454,8 @@ sandbox_addProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleV
|
||||||
if (!JS_SetPropertyById(cx, proto, id, vp))
|
if (!JS_SetPropertyById(cx, proto, id, vp))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!JS_CopyPropertyFrom(cx, id, unwrappedProto, obj))
|
if (!JS_CopyPropertyFrom(cx, id, unwrappedProto, obj,
|
||||||
|
MakeNonConfigurableIntoConfigurable))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче