Bug 1148568 - In JSON.parse with a reviver callback, ignore failure when defining properties. r=Waldo.

Switch to StandardDefineProperty while we're at it. I don't think the "CreateDataProperty" operation given in the spec is quite worth making into a function on its own, since the standard almost exclusively uses it in cases where it "can't fail", and (a) that is unpossible for us; (b) this is not one of those cases anyway.

--HG--
extra : rebase_source : f224305107a7881b6dfd312419808e0211d2f6f3
This commit is contained in:
Jason Orendorff 2015-03-23 14:32:30 -05:00
parent 24fcf2a236
commit 43939414b8

View File

@ -710,16 +710,16 @@ Walk(JSContext* cx, HandleObject holder, HandleId name, HandleValue reviver, Mut
if (!Walk(cx, obj, id, reviver, &newElement))
return false;
ObjectOpResult ignored;
if (newElement.isUndefined()) {
/* Step 2a(iii)(2). */
ObjectOpResult ignored;
/* Step 2a(iii)(2). The spec deliberately ignores strict failure. */
if (!DeleteProperty(cx, obj, id, ignored))
return false;
} else {
/* Step 2a(iii)(3). */
// XXX This definition should ignore success/failure, when
// our property-definition APIs indicate that.
if (!DefineProperty(cx, obj, id, newElement))
/* Step 2a(iii)(3). The spec deliberately ignores strict failure. */
Rooted<PropertyDescriptor> desc(cx);
desc.setDataDescriptor(newElement, JSPROP_ENUMERATE);
if (!StandardDefineProperty(cx, obj, id, desc, ignored))
return false;
}
}
@ -738,16 +738,16 @@ Walk(JSContext* cx, HandleObject holder, HandleId name, HandleValue reviver, Mut
if (!Walk(cx, obj, id, reviver, &newElement))
return false;
ObjectOpResult ignored;
if (newElement.isUndefined()) {
/* Step 2b(ii)(2). */
ObjectOpResult ignored;
/* Step 2b(ii)(2). The spec deliberately ignores strict failure. */
if (!DeleteProperty(cx, obj, id, ignored))
return false;
} else {
/* Step 2b(ii)(3). */
// XXX This definition should ignore success/failure, when
// our property-definition APIs indicate that.
if (!DefineProperty(cx, obj, id, newElement))
/* Step 2b(ii)(3). The spec deliberately ignores strict failure. */
Rooted<PropertyDescriptor> desc(cx);
desc.setDataDescriptor(newElement, JSPROP_ENUMERATE);
if (!StandardDefineProperty(cx, obj, id, desc, ignored))
return false;
}
}