Skip to content

Commit

Permalink
Object.getOwnPropertyDescriptors: add test to ensure undefined desc…
Browse files Browse the repository at this point in the history
…riptors are not added.

Per tc39/ecma262#593
  • Loading branch information
ljharb committed Jun 2, 2016
1 parent 91d06f5 commit 0fc5ed6
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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: sec-object.getownpropertydescriptors
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")

0 comments on commit 0fc5ed6

Please sign in to comment.