This does not match ES6 spec but is the behavior in both Firefox and WebKit/Blink.
authordslomov@chromium.org <dslomov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 15 Jul 2013 07:43:46 +0000 (07:43 +0000)
committerdslomov@chromium.org <dslomov@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 15 Jul 2013 07:43:46 +0000 (07:43 +0000)
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
test/mjsunit/external-array-no-sse2.js
test/mjsunit/external-array.js
test/mjsunit/harmony/typedarrays.js

index 891b4d7..ee1fa9d 100644 (file)
@@ -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");
index cffcab8..9a008fb 100644 (file)
@@ -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
index deb3c86..81788d4 100644 (file)
@@ -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
index 99364c8..8e8ec57 100644 (file)
@@ -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);
 }