1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/basic/testInt32ToId.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +function testInt32ToId() 1.5 +{ 1.6 + // Ensure that a property which is a negative integer that does not fit in a 1.7 + // jsval is properly detected by the 'in' operator. 1.8 + var obj = { "-1073741828": 17 }; 1.9 + var index = -1073741819; 1.10 + var a = []; 1.11 + for (var i = 0; i < 10; i++) 1.12 + { 1.13 + a.push(index in obj); 1.14 + index--; 1.15 + } 1.16 + 1.17 + // Ensure that a property which is a negative integer that does not fit in a 1.18 + // jsval is properly *not* detected by the 'in' operator. In this case 1.19 + // wrongly applying INT_TO_JSID to -2147483648 will shift off the sign bit 1.20 + // (the only bit set in that number) and bitwise-or that value with 1, 1.21 + // producing jsid(1) -- which actually represents "0", not "-2147483648". 1.22 + // Thus 'in' will report a "-2147483648" property when none exists, because 1.23 + // it thinks the request was really whether the object had property "0". 1.24 + var obj2 = { 0: 17 }; 1.25 + var b = []; 1.26 + var index = -(1 << 28); 1.27 + for (var i = 0; i < 10; i++) 1.28 + { 1.29 + b.push(index in obj2); 1.30 + index = index - (1 << 28); 1.31 + } 1.32 + 1.33 + return a.join(",") + b.join(","); 1.34 +} 1.35 + 1.36 +assertEq(testInt32ToId(), 1.37 + "false,false,false,false,false,false,false,false,false,true" + 1.38 + "false,false,false,false,false,false,false,false,false,false");