array-push-frozen-array.js (407B)
1 function maybeFreeze(arr, b) { 2 with(this) {}; // Don't inline this. 3 if (b) { 4 Object.freeze(arr); 5 } 6 } 7 function test() { 8 var arr = []; 9 for (var i = 0; i < 1800; i++) { 10 maybeFreeze(arr, i > 1500); 11 try { 12 arr.push(2); 13 assertEq(i <= 1500, true); 14 } catch(e) { 15 assertEq(e instanceof TypeError, true); 16 } 17 } 18 } 19 test();