Chromium Code Reviews| Index: test/mjsunit/regress/regress-1973.js |
| diff --git a/test/mjsunit/getter-in-value-prototype.js b/test/mjsunit/regress/regress-1973.js |
| similarity index 58% |
| copy from test/mjsunit/getter-in-value-prototype.js |
| copy to test/mjsunit/regress/regress-1973.js |
| index b55320ac5b9ea8f30c820f15fd572772f25363b5..14d1c1e2ad31b1885510081ed2451481cb47f248 100644 |
| --- a/test/mjsunit/getter-in-value-prototype.js |
| +++ b/test/mjsunit/regress/regress-1973.js |
| @@ -1,4 +1,4 @@ |
| -// Copyright 2008 the V8 project authors. All rights reserved. |
| +// Copyright 2012 the V8 project authors. All rights reserved. |
| // Redistribution and use in source and binary forms, with or without |
| // modification, are permitted provided that the following conditions are |
| // met: |
| @@ -25,11 +25,27 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// Test that getters can be defined and called on value prototypes. |
| -// |
| -// This used to fail because of an invalid cast of the receiver to a |
| -// JSObject. |
| +// Test that getters and setters pass unwrapped this values in strict mode |
| +// and wrapped this values is non-strict mode. |
| -String.prototype.__defineGetter__('x', function() { return this; }); |
| -assertEquals('asdf', 'asdf'.x); |
| +function TestAccessorWrapping(prototype, primitive) { |
|
rossberg
2012/03/14 17:34:52
Instead of passing prototype separately, you could
|
| + // Check that strict mode passes unwrapped this value. |
| + var strict_type = typeof primitive; |
| + Object.defineProperty(prototype, "strict", { |
| + get: function() { "use strict"; assertSame(strict_type, typeof this); }, |
| + set: function() { "use strict"; assertSame(strict_type, typeof this); } |
| + }); |
| + primitive.strict = primitive.strict; |
| + // Check that non-strict mode passes wrapped this value. |
| + var sloppy_type = typeof Object(primitive); |
| + Object.defineProperty(prototype, "sloppy", { |
| + get: function() { assertSame(sloppy_type, typeof this); }, |
| + set: function() { assertSame(sloppy_type, typeof this); } |
| + }); |
| + primitive.sloppy = primitive.sloppy; |
| +} |
| +TestAccessorWrapping(Boolean.prototype, true); |
| +TestAccessorWrapping(Number.prototype, 0); |
| +TestAccessorWrapping(Object.prototype, {}); |
| +TestAccessorWrapping(String.prototype, ""); |