Reviewers: rossberg, Michael Starzinger, arv,

Description:
Fix issue with setting __proto__ on a value

BUG=v8:3172

Please review this at https://codereview.chromium.org/174113003/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+5, -4 lines):
  M src/v8natives.js
  M test/mjsunit/proto-accessor.js


Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 256343a89e9a8ec302242b40d37764cb62696c87..c850a4bcbb65fbd69cc3de5c296b36eacda70441 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1394,7 +1394,7 @@ function ObjectGetProto() {
 function ObjectSetProto(proto) {
   CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__");

-  if (IS_SPEC_OBJECT(proto) || IS_NULL(proto) && IS_SPEC_OBJECT(this)) {
+  if ((IS_SPEC_OBJECT(proto) || IS_NULL(proto)) && IS_SPEC_OBJECT(this)) {
     %SetPrototype(this, proto);
   }
 }
Index: test/mjsunit/proto-accessor.js
diff --git a/test/mjsunit/proto-accessor.js b/test/mjsunit/proto-accessor.js
index 5eb48bbd239af1f8a420fd626a108fb64ebba944..3f8b3a1331a97bc8dd798414a069f2d6dad00d52 100644
--- a/test/mjsunit/proto-accessor.js
+++ b/test/mjsunit/proto-accessor.js
@@ -98,12 +98,13 @@ var values = [1, true, false, 's', Symbol()];


 function TestSetProtoOfValues() {
+  var proto = {};
   for (var i = 0; i < values.length; i++) {
-    assertEquals(setProto.call(values[i], i), undefined);
+    assertEquals(setProto.call(values[i], proto), undefined);
   }

-  assertThrows(function() { setProto.call(null, 7); }, TypeError);
-  assertThrows(function() { setProto.call(undefined, 8); }, TypeError);
+  assertThrows(function() { setProto.call(null, proto); }, TypeError);
+  assertThrows(function() { setProto.call(undefined, proto); }, TypeError);
 }
 TestSetProtoOfValues();



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to