Merge pull request #1168 from rwaldron/proxy-own-keys-duplicates-throws

Proxy, [[OwnPropertyKeys]]: If trapResult contains any duplicate entries, throw a TypeError
This commit is contained in:
Leo Balter 2017-08-10 12:31:59 -04:00 committed by GitHub
commit c93ba1154e
18 changed files with 89 additions and 40 deletions

View File

@ -1,11 +1,11 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
8. Let trapResultArray be Call(trap, handler, «target»). 7. Let trapResultArray be ? Call(trap, handler, « target »).
---*/ ---*/
var _target, _handler; var _target, _handler;

View File

@ -1,11 +1,12 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
8. Let trapResultArray be Call(trap, handler, «target»). 7. Let trapResultArray be ? Call(trap, handler, « target »).
features: [Symbol] features: [Symbol]
---*/ ---*/

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
If target is extensible, return the non-falsy trap result if target doesn't If target is extensible, return the non-falsy trap result if target doesn't
contain any non-configurable keys. contain any non-configurable keys.
@ -9,7 +9,7 @@ info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
19. If extensibleTarget is true and targetNonconfigurableKeys is empty, then 15. If extensibleTarget is true and targetNonconfigurableKeys is empty, then
a. Return trapResult. a. Return trapResult.
---*/ ---*/

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
If target is extensible, return the non-falsy trap result if it contains all If target is extensible, return the non-falsy trap result if it contains all
of target's non-configurable keys. of target's non-configurable keys.
@ -9,7 +9,7 @@ info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
22. If extensibleTarget is true, return trapResult. 18. If extensibleTarget is true, return trapResult.
---*/ ---*/
var target = {}; var target = {};

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
If target is not extensible, the result must contain all the keys of the own If target is not extensible, the result must contain all the keys of the own
properties of the target object. properties of the target object.
@ -9,7 +9,7 @@ info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
23. Repeat, for each key that is an element of targetConfigurableKeys, 19. For each key that is an element of targetConfigurableKeys, do
a. If key is not an element of uncheckedResultKeys, throw a TypeError a. If key is not an element of uncheckedResultKeys, throw a TypeError
exception. exception.
---*/ ---*/

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
If target is not extensible, the result can't contain keys names not If target is not extensible, the result can't contain keys names not
contained in the target object. contained in the target object.
@ -9,7 +9,7 @@ info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
24. If uncheckedResultKeys is not empty, throw a TypeError exception. 20. If uncheckedResultKeys is not empty, throw a TypeError exception.
---*/ ---*/
var target = { var target = {

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
If target is not extensible, the result must contain all the keys of the own If target is not extensible, the result must contain all the keys of the own
properties of the target object and no other values properties of the target object and no other values
@ -9,7 +9,7 @@ info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
25. Return trapResult. 21. Return trapResult.
---*/ ---*/
var target = { var target = {

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )

View File

@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
The result List must contain the keys of all non-configurable own properties The result List must contain the keys of all non-configurable own properties
of the target object. of the target object.
@ -9,9 +9,10 @@ info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
21. Repeat, for each key that is an element of targetNonconfigurableKeys, 17. For each key that is an element of targetNonconfigurableKeys, do
a. If key is not an element of uncheckedResultKeys, throw a TypeError a. If key is not an element of uncheckedResultKeys, throw a TypeError
exception. exception.
---*/ ---*/
var target = { var target = {

View File

@ -0,0 +1,22 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: >
The returned list must not contain any duplicate entries.
info: >
[[OwnPropertyKeys]] ( )
...
9. If trapResult contains any duplicate entries, throw a TypeError exception.
---*/
var p = new Proxy({}, {
ownKeys() {
return ["a", "a"];
}
});
assert.throws(TypeError, function() {
Object.keys(p);
});

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: >
The returned list must not contain any duplicate entries.
info: >
[[OwnPropertyKeys]] ( )
...
9. If trapResult contains any duplicate entries, throw a TypeError exception.
---*/
var s = Symbol();
var p = new Proxy({}, {
ownKeys() {
return [s, s];
}
});
assert.throws(TypeError, function() {
Object.keys(p);
});

View File

@ -1,19 +1,16 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
Trap returns abrupt. Trap returns abrupt.
info: > info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
... ...
8. Let trapResultArray be Call(trap, handler, «target»). 7. Let trapResultArray be ? Call(trap, handler, « target »).
9. Let trapResult be CreateListFromArrayLike(trapResultArray, «String, Symbol»). 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »).
7.3.17 CreateListFromArrayLike (obj [, elementTypes] )
1. ReturnIfAbrupt(obj).
...
---*/ ---*/
var p = new Proxy({}, { var p = new Proxy({}, {

View File

@ -2,7 +2,6 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
es6id: 9.5.12
description: > description: >
If return is not a list object, throw a TypeError exception (honoring If return is not a list object, throw a TypeError exception (honoring
the Realm of the current execution context) the Realm of the current execution context)
@ -13,10 +12,11 @@ info: |
Symbol »). Symbol »).
... ...
#sec-createlistfromarraylike
7.3.17 CreateListFromArrayLike (obj [, elementTypes] ) 7.3.17 CreateListFromArrayLike (obj [, elementTypes] )
... 2. If Type(obj) is not Object, throw a TypeError exception.
3. If Type(obj) is not Object, throw a TypeError exception.
features: [Symbol] features: [Symbol]
---*/ ---*/

View File

@ -1,18 +1,22 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
If return is not a list object, throw a TypeError exception If return is not a list object, throw a TypeError exception
info: > info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
8. Let trapResultArray be Call(trap, handler, «target»). 7. Let trapResultArray be ? Call(trap, handler, « target »).
9. Let trapResult be CreateListFromArrayLike(trapResultArray, «String, 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String,
Symbol»). Symbol »).
... ...
7.3.17 CreateListFromArrayLike (obj [, elementTypes] )
3. If Type(obj) is not Object, throw a TypeError exception. #sec-createlistfromarraylike
7.3.17 CreateListFromArrayLike (obj [, elementTypes] )
2. If Type(obj) is not Object, throw a TypeError exception.
features: [Symbol] features: [Symbol]
---*/ ---*/

View File

@ -2,7 +2,6 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
es6id: 9.5.12
description: > description: >
Throws if trap is not callable (honoring the Realm of the current execution Throws if trap is not callable (honoring the Realm of the current execution
context) context)
@ -12,9 +11,10 @@ info: |
5. Let trap be GetMethod(handler, "ownKeys"). 5. Let trap be GetMethod(handler, "ownKeys").
... ...
#sec-getmethod
7.3.9 GetMethod (O, P) 7.3.9 GetMethod (O, P)
5. If IsCallable(func) is false, throw a TypeError exception. 4. If IsCallable(func) is false, throw a TypeError exception.
---*/ ---*/
var OProxy = $262.createRealm().global.Proxy; var OProxy = $262.createRealm().global.Proxy;

View File

@ -1,18 +1,19 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
Trap is not callable. Trap is not callable.
info: > info: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
5. Let trap be GetMethod(handler, "ownKeys"). 5. Let trap be ? GetMethod(handler, "ownKeys").
... ...
#sec-getmethod
7.3.9 GetMethod (O, P) 7.3.9 GetMethod (O, P)
5. If IsCallable(func) is false, throw a TypeError exception. 4. If IsCallable(func) is false, throw a TypeError exception.
---*/ ---*/
var p = new Proxy({attr:1}, { var p = new Proxy({attr:1}, {

View File

@ -1,11 +1,11 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved. // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: 9.5.12 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
description: > description: >
[[OwnPropertyKeys]] ( ) [[OwnPropertyKeys]] ( )
7. If trap is undefined, then Return target.[[OwnPropertyKeys]]() 6. If trap is undefined, then Return target.[[OwnPropertyKeys]]()
---*/ ---*/
var target = { var target = {