Bug 968866 -- Freeze user-visible offset/type vectors r=till

This commit is contained in:
Nicholas D. Matsakis 2014-02-06 11:32:58 -05:00
parent f8b4143e01
commit 8961875e86
2 changed files with 10 additions and 0 deletions

View File

@ -911,6 +911,12 @@ StructMetaTypeDescr::layout(JSContext *cx,
return false;
}
if (!JSObject::freeze(cx, fieldOffsets))
return false;
if (!JSObject::freeze(cx, fieldTypes))
return false;
RootedValue fieldOffsetsValue(cx, ObjectValue(*fieldOffsets));
if (!JSObject::defineProperty(cx, structType, cx->names().fieldOffsets,
fieldOffsetsValue, nullptr, nullptr,

View File

@ -36,6 +36,10 @@ function runTests() {
assertEq(S.fieldOffsets.y, 4);
assertEq(S.fieldOffsets.z, 8);
// fieldTypes and fieldOffsets should be frozen
assertEq(Object.isFrozen(S.fieldTypes), true);
assertEq(Object.isFrozen(S.fieldOffsets), true);
if (typeof reportCompare === "function")
reportCompare(true, true);
print("Tests complete");