Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1835)

Unified Diff: test/mjsunit/harmony/array-of.js

Issue 1181623003: In Array.of and Array.from, fall back to DefineOwnProperty (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« test/mjsunit/harmony/array-from.js ('K') | « test/mjsunit/harmony/array-from.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/array-of.js
diff --git a/test/mjsunit/harmony/array-of.js b/test/mjsunit/harmony/array-of.js
index adf7cb547cdae9eebd9fdec14f01c8d562526e65..a0fe1beb740f9d88037f61f23b404da966484dd3 100644
--- a/test/mjsunit/harmony/array-of.js
+++ b/test/mjsunit/harmony/array-of.js
@@ -182,3 +182,24 @@ assertThrows(function() { new Array.of() }, TypeError); // not a constructor
assertEquals(instance instanceof boundFn, true);
assertEquals(Array.isArray(instance), false);
})();
+
+// Assert that [[DefineOwnProperty]] is used in ArrayFrom, meaning a
+// setter isn't called, and a failed [[DefineOwnProperty]] will throw.
+(function testDefinesOwnProperty() {
+ var setterCalled = 0;
+ function exotic() {
+ Object.defineProperty(this, '0', {
+ get: function() { return 2; },
+ set: function() { setterCalled++; }
+ });
+ }
+ // Check that exotic was defined right
+ var instance = new exotic();
+ assertEquals(2, instance[0]);
+ instance[0] = 1;
+ assertEquals(2, instance[0]);
+ assertEquals(1, setterCalled);
+ // Accessor properties can't be overwritten with DefineOwnProperty
+ assertThrows(function () { Array.of.call(exotic, 1); }, TypeError);
+ assertEquals(1, setterCalled);
+})();
« test/mjsunit/harmony/array-from.js ('K') | « test/mjsunit/harmony/array-from.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698