From a6419e3e47072d35b5a2e2d07c29cc2ab2f49e55 Mon Sep 17 00:00:00 2001 From: "dslomov@chromium.org" Date: Mon, 15 Jul 2013 07:43:46 +0000 Subject: [PATCH] This does not match ES6 spec but is the behavior in both Firefox and WebKit/Blink. R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/19086003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15655 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/typedarray.js | 2 +- test/mjsunit/external-array-no-sse2.js | 6 ++++-- test/mjsunit/external-array.js | 6 ++++-- test/mjsunit/harmony/typedarrays.js | 11 +++++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/typedarray.js b/src/typedarray.js index 891b4d7..ee1fa9d 100644 --- a/src/typedarray.js +++ b/src/typedarray.js @@ -154,7 +154,7 @@ function TypedArraySet(obj, offset) { var l = obj.length; if (IS_UNDEFINED(l)) { - throw MakeTypeError("invalid_argument"); + return; } if (intOffset + l > this.length) { throw MakeRangeError("typed_array_set_source_too_large"); diff --git a/test/mjsunit/external-array-no-sse2.js b/test/mjsunit/external-array-no-sse2.js index cffcab8..9a008fb 100644 --- a/test/mjsunit/external-array-no-sse2.js +++ b/test/mjsunit/external-array-no-sse2.js @@ -606,8 +606,10 @@ a61.set(a62) assertArrayPrefix([1, 12], a61) // Invalid source -assertThrows(function() { a.set(0) }) -assertThrows(function() { a.set({}) }) +a.set(0); // does not throw +assertArrayPrefix([1,2,3,4,5,6], a); +a.set({}); // does not throw +assertArrayPrefix([1,2,3,4,5,6], a); // Test arraybuffer.slice diff --git a/test/mjsunit/external-array.js b/test/mjsunit/external-array.js index deb3c86..81788d4 100644 --- a/test/mjsunit/external-array.js +++ b/test/mjsunit/external-array.js @@ -605,8 +605,10 @@ a61.set(a62) assertArrayPrefix([1, 12], a61) // Invalid source -assertThrows(function() { a.set(0) }) -assertThrows(function() { a.set({}) }) +a.set(0); // does not throw +assertArrayPrefix([1,2,3,4,5,6], a); +a.set({}); // does not throw +assertArrayPrefix([1,2,3,4,5,6], a); // Test arraybuffer.slice diff --git a/test/mjsunit/harmony/typedarrays.js b/test/mjsunit/harmony/typedarrays.js index 99364c8..8e8ec57 100644 --- a/test/mjsunit/harmony/typedarrays.js +++ b/test/mjsunit/harmony/typedarrays.js @@ -453,8 +453,15 @@ function TestTypedArraySet() { // Invalid source var a = new Uint16Array(50); - assertThrows(function() { a.set(0) }, TypeError); - assertThrows(function() { a.set({}) }, TypeError); + var expected = []; + for (i = 0; i < 50; i++) { + a[i] = i; + expected.push(i); + } + a.set(0); + assertArrayPrefix(expected, a); + a.set({}); + assertArrayPrefix(expected, a); assertThrows(function() { a.set.call({}) }, TypeError); assertThrows(function() { a.set.call([]) }, TypeError); } -- 2.7.4