forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Object.getOwnPropertyDescriptors
: add test to ensure undefined desc…
…riptors are not added. Per tc39/ecma262#593
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
test/built-ins/Object/getOwnPropertyDescriptors/proxy-undefined-descriptor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |