Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: test/mjsunit/regress/regress-705-shadowed_properties.js

Issue 1608523002: [runtime] Do not use the enum-cache for non-prototype objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: signed unsigned missmatch Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-705-shadowed_properties.js
diff --git a/test/mjsunit/regress/regress-705-shadowed_properties.js b/test/mjsunit/regress/regress-705-shadowed_properties.js
new file mode 100644
index 0000000000000000000000000000000000000000..f5b9e8262e682466f8459e9afdf5089eafd869f8
--- /dev/null
+++ b/test/mjsunit/regress/regress-705-shadowed_properties.js
@@ -0,0 +1,57 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function allKeys(object) {
+ var keys = [];
+ for (var key in object) {
+ keys.push(key);
+ }
+ return keys;
+}
+
+var a = { a1: true, a2: true};
+var b = { b1: true, b2: true};
+a.__proto__ = b;
+
+assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
+assertEquals(['b1', 'b2'], allKeys(b));
+
+// Adding a non-enumerable property to either a or b shouldn't change
+// the result.
+var propertyDescriptor = {
+ enumerable: false,
+ configurable: true,
+ writable: true,
+ value: true
+};
+
+Object.defineProperty(a, 'a3', propertyDescriptor);
+assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
+assertEquals(['b1', 'b2'], allKeys(b));
+
+Object.defineProperty(b, 'b3', propertyDescriptor);
+assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
+assertEquals(['b1', 'b2'], allKeys(b));
+
+// A non-enumerable property shadows an enumerable version on the prototype
+// chain.
+b['a3'] = true;
+assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
+assertEquals(['b1', 'b2', 'a3'], allKeys(b));
+
+// Try the same with indexed-properties.
+var aIndex = {0:true, 1:true};
+var bIndex = {10:true, 11:true};
+aIndex.__proto__= bIndex;
+assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
+assertEquals(['10', '11'], allKeys(bIndex));
+
+Object.defineProperty(aIndex, 2, propertyDescriptor);
+Object.defineProperty(bIndex, 12, propertyDescriptor);
+assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
+assertEquals(['10', '11'], allKeys(bIndex));
+
+bIndex[2] = 2;
+assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
+assertEquals(['2', '10', '11'], allKeys(bIndex));
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698