diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor')
15 files changed, 410 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/browser.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/browser.js diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/getOwnPropertyDescriptor.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/getOwnPropertyDescriptor.js new file mode 100644 index 0000000000..48c2268874 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/getOwnPropertyDescriptor.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Reflect.getOwnPropertyDescriptor is configurable, writable and not enumerable. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [Reflect] +---*/ + +verifyNotEnumerable(Reflect, 'getOwnPropertyDescriptor'); +verifyWritable(Reflect, 'getOwnPropertyDescriptor'); +verifyConfigurable(Reflect, 'getOwnPropertyDescriptor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js new file mode 100644 index 0000000000..47bc4d2b9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Reflect.getOwnPropertyDescriptor.length value and property descriptor +includes: [propertyHelper.js] +features: [Reflect] +---*/ + +assert.sameValue( + Reflect.getOwnPropertyDescriptor.length, 2, + 'The value of `Reflect.getOwnPropertyDescriptor.length` is `2`' +); + +verifyNotEnumerable(Reflect.getOwnPropertyDescriptor, 'length'); +verifyNotWritable(Reflect.getOwnPropertyDescriptor, 'length'); +verifyConfigurable(Reflect.getOwnPropertyDescriptor, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js new file mode 100644 index 0000000000..521736be82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Reflect.getOwnPropertyDescriptor.name value and property descriptor +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [Reflect] +---*/ + +assert.sameValue( + Reflect.getOwnPropertyDescriptor.name, 'getOwnPropertyDescriptor', + 'The value of `Reflect.getOwnPropertyDescriptor.name` is `"getOwnPropertyDescriptor"`' +); + +verifyNotEnumerable(Reflect.getOwnPropertyDescriptor, 'name'); +verifyNotWritable(Reflect.getOwnPropertyDescriptor, 'name'); +verifyConfigurable(Reflect.getOwnPropertyDescriptor, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js new file mode 100644 index 0000000000..62c4d5511e --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Reflect.getOwnPropertyDescriptor does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Reflect, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Reflect.getOwnPropertyDescriptor), + false, + 'isConstructor(Reflect.getOwnPropertyDescriptor) must return false' +); + +assert.throws(TypeError, () => { + new Reflect.getOwnPropertyDescriptor({}, ''); +}, '`new Reflect.getOwnPropertyDescriptor({}, \'\')` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-abrupt-from-property-key.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-abrupt-from-property-key.js new file mode 100644 index 0000000000..61a47cc036 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-abrupt-from-property-key.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Return abrupt from ToPropertyKey(propertyKey) +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 2. Let key be ToPropertyKey(propertyKey). + 3. ReturnIfAbrupt(key). + ... +features: [Reflect] +---*/ + +var p = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + Reflect.getOwnPropertyDescriptor({}, p); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-abrupt-from-result.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-abrupt-from-result.js new file mode 100644 index 0000000000..a5af7f65c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-abrupt-from-result.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Return abrupt result from getting the property descriptor. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 4. Let desc be target.[[GetOwnProperty]](key). + 5. ReturnIfAbrupt(desc). + ... +features: [Proxy, Reflect] +---*/ + +var o1 = {}; +var p = new Proxy(o1, { + getOwnPropertyDescriptor: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Reflect.getOwnPropertyDescriptor(p, 'p1'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-from-accessor-descriptor.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-from-accessor-descriptor.js new file mode 100644 index 0000000000..e4200db1c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-from-accessor-descriptor.js @@ -0,0 +1,57 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Return a property descriptor object as an accessor descriptor. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 4. Let desc be target.[[GetOwnProperty]](key). + 5. ReturnIfAbrupt(desc). + 6. Return FromPropertyDescriptor(desc). + + 6.2.4.4 FromPropertyDescriptor ( Desc ) + + ... + 2. Let obj be ObjectCreate(%ObjectPrototype%). + ... + 4. If Desc has a [[Value]] field, then + a. Perform CreateDataProperty(obj, "value", Desc.[[Value]]). + 5. If Desc has a [[Writable]] field, then + a. Perform CreateDataProperty(obj, "writable", Desc.[[Writable]]). + 6. If Desc has a [[Get]] field, then + a. Perform CreateDataProperty(obj, "get", Desc.[[Get]]). + 7. If Desc has a [[Set]] field, then + a. Perform CreateDataProperty(obj, "set", Desc.[[Set]]) + 8. If Desc has an [[Enumerable]] field, then + a. Perform CreateDataProperty(obj, "enumerable", Desc.[[Enumerable]]). + 9. If Desc has a [[Configurable]] field, then + a. Perform CreateDataProperty(obj , "configurable", Desc.[[Configurable]]). + ... + 11. Return obj. + +includes: [compareArray.js] +features: [Reflect] +---*/ + +var o1 = {}; +var fn = function() {}; +Object.defineProperty(o1, 'p', { + get: fn, + configurable: true +}); + +var result = Reflect.getOwnPropertyDescriptor(o1, 'p'); + +assert.compareArray( + Object.getOwnPropertyNames(result), + ['get', 'set', 'enumerable', 'configurable'] +); +assert.sameValue(result.enumerable, false); +assert.sameValue(result.configurable, true); +assert.sameValue(result.get, fn); +assert.sameValue(result.set, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-from-data-descriptor.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-from-data-descriptor.js new file mode 100644 index 0000000000..6acc6cdcff --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/return-from-data-descriptor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Return a property descriptor object as a data descriptor. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 4. Let desc be target.[[GetOwnProperty]](key). + 5. ReturnIfAbrupt(desc). + 6. Return FromPropertyDescriptor(desc). +includes: [compareArray.js] +features: [Reflect] +---*/ + +var o1 = { + p: 'foo' +}; + +var result = Reflect.getOwnPropertyDescriptor(o1, 'p'); + +assert.compareArray( + Object.getOwnPropertyNames(result), + ['value', 'writable', 'enumerable', 'configurable'] +); +assert.sameValue(result.value, 'foo'); +assert.sameValue(result.enumerable, true); +assert.sameValue(result.configurable, true); +assert.sameValue(result.writable, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/shell.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/symbol-property.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/symbol-property.js new file mode 100644 index 0000000000..ed4956702d --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/symbol-property.js @@ -0,0 +1,39 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Use a symbol value on property key. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 2. Let key be ToPropertyKey(propertyKey). + ... + + 7.1.14 ToPropertyKey ( argument ) + + ... + 3. If Type(key) is Symbol, then + a. Return key. + ... +includes: [compareArray.js] +features: [Reflect, Symbol] +---*/ + +var o = {}; +var s = Symbol('42'); +o[s] = 42; + +var result = Reflect.getOwnPropertyDescriptor(o, s); + +assert.compareArray( + Object.getOwnPropertyNames(result), + ['value', 'writable', 'enumerable', 'configurable'] +); +assert.sameValue(result.value, 42); +assert.sameValue(result.enumerable, true); +assert.sameValue(result.configurable, true); +assert.sameValue(result.writable, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/target-is-not-object-throws.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/target-is-not-object-throws.js new file mode 100644 index 0000000000..597cbd22ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/target-is-not-object-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Throws a TypeError if target is not an Object. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + 1. If Type(target) is not Object, throw a TypeError exception. + ... +features: [Reflect] +---*/ + +assert.throws(TypeError, function() { + Reflect.getOwnPropertyDescriptor(1, 'p'); +}); + +assert.throws(TypeError, function() { + Reflect.getOwnPropertyDescriptor(null, 'p'); +}); + +assert.throws(TypeError, function() { + Reflect.getOwnPropertyDescriptor(undefined, 'p'); +}); + +assert.throws(TypeError, function() { + Reflect.getOwnPropertyDescriptor('', 'p'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/target-is-symbol-throws.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/target-is-symbol-throws.js new file mode 100644 index 0000000000..426385becf --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/target-is-symbol-throws.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Throws a TypeError if target is a Symbol +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + 1. If Type(target) is not Object, throw a TypeError exception. + ... +features: [Reflect, Symbol] +---*/ + +assert.throws(TypeError, function() { + Reflect.getOwnPropertyDescriptor(Symbol(1), 'p'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/undefined-own-property.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/undefined-own-property.js new file mode 100644 index 0000000000..5328c41105 --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/undefined-own-property.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 Leonardo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Return undefined for an non existing own property. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 4. Let desc be target.[[GetOwnProperty]](key). + 5. ReturnIfAbrupt(desc). + 6. Return FromPropertyDescriptor(desc). + + 6.2.4.4 FromPropertyDescriptor ( Desc ) + + 1. If Desc is undefined, return undefined. +features: [Reflect] +---*/ + +var o = Object.create({ + p: 1 +}); + +var result = Reflect.getOwnPropertyDescriptor(o, 'p'); +assert.sameValue(result, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/undefined-property.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/undefined-property.js new file mode 100644 index 0000000000..3eff63118f --- /dev/null +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/undefined-property.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.1.7 +description: > + Return undefined for an undefined property. +info: | + 26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey ) + + ... + 4. Let desc be target.[[GetOwnProperty]](key). + 5. ReturnIfAbrupt(desc). + 6. Return FromPropertyDescriptor(desc). + + 6.2.4.4 FromPropertyDescriptor ( Desc ) + + 1. If Desc is undefined, return undefined. +features: [Reflect] +---*/ + +var result = Reflect.getOwnPropertyDescriptor({}, undefined); +assert.sameValue(result, undefined); + +reportCompare(0, 0); |