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

Unified Diff: test/mjsunit/harmony/collections.js

Issue 9074003: Fix handling of bogus receivers for Harmony collections. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 12 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
« no previous file with comments | « src/macros.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/collections.js
diff --git a/test/mjsunit/harmony/collections.js b/test/mjsunit/harmony/collections.js
index 4b435c16141b01c50bb3ca7233b053261d9ef919..52df11f97445a889bc58da658ac112bf33b4bad2 100644
--- a/test/mjsunit/harmony/collections.js
+++ b/test/mjsunit/harmony/collections.js
@@ -274,6 +274,30 @@ var o = Object.create({}, { myValue: {
assertEquals(10, o.myValue);
+// Regression test for issue 1884: Invoking any of the methods for Harmony
+// maps, sets, or weak maps, with a wrong type of receiver should be throwing
+// a proper TypeError.
+function TestBogusReceivers(func) {
+ assertThrows(function () { func.call(undefined, {}) }, TypeError);
+ assertThrows(function () { func.call(null, {}) }, TypeError);
+ assertThrows(function () { func.call(true, {}) }, TypeError);
+ assertThrows(function () { func.call("x", {}) }, TypeError);
+ assertThrows(function () { func.call(23, {}) }, TypeError);
+ assertThrows(function () { func.call({}, {}) }, TypeError);
rossberg 2012/01/04 10:07:00 Particularly interesting cases would be variations
Michael Starzinger 2012/01/05 10:40:09 Done. I generalized the regression test a bit.
+}
+TestBogusReceivers(Set.prototype.add);
+TestBogusReceivers(Set.prototype.has);
+TestBogusReceivers(Set.prototype.delete);
+TestBogusReceivers(Map.prototype.get);
+TestBogusReceivers(Map.prototype.set);
+TestBogusReceivers(Map.prototype.has);
+TestBogusReceivers(Map.prototype.delete);
+TestBogusReceivers(WeakMap.prototype.get);
+TestBogusReceivers(WeakMap.prototype.set);
+TestBogusReceivers(WeakMap.prototype.has);
+TestBogusReceivers(WeakMap.prototype.delete);
+
+
// Stress Test
// There is a proposed stress-test available at the es-discuss mailing list
// which cannot be reasonably automated. Check it out by hand if you like:
« no previous file with comments | « src/macros.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698