OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-object-own-property-descriptors | 5 // Flags: --harmony-object-own-property-descriptors |
6 // Flags: --allow-natives-syntax | 6 // Flags: --allow-natives-syntax |
7 | 7 |
8 function DataDescriptor(value) { | 8 function DataDescriptor(value) { |
9 return { "enumerable": true, "configurable": true, "writable": true, value }; | 9 return { "enumerable": true, "configurable": true, "writable": true, value }; |
10 } | 10 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 value: "VALUE" | 188 value: "VALUE" |
189 }; | 189 }; |
190 }, | 190 }, |
191 get(target, name) { assertUnreachable(); }, | 191 get(target, name) { assertUnreachable(); }, |
192 set(target, name, value) { assertUnreachable(); }, | 192 set(target, name, value) { assertUnreachable(); }, |
193 deleteProperty(target, name) { assertUnreachable(); }, | 193 deleteProperty(target, name) { assertUnreachable(); }, |
194 defineProperty(target, name, desc) { assertUnreachable(); } | 194 defineProperty(target, name, desc) { assertUnreachable(); } |
195 }); | 195 }); |
196 | 196 |
197 var result = Object.getOwnPropertyDescriptors(P); | 197 var result = Object.getOwnPropertyDescriptors(P); |
198 assertEquals({ "A": undefined }, result); | 198 assertEquals({ |
| 199 "A": { |
| 200 "value": "VALUE", |
| 201 "writable": false, |
| 202 "enumerable": false, |
| 203 "configurable": true |
| 204 } |
| 205 }, result); |
199 assertTrue(result.hasOwnProperty("A")); | 206 assertTrue(result.hasOwnProperty("A")); |
200 assertEquals([ | 207 assertEquals([ |
201 "ownKeys()", | 208 "ownKeys()", |
202 "getOwnPropertyDescriptor(A)", | 209 "getOwnPropertyDescriptor(A)", |
203 "getOwnPropertyDescriptor(A)" | 210 "getOwnPropertyDescriptor(A)" |
204 ], log); | 211 ], log); |
205 } | 212 } |
206 TestDuplicateKeys(); | 213 TestDuplicateKeys(); |
| 214 |
| 215 function TestFakeProperty() { |
| 216 var log = []; |
| 217 var P = new Proxy({}, { |
| 218 ownKeys() { |
| 219 log.push(`ownKeys()`); |
| 220 return ["fakeProperty"]; |
| 221 }, |
| 222 getOwnPropertyDescriptor(target, name) { |
| 223 log.push(`getOwnPropertyDescriptor(${name})`); |
| 224 return; |
| 225 } |
| 226 }); |
| 227 var result = Object.getOwnPropertyDescriptors(P); |
| 228 assertEquals({}, result); |
| 229 assertFalse(result.hasOwnProperty("fakeProperty")); |
| 230 assertEquals([ |
| 231 "ownKeys()", |
| 232 "getOwnPropertyDescriptor(fakeProperty)" |
| 233 ], log); |
| 234 } |
| 235 TestFakeProperty(); |
OLD | NEW |