Reviewers: rossberg,
Description:
Fix wrapping of receiver for non-strict callbacks.
[email protected]
BUG=v8:1973
TEST=mjsunit/regress/regress-1973
Please review this at https://chromiumcodereview.appspot.com/9705020/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/objects.cc
M test/mjsunit/getter-in-value-prototype.js
A + test/mjsunit/regress/regress-1973.js
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
7865ac0715aba77b0f0ff84641095c6d341af492..a0872c6a2492154f2320c4e9b926c0e4ebf310ec
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -288,7 +288,7 @@ MaybeObject*
Object::GetPropertyWithDefinedGetter(Object* receiver,
bool has_pending_exception;
Handle<Object> result =
- Execution::Call(fun, self, 0, NULL, &has_pending_exception);
+ Execution::Call(fun, self, 0, NULL, &has_pending_exception, true);
// Check for pending exception and return the result.
if (has_pending_exception) return Failure::Exception();
return *result;
Index: test/mjsunit/getter-in-value-prototype.js
diff --git a/test/mjsunit/getter-in-value-prototype.js
b/test/mjsunit/getter-in-value-prototype.js
index
b55320ac5b9ea8f30c820f15fd572772f25363b5..abe2cb1934b0dab8f366e93e1bc19480c4fd1230
100644
--- a/test/mjsunit/getter-in-value-prototype.js
+++ b/test/mjsunit/getter-in-value-prototype.js
@@ -31,5 +31,5 @@
// JSObject.
String.prototype.__defineGetter__('x', function() { return this; });
-assertEquals('asdf', 'asdf'.x);
+assertEquals(Object('asdf'), 'asdf'.x);
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) {
+ // 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, "");
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev