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 1be87bc295
commit 8f90f4e630
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");