michael@0: function testInt32ToId() michael@0: { michael@0: // Ensure that a property which is a negative integer that does not fit in a michael@0: // jsval is properly detected by the 'in' operator. michael@0: var obj = { "-1073741828": 17 }; michael@0: var index = -1073741819; michael@0: var a = []; michael@0: for (var i = 0; i < 10; i++) michael@0: { michael@0: a.push(index in obj); michael@0: index--; michael@0: } michael@0: michael@0: // Ensure that a property which is a negative integer that does not fit in a michael@0: // jsval is properly *not* detected by the 'in' operator. In this case michael@0: // wrongly applying INT_TO_JSID to -2147483648 will shift off the sign bit michael@0: // (the only bit set in that number) and bitwise-or that value with 1, michael@0: // producing jsid(1) -- which actually represents "0", not "-2147483648". michael@0: // Thus 'in' will report a "-2147483648" property when none exists, because michael@0: // it thinks the request was really whether the object had property "0". michael@0: var obj2 = { 0: 17 }; michael@0: var b = []; michael@0: var index = -(1 << 28); michael@0: for (var i = 0; i < 10; i++) michael@0: { michael@0: b.push(index in obj2); michael@0: index = index - (1 << 28); michael@0: } michael@0: michael@0: return a.join(",") + b.join(","); michael@0: } michael@0: michael@0: assertEq(testInt32ToId(), michael@0: "false,false,false,false,false,false,false,false,false,true" + michael@0: "false,false,false,false,false,false,false,false,false,false");