mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 12:15:33 +00:00
Bug 1105518: Remove JSPROP_REDEFINE_NONCONFIGURABLE from jsapi. r=jorendorff
This commit is contained in:
parent
cbd7017dfb
commit
77fbd62447
@ -495,13 +495,6 @@ static const unsigned JSFUN_CONSTRUCTOR = 0x400;
|
||||
/* | of all the JSFUN_* flags */
|
||||
static const unsigned JSFUN_FLAGS_MASK = 0x400;
|
||||
|
||||
/*
|
||||
* If set, will allow redefining a non-configurable property, but only on a
|
||||
* non-DOM global. This is a temporary hack that will need to go away in bug
|
||||
* 1105518.
|
||||
*/
|
||||
static const unsigned JSPROP_REDEFINE_NONCONFIGURABLE = 0x1000;
|
||||
|
||||
/*
|
||||
* Resolve hooks and enumerate hooks must pass this flag when calling
|
||||
* JS_Define* APIs to reify lazily-defined properties.
|
||||
@ -2112,7 +2105,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
|
||||
JSPROP_IGNORE_VALUE |
|
||||
JSPROP_GETTER |
|
||||
JSPROP_SETTER |
|
||||
JSPROP_REDEFINE_NONCONFIGURABLE |
|
||||
JSPROP_RESOLVING |
|
||||
SHADOWABLE)) == 0);
|
||||
MOZ_ASSERT(!hasAll(JSPROP_IGNORE_ENUMERATE | JSPROP_ENUMERATE));
|
||||
@ -2134,7 +2126,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_PERMANENT));
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_READONLY));
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_VALUE));
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_REDEFINE_NONCONFIGURABLE));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2146,7 +2137,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
|
||||
JSPROP_READONLY |
|
||||
JSPROP_GETTER |
|
||||
JSPROP_SETTER |
|
||||
JSPROP_REDEFINE_NONCONFIGURABLE |
|
||||
JSPROP_RESOLVING |
|
||||
SHADOWABLE)) == 0);
|
||||
MOZ_ASSERT_IF(isAccessorDescriptor(), has(JSPROP_GETTER) && has(JSPROP_SETTER));
|
||||
|
@ -1707,18 +1707,8 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
||||
return result.succeed();
|
||||
}
|
||||
|
||||
// Non-standard hack: Allow redefining non-configurable properties if
|
||||
// JSPROP_REDEFINE_NONCONFIGURABLE is set _and_ the object is a non-DOM
|
||||
// global. The idea is that a DOM object can never have such a thing on
|
||||
// its proto chain directly on the web, so we should be OK optimizing
|
||||
// access to accessors found on such an object. Bug 1105518 contemplates
|
||||
// removing this hack.
|
||||
bool skipRedefineChecks = (desc.attributes() & JSPROP_REDEFINE_NONCONFIGURABLE) &&
|
||||
obj->is<GlobalObject>() &&
|
||||
!obj->getClass()->isDOMClass();
|
||||
|
||||
// Step 4.
|
||||
if (!IsConfigurable(shapeAttrs) && !skipRedefineChecks) {
|
||||
if (!IsConfigurable(shapeAttrs)) {
|
||||
if (desc.hasConfigurable() && desc.configurable())
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
if (desc.hasEnumerable() && desc.enumerable() != IsEnumerable(shapeAttrs))
|
||||
@ -1753,7 +1743,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
||||
}
|
||||
} else if (desc.isDataDescriptor() != IsDataDescriptor(shapeAttrs)) {
|
||||
// Step 6.
|
||||
if (!IsConfigurable(shapeAttrs) && !skipRedefineChecks)
|
||||
if (!IsConfigurable(shapeAttrs))
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
|
||||
// Fill in desc fields with default values (steps 6.b.i and 6.c.i).
|
||||
@ -1763,7 +1753,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
||||
bool frozen = !IsConfigurable(shapeAttrs) && !IsWritable(shapeAttrs);
|
||||
|
||||
// Step 7.a.i.1.
|
||||
if (frozen && desc.hasWritable() && desc.writable() && !skipRedefineChecks)
|
||||
if (frozen && desc.hasWritable() && desc.writable())
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
|
||||
if (frozen || !desc.hasValue()) {
|
||||
@ -1780,13 +1770,13 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
||||
MOZ_ASSERT(!cx->helperThread());
|
||||
if (!SameValue(cx, desc.value(), currentValue, &same))
|
||||
return false;
|
||||
if (!same && !skipRedefineChecks)
|
||||
if (!same)
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 7.a.i.3.
|
||||
if (frozen && !skipRedefineChecks)
|
||||
if (frozen)
|
||||
return result.succeed();
|
||||
|
||||
// Fill in desc.[[Writable]].
|
||||
@ -1802,8 +1792,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
||||
if (desc.hasSetterObject()) {
|
||||
// Step 8.a.i.
|
||||
if (!IsConfigurable(shapeAttrs) &&
|
||||
desc.setterObject() != prop.shape()->setterObject() &&
|
||||
!skipRedefineChecks)
|
||||
desc.setterObject() != prop.shape()->setterObject())
|
||||
{
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
@ -1814,8 +1803,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
||||
if (desc.hasGetterObject()) {
|
||||
// Step 8.a.ii.
|
||||
if (!IsConfigurable(shapeAttrs) &&
|
||||
desc.getterObject() != prop.shape()->getterObject() &&
|
||||
!skipRedefineChecks)
|
||||
desc.getterObject() != prop.shape()->getterObject())
|
||||
{
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user