Reviewers: Michael Starzinger,
Description:
Proxies: Fix ToStringArray function so that it does not reject some keys.
[email protected]
BUG=v8:1543
TEST=
Please review this at https://chromiumcodereview.appspot.com/10453053/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/v8natives.js
M test/mjsunit/harmony/proxies.js
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index
f1e8084a53038dff8d8c33a888d2e1bf41311af4..86f07a195ae499ace4efdb430547493e07184133
100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -337,7 +337,7 @@ function ObjectKeys(obj) {
if (%IsJSProxy(obj)) {
var handler = %GetHandler(obj);
var names = CallTrap0(handler, "keys", DerivedKeysTrap);
- return ToStringArray(names);
+ return ToStringArray(names, "keys");
}
return %LocalKeys(obj);
}
@@ -963,7 +963,7 @@ function ToStringArray(obj, trap) {
var names = {}; // TODO(rossberg): use sets once they are ready.
for (var index = 0; index < n; index++) {
var s = ToString(obj[index]);
- if (s in names) {
+ if (%HasLocalProperty(names, s)) {
throw MakeTypeError("proxy_repeated_prop_name", [obj, trap, s]);
}
array[index] = s;
Index: test/mjsunit/harmony/proxies.js
diff --git a/test/mjsunit/harmony/proxies.js
b/test/mjsunit/harmony/proxies.js
index
8d8f83996e255832168fa0c3c5a2d3f117888cb8..8b12b389b9cf956d47d086e3d4ed6c7011385c48
100644
--- a/test/mjsunit/harmony/proxies.js
+++ b/test/mjsunit/harmony/proxies.js
@@ -1630,8 +1630,8 @@ TestPropertyNames([], {
getOwnPropertyNames: function() { return [] }
})
-TestPropertyNames(["a", "zz", " ", "0"], {
- getOwnPropertyNames: function() { return ["a", "zz", " ", 0] }
+TestPropertyNames(["a", "zz", " ", "0", "toString"], {
+ getOwnPropertyNames: function() { return ["a", "zz", " ", 0, "toString"]
}
})
TestPropertyNames(["throw", "function "], {
@@ -1678,8 +1678,8 @@ TestKeys([], {
keys: function() { return [] }
})
-TestKeys(["a", "zz", " ", "0"], {
- keys: function() { return ["a", "zz", " ", 0] }
+TestKeys(["a", "zz", " ", "0", "toString"], {
+ keys: function() { return ["a", "zz", " ", 0, "toString"] }
})
TestKeys(["throw", "function "], {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev