From c2eaa30b08fb1e041b7297e415b6bad8461f50dc Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 2 Jun 2016 14:30:36 -0700 Subject: [PATCH] `Object.getOwnPropertyDescriptors`: add test to ensure undefined descriptors are not added. Per https://github.com/tc39/ecma262/pull/593 --- .../proxy-undefined-descriptor.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js diff --git a/test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js b/test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js new file mode 100644 index 00000000000..56ea84b579a --- /dev/null +++ b/test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.getOwnPropertyDescriptors should perform observable operations in the correct order +esid: pending +author: Jordan Harband +features: [Proxy] +includes: [proxyTrapsHelper.js] +---*/ + +var key = "a"; +var ownKeys = [key]; +var badProxyHandlers = allowProxyTraps({ + getOwnPropertyDescriptor: function () {}, + ownKeys: function () { + return ownKeys; + } +}); +var proxy = new Proxy({}, badProxyHandlers); + +var keys = Object.keys(proxy); +assert.sameValue(keys, ownKeys, 'Object.keys returns the result of the [[OwnKeys]] trap'); + +var descriptor = Object.getOwnPropertyDescriptor(proxy, key); +assert.sameValue(descriptor, undefined, "Descriptor matches result of [[GetOwnPropertyDescriptor]] trap"); + +var result = Object.getOwnPropertyDescriptors(proxy); +assert.sameValue(key in result, false, "key is not present in result")