зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 822901f56c1f (bug 1170216)
--HG-- extra : rebase_source : fcde858b7a057af0a53b9e4e00bea770a38bc3a1
This commit is contained in:
Родитель
247c97380b
Коммит
2d907f3406
|
@ -548,19 +548,6 @@ js::SetIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level)
|
|||
|
||||
MOZ_ASSERT(nobj->lastProperty()->slotSpan() == last->slotSpan());
|
||||
JS_ALWAYS_TRUE(nobj->setLastProperty(cx, last));
|
||||
|
||||
// Ordinarily ArraySetLength handles this, but we're going behind its back
|
||||
// right now, so we must do this manually.
|
||||
//
|
||||
// ArraySetLength also implements the capacity <= length invariant for
|
||||
// arrays with non-writable length. We don't need to do anything special
|
||||
// for that, because capacity was zeroed out by preventExtensions. (See
|
||||
// the assertion about getDenseCapacity above.)
|
||||
if (level == IntegrityLevel::Frozen && obj->is<ArrayObject>()) {
|
||||
if (!obj->as<ArrayObject>().maybeCopyElementsForWrite(cx))
|
||||
return false;
|
||||
obj->as<ArrayObject>().getElementsHeader()->setNonwritableArrayLength();
|
||||
}
|
||||
} else {
|
||||
RootedId id(cx);
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
|
@ -599,6 +586,21 @@ js::SetIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level)
|
|||
}
|
||||
}
|
||||
|
||||
// Ordinarily ArraySetLength handles this, but we're going behind its back
|
||||
// right now, so we must do this manually. Neither the custom property
|
||||
// tree mutations nor the DefineProperty call in the above code will do
|
||||
// this for us.
|
||||
//
|
||||
// ArraySetLength also implements the capacity <= length invariant for
|
||||
// arrays with non-writable length. We don't need to do anything special
|
||||
// for that, because capacity was zeroed out by preventExtensions. (See
|
||||
// the assertion before the if-else above.)
|
||||
if (level == IntegrityLevel::Frozen && obj->is<ArrayObject>()) {
|
||||
if (!obj->as<ArrayObject>().maybeCopyElementsForWrite(cx))
|
||||
return false;
|
||||
obj->as<ArrayObject>().getElementsHeader()->setNonwritableArrayLength();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче