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/Object/getOwnPropertySymbols | |
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/Object/getOwnPropertySymbols')
14 files changed, 457 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/browser.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/browser.js diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js new file mode 100644 index 0000000000..6807e1d8dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Object.getOwnPropertySymbols.length is 1. +info: | + Object.getOwnPropertySymbols ( O ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Object.getOwnPropertySymbols.length, 1); + +verifyNotEnumerable(Object.getOwnPropertySymbols, "length"); +verifyNotWritable(Object.getOwnPropertySymbols, "length"); +verifyConfigurable(Object.getOwnPropertySymbols, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js new file mode 100644 index 0000000000..0199dbba7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Object.getOwnPropertySymbols.name is "getOwnPropertySymbols". +info: | + Object.getOwnPropertySymbols ( O ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Object.getOwnPropertySymbols.name, "getOwnPropertySymbols"); + +verifyNotEnumerable(Object.getOwnPropertySymbols, "name"); +verifyNotWritable(Object.getOwnPropertySymbols, "name"); +verifyConfigurable(Object.getOwnPropertySymbols, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/non-object-argument-invalid.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/non-object-argument-invalid.js new file mode 100644 index 0000000000..ca722cca30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/non-object-argument-invalid.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-object.getownpropertysymbols +description: > + Object.getOwnPropertySymbols called with an invalid non-object value +info: | + GetOwnPropertyKeys ( O, type ) + + Let obj be ? ToObject(O). + Let keys be ? obj.[[OwnPropertyKeys]](). + Let nameList be a new empty List. + For each element nextKey of keys, do + If Type(nextKey) is Symbol and type is symbol or Type(nextKey) is String and type is string, then + Append nextKey as the last element of nameList. + Return CreateArrayFromList(nameList). + +features: [Symbol] +---*/ + +let count = 0; + +assert.throws(TypeError, () => { + count++; + Object.getOwnPropertySymbols(undefined); +}, '`Object.getOwnPropertySymbols(undefined)` throws TypeError'); + +assert.throws(TypeError, () => { + count++; + Object.getOwnPropertySymbols(null); +}, '`Object.getOwnPropertySymbols(null)` throws TypeError'); + +assert.sameValue(count, 2, 'The value of `count` is 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/non-object-argument-valid.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/non-object-argument-valid.js new file mode 100644 index 0000000000..bc9f498394 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/non-object-argument-valid.js @@ -0,0 +1,47 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.getownpropertysymbols +description: > + Object.getOwnPropertySymbols called with a valid non-object value +info: | + GetOwnPropertyKeys ( O, type ) + + Let obj be ? ToObject(O). + Let keys be ? obj.[[OwnPropertyKeys]](). + Let nameList be a new empty List. + For each element nextKey of keys, do + If Type(nextKey) is Symbol and type is symbol or Type(nextKey) is String and type is string, then + Append nextKey as the last element of nameList. + Return CreateArrayFromList(nameList). + +features: [Symbol] +includes: [compareArray.js] +---*/ + +assert.compareArray( + Object.getOwnPropertySymbols(true), [], + 'Object.getOwnPropertySymbols(true) must return []' +); +assert.compareArray( + Object.getOwnPropertySymbols(false), [], + 'Object.getOwnPropertySymbols(false) must return []' +); +assert.compareArray( + Object.getOwnPropertySymbols(1), [], + 'Object.getOwnPropertySymbols(1) must return []' +); +assert.compareArray( + Object.getOwnPropertySymbols(0), [], + 'Object.getOwnPropertySymbols(0) must return []' +); +assert.compareArray( + Object.getOwnPropertySymbols(""), [], + 'Object.getOwnPropertySymbols("") must return []' +); +assert.compareArray( + Object.getOwnPropertySymbols(Symbol()), [], + 'Object.getOwnPropertySymbols(Symbol()) must return []' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/not-a-constructor.js new file mode 100644 index 0000000000..c9a4d86680 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/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: > + Object.getOwnPropertySymbols 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, Symbol, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Object.getOwnPropertySymbols), + false, + 'isConstructor(Object.getOwnPropertySymbols) must return false' +); + +assert.throws(TypeError, () => { + new Object.getOwnPropertySymbols({}); +}, '`new Object.getOwnPropertySymbols({})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js new file mode 100644 index 0000000000..87d6e5619e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-with-description.js @@ -0,0 +1,20 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.getownpropertysymbols +description: > + Object.getOwnPropertySymbols returns all symbol properties that have descriptions +features: [Symbol] +---*/ + +var sym = Symbol("description"); + +var obj = {}; +obj[sym] = 1; + +var syms = Object.getOwnPropertySymbols(obj); + +assert.sameValue(syms[0], sym, "Array of symbols returned by `Object.getOwnPropertySymbols(obj)` includes `sym`"); +assert.sameValue(syms.length, 1, "The value of `syms.length` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js new file mode 100644 index 0000000000..7d63d51ad2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/object-contains-symbol-property-without-description.js @@ -0,0 +1,20 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.getownpropertysymbols +description: > + Object.getOwnPropertySymbols returns all symbol properties that do not have descriptions +features: [Symbol] +---*/ + +var sym = Symbol(); + +var obj = {}; +obj[sym] = 1; + +var syms = Object.getOwnPropertySymbols(obj); + +assert.sameValue(syms[0], sym, "Array of symbols returned by `Object.getOwnPropertySymbols(obj)` includes `sym`"); +assert.sameValue(syms.length, 1, "The value of `syms.length` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/order-after-define-property.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/order-after-define-property.js new file mode 100644 index 0000000000..737ec77cdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/order-after-define-property.js @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Property names are returned in ascending chronological order of creation + that is unaffected by [[DefineOwnProperty]]. +info: | + Object.getOwnPropertySymbols ( O ) + + 1. Return ? GetOwnPropertyKeys(O, Symbol). + + GetOwnPropertyKeys ( O, type ) + + 1. Let obj be ? ToObject(O). + 2. Let keys be ? obj.[[OwnPropertyKeys]](). + [...] + + OrdinaryOwnPropertyKeys ( O ) + + [...] + 4. For each own property key P of O that is a Symbol, in ascending + chronological order of property creation, do + a. Add P as the last element of keys. + 5. Return keys. +features: [Symbol] +includes: [compareArray.js] +---*/ + +var symA = Symbol("a"); +var symB = Symbol("b"); + +var obj = {}; +obj[symA] = 1; +obj[symB] = 2; +Object.defineProperty(obj, symA, { + get: function() {}, +}); +assert.compareArray(Object.getOwnPropertySymbols(obj), [symA, symB]); + +var arr = []; +arr[symA] = 1; +arr[symB] = 2; +Object.defineProperty(arr, symA, {writable: false}); +assert.compareArray(Object.getOwnPropertySymbols(arr), [symA, symB]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-absent-not-configurable-string-key.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-absent-not-configurable-string-key.js new file mode 100644 index 0000000000..7c16ab01ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-absent-not-configurable-string-key.js @@ -0,0 +1,55 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Proxy [[OwnPropertyKeys]] trap does not skip string keys when validating invariant: + * The result List must contain the keys of all non-configurable own properties of + the target object. +info: | + Object.getOwnPropertySymbols ( O ) + + 1. Return ? GetOwnPropertyKeys(O, Symbol). + + GetOwnPropertyKeys ( O, type ) + + ... + 2. Let keys be ? obj.[[OwnPropertyKeys]](). + + [[OwnPropertyKeys]] ( ) + + ... + 11. Let targetKeys be ? target.[[OwnPropertyKeys]](). + ... + 15. Let targetNonconfigurableKeys be a new empty List. + 16. For each element key of targetKeys, do + a. Let desc be ? target.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Configurable]] is false, then + i. Append key as an element of targetNonconfigurableKeys. + ... + 18. Let uncheckedResultKeys be a new List which is a copy of trapResult. + 19. For each key that is an element of targetNonconfigurableKeys, do + a. If key is not an element of uncheckedResultKeys, throw a TypeError exception. +features: [Proxy] +---*/ + +var target = {}; +Object.defineProperty(target, 'prop', { + value: 1, + writable: true, + enumerable: true, + configurable: false, +}); + +var proxy = new Proxy(target, { + ownKeys: function() { + return []; + }, +}); + +assert.throws(TypeError, function() { + Object.getOwnPropertySymbols(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-duplicate-string-entry.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-duplicate-string-entry.js new file mode 100644 index 0000000000..7ce3773702 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-duplicate-string-entry.js @@ -0,0 +1,37 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Proxy [[OwnPropertyKeys]] trap does not skip string keys when validating invariant: + * The returned List contains no duplicate entries. +info: | + Object.getOwnPropertySymbols ( O ) + + 1. Return ? GetOwnPropertyKeys(O, Symbol). + + GetOwnPropertyKeys ( O, type ) + + ... + 2. Let keys be ? obj.[[OwnPropertyKeys]](). + + [[OwnPropertyKeys]] ( ) + + ... + 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray, « String, Symbol »). + 9. If trapResult contains any duplicate entries, throw a TypeError exception. +features: [Proxy] +---*/ + +var proxy = new Proxy({}, { + ownKeys: function() { + return ['a', 'a']; + }, +}); + +assert.throws(TypeError, function() { + Object.getOwnPropertySymbols(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-absent-string-key.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-absent-string-key.js new file mode 100644 index 0000000000..5f16121e9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-absent-string-key.js @@ -0,0 +1,51 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Proxy [[OwnPropertyKeys]] trap does not skip string keys when validating invariant: + * If the target object is not extensible, then the result List must contain all the keys of + the own properties of the target object and no other values. +info: | + Object.getOwnPropertySymbols ( O ) + + 1. Return ? GetOwnPropertyKeys(O, Symbol). + + GetOwnPropertyKeys ( O, type ) + + ... + 2. Let keys be ? obj.[[OwnPropertyKeys]](). + + [[OwnPropertyKeys]] ( ) + + ... + 11. Let targetKeys be ? target.[[OwnPropertyKeys]](). + 16. For each element key of targetKeys, do + a. Let desc be ? target.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Configurable]] is false, then + ... + c. Else, + i. Append key as an element of targetConfigurableKeys. + ... + 18. Let uncheckedResultKeys be a new List which is a copy of trapResult. + ... + 21. For each key that is an element of targetConfigurableKeys, do + a. If key is not an element of uncheckedResultKeys, throw a TypeError exception. +features: [Proxy] +---*/ + +var target = {prop: 2}; +var proxy = new Proxy(target, { + ownKeys: function() { + return []; + }, +}); + +Object.preventExtensions(target); + +assert.throws(TypeError, function() { + Object.getOwnPropertySymbols(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-extra-string-key.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-extra-string-key.js new file mode 100644 index 0000000000..233ce34b16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-extra-string-key.js @@ -0,0 +1,50 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertysymbols +description: > + Proxy [[OwnPropertyKeys]] trap does not skip string keys when validating invariant: + * If the target object is not extensible, then the result List must contain all the keys of + the own properties of the target object and no other values. +info: | + Object.getOwnPropertySymbols ( O ) + + 1. Return ? GetOwnPropertyKeys(O, Symbol). + + GetOwnPropertyKeys ( O, type ) + + ... + 2. Let keys be ? obj.[[OwnPropertyKeys]](). + + [[OwnPropertyKeys]] ( ) + + ... + 11. Let targetKeys be ? target.[[OwnPropertyKeys]](). + 16. For each element key of targetKeys, do + a. Let desc be ? target.[[GetOwnProperty]](key). + b. If desc is not undefined and desc.[[Configurable]] is false, then + ... + c. Else, + i. Append key as an element of targetConfigurableKeys. + ... + 18. Let uncheckedResultKeys be a new List which is a copy of trapResult. + ... + 22. If uncheckedResultKeys is not empty, throw a TypeError exception. +features: [Proxy] +---*/ + +var target = {}; +var proxy = new Proxy(target, { + ownKeys: function() { + return ['prop']; + }, +}); + +Object.preventExtensions(target); + +assert.throws(TypeError, function() { + Object.getOwnPropertySymbols(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/shell.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/shell.js |