Chromium Code Reviews| 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: |