1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/basic/splice-fail-step-16.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,25 @@ 1.4 +/* Test that arrays resize normally during splice, even if .length is non-writable. */ 1.5 + 1.6 +var arr = [1, 2, 3, 4, 5, 6]; 1.7 + 1.8 +Object.defineProperty(arr, "length", {writable: false}); 1.9 + 1.10 +try 1.11 +{ 1.12 + var removed = arr.splice(3, 3, 9, 9, 9, 9); 1.13 + throw new Error("splice didn't throw, returned [" + removed + "]"); 1.14 +} 1.15 +catch (e) 1.16 +{ 1.17 + assertEq(e instanceof TypeError, true, 1.18 + "should have thrown a TypeError, instead threw " + e + ", arr is " + arr); 1.19 +} 1.20 + 1.21 +// The exception should happen in step 16, which means we've already removed the array elements. 1.22 +assertEq(arr[0], 1); 1.23 +assertEq(arr[1], 2); 1.24 +assertEq(arr[2], 3); 1.25 +assertEq(arr[3], 9); 1.26 +assertEq(arr[4], 9); 1.27 +assertEq(arr[5], 9); 1.28 +assertEq(arr.length, 6);