From 1cd7d875014d75b32c22cc3b57d4163383721c66 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 16 Sep 2020 15:33:42 -0400 Subject: [PATCH] Object.defineProperty: Property description must be an object. Fixes gh-1754 --- ...escription-must-be-an-object-not-bigint.js | 23 ++++++++++++++++ ...description-must-be-an-object-not-false.js | 26 ++++++++++++++++++ ...-description-must-be-an-object-not-null.js | 26 ++++++++++++++++++ ...escription-must-be-an-object-not-number.js | 26 ++++++++++++++++++ ...escription-must-be-an-object-not-string.js | 26 ++++++++++++++++++ ...escription-must-be-an-object-not-symbol.js | 27 +++++++++++++++++++ ...-description-must-be-an-object-not-true.js | 26 ++++++++++++++++++ ...ription-must-be-an-object-not-undefined.js | 26 ++++++++++++++++++ 8 files changed, 206 insertions(+) create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js create mode 100644 test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js new file mode 100644 index 0000000000..1692a9cec4 --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js @@ -0,0 +1,23 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (bigint) +info: | + Object.defineProperty ( O, P, Attributes ) + + ... + Let desc be ? ToPropertyDescriptor(Attributes). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +features: [BigInt] +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', 0n); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js new file mode 100644 index 0000000000..0de5f153e2 --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (false) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', false); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js new file mode 100644 index 0000000000..63f6340012 --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (null) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', null); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js new file mode 100644 index 0000000000..3595a899a0 --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (number) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', 1); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js new file mode 100644 index 0000000000..2d5a109beb --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (string) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', ''); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js new file mode 100644 index 0000000000..b2489e9b7a --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (symbol) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', Symbol()); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js new file mode 100644 index 0000000000..f34dba0883 --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (true) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', true); +}); diff --git a/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js new file mode 100644 index 0000000000..ca579d4655 --- /dev/null +++ b/test/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (undefined) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', undefined); +});