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 fce8b58 commit db19bca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var proxy = new Proxy({}, {
},
getOwnPropertyDescriptor(t, name) {
log += 'getOwnPropertyDescriptor:' + name + '|';
return descriptors[i++];
return descriptors[i > descriptors.length ? i : i++];
}
});

Expand Down
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 db19bca

Please sign in to comment.