Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js

raw
1 // Copyright (C) 2016 Jordan Harband. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: Object.getOwnPropertyDescriptors should filter out undefined OwnPropertyDescriptors
6 esid: sec-object.getownpropertydescriptors
7 author: Jordan Harband
8 features: [Proxy]
9 includes: [proxyTrapsHelper.js]
10 ---*/
11
12 var key = "a";
13 var ownKeys = [key];
14 var badProxyHandlers = allowProxyTraps({
15 getOwnPropertyDescriptor: function() {},
16 ownKeys: function() {
17 return ownKeys;
18 }
19 });
20 var proxy = new Proxy({}, badProxyHandlers);
21
22 var keys = Reflect.ownKeys(proxy);
23 assert.notSameValue(keys, ownKeys, 'Object.keys returns a new Array');
24 assert.sameValue(Array.isArray(keys), true, 'Object.keys returns an Array');
25 assert.sameValue(keys.length, ownKeys.length, 'keys and ownKeys have the same length');
26 assert.sameValue(keys[0], ownKeys[0], 'keys and ownKeys have the same contents');
27
28 var descriptor = Object.getOwnPropertyDescriptor(proxy, key);
29 assert.sameValue(descriptor, undefined, "Descriptor matches result of [[GetOwnPropertyDescriptor]] trap");
30
31 var result = Object.getOwnPropertyDescriptors(proxy);
32 assert.sameValue(key in result, false, "key is not present in result");