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

Side by Side 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: pass filter along 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 unified diff | Download patch
« src/key-accumulator.h ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
Jakob Kummerow 2016/01/19 15:32:53 nit: 2015 is so last year
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function allKeys(object) {
6 var keys = [];
7 for (var key in object) {
8 keys.push(key);
9 }
10 return keys;
11 }
12
13 var a = { a1: true, a2: true};
14 var b = { b1: true, b2: true};
15 a.__proto__ = b;
16
17 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
18 assertEquals(['b1', 'b2'], allKeys(b));
19
20 // Adding a non-enumerable property to either a or b should change
Jakob Kummerow 2016/01/19 15:32:53 nit: s/should/shouldn't/
21 // the result.
22 var propertyDescriptor = {
23 enumerable: false,
24 configurable: true,
25 writable: true,
26 value: true
27 };
28
29 Object.defineProperty(a, 'a3', propertyDescriptor);
30 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
31 assertEquals(['b1', 'b2'], allKeys(b));
32
33 Object.defineProperty(b, 'b3', propertyDescriptor);
34 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
35 assertEquals(['b1', 'b2'], allKeys(b));
36
37 // A non-enumerable property shadows an enumerable version on the prototype
38 // chain.
39 b['a3'] = true;
40 Object.defineProperty(a, 'a3', propertyDescriptor);
Jakob Kummerow 2016/01/19 15:32:53 You've already done this in line 29.
41 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
42 assertEquals(['b1', 'b2', 'a3'], allKeys(b));
43
44 // Try the same with indexed-properties.
45 var aIndex = {0:true, 1:true};
46 var bIndex = {10:true, 11:true};
47 aIndex.__proto__= bIndex;
48 assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
49 assertEquals(['10', '11'], allKeys(bIndex));
50
51 Object.defineProperty(aIndex, 2, propertyDescriptor);
52 Object.defineProperty(bIndex, 12, propertyDescriptor);
53 assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
54 assertEquals(['10', '11'], allKeys(bIndex));
55
56 bIndex[2] = 2;
57 assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
58 assertEquals(['2', '10', '11'], allKeys(bIndex));
OLDNEW
« src/key-accumulator.h ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698