diff --git a/test/built-ins/Proxy/ownKeys/return-type-throws-array.js b/test/built-ins/Proxy/ownKeys/return-type-throws-array.js new file mode 100644 index 0000000000000000000000000000000000000000..1088f8e290a8785124166a425b06167c4bec04f9 --- /dev/null +++ b/test/built-ins/Proxy/ownKeys/return-type-throws-array.js @@ -0,0 +1,34 @@ +// 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 have entries whose type does not match + « String, Symbol ». +info: > + [[OwnPropertyKeys]] ( ) + + ... + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? + CreateListFromArrayLike(trapResultArray, « String, Symbol »). + ... + + CreateListFromArrayLike ( obj [ , elementTypes ] ) + + ... + 6. Repeat, while index < len + ... + d. If Type(next) is not an element of elementTypes, + throw a TypeError exception. +---*/ + +var p = new Proxy({}, { + ownKeys() { + return [[]]; + } +}); + +assert.throws(TypeError, function() { + Object.keys(p); +}); diff --git a/test/built-ins/Proxy/ownKeys/return-type-throws-boolean.js b/test/built-ins/Proxy/ownKeys/return-type-throws-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..e97209fe9f20b3d52799713b61a2e196de180f73 --- /dev/null +++ b/test/built-ins/Proxy/ownKeys/return-type-throws-boolean.js @@ -0,0 +1,34 @@ +// 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 have entries whose type does not match + « String, Symbol ». +info: > + [[OwnPropertyKeys]] ( ) + + ... + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? + CreateListFromArrayLike(trapResultArray, « String, Symbol »). + ... + + CreateListFromArrayLike ( obj [ , elementTypes ] ) + + ... + 6. Repeat, while index < len + ... + d. If Type(next) is not an element of elementTypes, + throw a TypeError exception. +---*/ + +var p = new Proxy({}, { + ownKeys() { + return [true]; + } +}); + +assert.throws(TypeError, function() { + Object.keys(p); +}); diff --git a/test/built-ins/Proxy/ownKeys/return-type-throws-null.js b/test/built-ins/Proxy/ownKeys/return-type-throws-null.js new file mode 100644 index 0000000000000000000000000000000000000000..8b464e837ca2a90bb0dfc5427dc9f201ab8bce09 --- /dev/null +++ b/test/built-ins/Proxy/ownKeys/return-type-throws-null.js @@ -0,0 +1,34 @@ +// 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 have entries whose type does not match + « String, Symbol ». +info: > + [[OwnPropertyKeys]] ( ) + + ... + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? + CreateListFromArrayLike(trapResultArray, « String, Symbol »). + ... + + CreateListFromArrayLike ( obj [ , elementTypes ] ) + + ... + 6. Repeat, while index < len + ... + d. If Type(next) is not an element of elementTypes, + throw a TypeError exception. +---*/ + +var p = new Proxy({}, { + ownKeys() { + return [null]; + } +}); + +assert.throws(TypeError, function() { + Object.keys(p); +}); diff --git a/test/built-ins/Proxy/ownKeys/return-type-throws-number.js b/test/built-ins/Proxy/ownKeys/return-type-throws-number.js new file mode 100644 index 0000000000000000000000000000000000000000..0ab76341d72df0b0200f79072159c39928c8a757 --- /dev/null +++ b/test/built-ins/Proxy/ownKeys/return-type-throws-number.js @@ -0,0 +1,34 @@ +// 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 have entries whose type does not match + « String, Symbol ». +info: > + [[OwnPropertyKeys]] ( ) + + ... + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? + CreateListFromArrayLike(trapResultArray, « String, Symbol »). + ... + + CreateListFromArrayLike ( obj [ , elementTypes ] ) + + ... + 6. Repeat, while index < len + ... + d. If Type(next) is not an element of elementTypes, + throw a TypeError exception. +---*/ + +var p = new Proxy({}, { + ownKeys() { + return [1]; + } +}); + +assert.throws(TypeError, function() { + Object.keys(p); +}); diff --git a/test/built-ins/Proxy/ownKeys/return-type-throws-object.js b/test/built-ins/Proxy/ownKeys/return-type-throws-object.js new file mode 100644 index 0000000000000000000000000000000000000000..433157e0548564eb7e9ca357f20615dfcc456ee7 --- /dev/null +++ b/test/built-ins/Proxy/ownKeys/return-type-throws-object.js @@ -0,0 +1,34 @@ +// 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 have entries whose type does not match + « String, Symbol ». +info: > + [[OwnPropertyKeys]] ( ) + + ... + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? + CreateListFromArrayLike(trapResultArray, « String, Symbol »). + ... + + CreateListFromArrayLike ( obj [ , elementTypes ] ) + + ... + 6. Repeat, while index < len + ... + d. If Type(next) is not an element of elementTypes, + throw a TypeError exception. +---*/ + +var p = new Proxy({}, { + ownKeys() { + return [{}]; + } +}); + +assert.throws(TypeError, function() { + Object.keys(p); +}); diff --git a/test/built-ins/Proxy/ownKeys/return-type-throws-undefined.js b/test/built-ins/Proxy/ownKeys/return-type-throws-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..9800fa4dfa17d1380aff3c123fb019e09db75076 --- /dev/null +++ b/test/built-ins/Proxy/ownKeys/return-type-throws-undefined.js @@ -0,0 +1,34 @@ +// 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 have entries whose type does not match + « String, Symbol ». +info: > + [[OwnPropertyKeys]] ( ) + + ... + 7. Let trapResultArray be ? Call(trap, handler, « target »). + 8. Let trapResult be ? + CreateListFromArrayLike(trapResultArray, « String, Symbol »). + ... + + CreateListFromArrayLike ( obj [ , elementTypes ] ) + + ... + 6. Repeat, while index < len + ... + d. If Type(next) is not an element of elementTypes, + throw a TypeError exception. +---*/ + +var p = new Proxy({}, { + ownKeys() { + return [undefined]; + } +}); + +assert.throws(TypeError, function() { + Object.keys(p); +});