summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/entries
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Object/entries
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/entries')
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/exception-during-enumeration.js23
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/exception-not-object-coercible.js18
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/function-length.js17
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/function-name.js21
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js15
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/getter-adding-key.js31
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/getter-making-future-key-nonenumerable.js34
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/getter-removing-future-key.js32
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/inherited-properties-omitted.js31
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/observable-operations.js46
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/order-after-define-property-with-function.js40
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/order-after-define-property.js40
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/primitive-booleans.js20
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/primitive-numbers.js17
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/primitive-strings.js22
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/primitive-symbols.js16
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/return-order.js43
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/shell.js33
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/symbols-omitted.js35
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/tamper-with-global-object.js22
-rw-r--r--js/src/tests/test262/built-ins/Object/entries/tamper-with-object-keys.js22
23 files changed, 609 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/entries/browser.js b/js/src/tests/test262/built-ins/Object/entries/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/browser.js
diff --git a/js/src/tests/test262/built-ins/Object/entries/exception-during-enumeration.js b/js/src/tests/test262/built-ins/Object/entries/exception-during-enumeration.js
new file mode 100644
index 0000000000..ae746122f7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/exception-during-enumeration.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries should terminate if getting a value throws an exception
+author: Jordan Harband
+---*/
+
+var trappedKey = {
+ get a() {
+ throw new RangeError('This error should be re-thrown');
+ },
+ get b() {
+ throw new Test262Error('Should not try to get the second element');
+ }
+};
+
+assert.throws(RangeError, function() {
+ Object.entries(trappedKey);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/exception-not-object-coercible.js b/js/src/tests/test262/built-ins/Object/entries/exception-not-object-coercible.js
new file mode 100644
index 0000000000..6efcfa500c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/exception-not-object-coercible.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries should fail if given a null or undefined value
+author: Jordan Harband
+---*/
+
+assert.throws(TypeError, function() {
+ Object.entries(null);
+});
+
+assert.throws(TypeError, function() {
+ Object.entries(undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/function-length.js b/js/src/tests/test262/built-ins/Object/entries/function-length.js
new file mode 100644
index 0000000000..6510ac12b6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/function-length.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries should have length 1
+author: Jordan Harband
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Object.entries.length, 1, 'Expected Object.entries.length to be 1');
+
+verifyNotEnumerable(Object.entries, 'length');
+verifyNotWritable(Object.entries, 'length');
+verifyConfigurable(Object.entries, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/function-name.js b/js/src/tests/test262/built-ins/Object/entries/function-name.js
new file mode 100644
index 0000000000..ddc50048d8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/function-name.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries should have name property with value 'entries'
+author: Jordan Harband
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ Object.entries.name,
+ 'entries',
+ 'Expected Object.entries.name to be "entries"'
+);
+
+verifyNotEnumerable(Object.entries, 'name');
+verifyNotWritable(Object.entries, 'name');
+verifyConfigurable(Object.entries, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js b/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js
new file mode 100644
index 0000000000..a1ed98ba44
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries should be writable, non-enumerable, and configurable
+author: Jordan Harband
+includes: [propertyHelper.js]
+---*/
+
+verifyNotEnumerable(Object, 'entries');
+verifyWritable(Object, 'entries');
+verifyConfigurable(Object, 'entries');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/getter-adding-key.js b/js/src/tests/test262/built-ins/Object/entries/getter-adding-key.js
new file mode 100644
index 0000000000..0da05996f8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/getter-adding-key.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries does not see a new element added by a getter that is hit during iteration
+author: Jordan Harband
+---*/
+
+var bAddsC = {
+ a: 'A',
+ get b() {
+ this.c = 'C';
+ return 'B';
+ }
+};
+
+var result = Object.entries(bAddsC);
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 2, 'result has 2 items');
+
+assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array');
+assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array');
+
+assert.sameValue(result[0][0], 'a', 'first entry has key "a"');
+assert.sameValue(result[0][1], 'A', 'first entry has value "A"');
+assert.sameValue(result[1][0], 'b', 'second entry has key "b"');
+assert.sameValue(result[1][1], 'B', 'second entry has value "B"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/getter-making-future-key-nonenumerable.js b/js/src/tests/test262/built-ins/Object/entries/getter-making-future-key-nonenumerable.js
new file mode 100644
index 0000000000..0438bfbc05
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/getter-making-future-key-nonenumerable.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries does not see an element made non-enumerable by a getter that is hit during iteration
+author: Jordan Harband
+---*/
+
+var bDeletesC = {
+ a: 'A',
+ get b() {
+ Object.defineProperty(this, 'c', {
+ enumerable: false
+ });
+ return 'B';
+ },
+ c: 'C'
+};
+
+var result = Object.entries(bDeletesC);
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 2, 'result has 2 items');
+
+assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array');
+assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array');
+
+assert.sameValue(result[0][0], 'a', 'first entry has key "a"');
+assert.sameValue(result[0][1], 'A', 'first entry has value "A"');
+assert.sameValue(result[1][0], 'b', 'second entry has key "b"');
+assert.sameValue(result[1][1], 'B', 'second entry has value "B"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/getter-removing-future-key.js b/js/src/tests/test262/built-ins/Object/entries/getter-removing-future-key.js
new file mode 100644
index 0000000000..71ecc6cb67
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/getter-removing-future-key.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries does not see an element removed by a getter that is hit during iteration
+author: Jordan Harband
+---*/
+
+var bDeletesC = {
+ a: 'A',
+ get b() {
+ delete this.c;
+ return 'B';
+ },
+ c: 'C'
+};
+
+var result = Object.entries(bDeletesC);
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 2, 'result has 2 items');
+
+assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array');
+assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array');
+
+assert.sameValue(result[0][0], 'a', 'first entry has key "a"');
+assert.sameValue(result[0][1], 'A', 'first entry has value "A"');
+assert.sameValue(result[1][0], 'b', 'second entry has key "b"');
+assert.sameValue(result[1][1], 'B', 'second entry has value "B"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/inherited-properties-omitted.js b/js/src/tests/test262/built-ins/Object/entries/inherited-properties-omitted.js
new file mode 100644
index 0000000000..1a609f9899
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/inherited-properties-omitted.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries does not see inherited properties.
+author: Jordan Harband
+---*/
+
+var F = function G() {};
+F.prototype.a = {};
+F.prototype.b = {};
+
+var f = new F();
+f.b = {}; // shadow the prototype
+f.c = {}; // solely an own property
+
+var result = Object.entries(f);
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 2, 'result has 2 items');
+
+assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array');
+assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array');
+
+assert.sameValue(result[0][0], 'b', 'first entry has key "b"');
+assert.sameValue(result[0][1], f.b, 'first entry has value f.b');
+assert.sameValue(result[1][0], 'c', 'second entry has key "c"');
+assert.sameValue(result[1][1], f.c, 'second entry has value f.c');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js
new file mode 100644
index 0000000000..cab5f1d2e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js
@@ -0,0 +1,31 @@
+// 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.entries 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, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Object.entries), false, 'isConstructor(Object.entries) must return false');
+
+assert.throws(TypeError, () => {
+ new Object.entries({});
+}, '`new Object.entries({})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/observable-operations.js b/js/src/tests/test262/built-ins/Object/entries/observable-operations.js
new file mode 100644
index 0000000000..bf7ad86bf6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/observable-operations.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries should perform observable operations in the correct order
+author: Jordan Harband
+features: [Proxy]
+includes: [proxyTrapsHelper.js]
+---*/
+
+var log = "";
+var object = {
+ a: 0,
+ b: 0,
+ c: 0
+};
+var handler = allowProxyTraps({
+ get: function(target, propertyKey, receiver) {
+ assert.sameValue(target, object, "get target");
+ assert.sameValue(receiver, proxy, "get receiver");
+ log += "|get:" + propertyKey;
+ return target[propertyKey];
+ },
+ getOwnPropertyDescriptor: function(target, propertyKey) {
+ assert.sameValue(target, object, "getOwnPropertyDescriptor");
+ log += "|getOwnPropertyDescriptor:" + propertyKey;
+ return Object.getOwnPropertyDescriptor(target, propertyKey);
+ },
+ ownKeys: function(target) {
+ assert.sameValue(target, object, "ownKeys");
+ log += "|ownKeys";
+ return Object.getOwnPropertyNames(target);
+ }
+});
+var check = allowProxyTraps({
+ get: function(target, propertyKey, receiver) {
+ assert(propertyKey in target, "handler check: " + propertyKey);
+ return target[propertyKey];
+ }
+});
+var proxy = new Proxy(object, new Proxy(handler, check));
+var result = Object.entries(proxy);
+assert.sameValue(log, "|ownKeys|getOwnPropertyDescriptor:a|get:a|getOwnPropertyDescriptor:b|get:b|getOwnPropertyDescriptor:c|get:c", log);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/order-after-define-property-with-function.js b/js/src/tests/test262/built-ins/Object/entries/order-after-define-property-with-function.js
new file mode 100644
index 0000000000..f7e40bc7c3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/order-after-define-property-with-function.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: >
+ Property names are returned in ascending chronological order of creation
+ that is unaffected by [[DefineOwnProperty]].
+info: |
+ Object.entries ( O )
+
+ [...]
+ 2. Let nameList be ? EnumerableOwnPropertyNames(obj, key+value).
+ 3. Return CreateArrayFromList(nameList).
+
+ EnumerableOwnPropertyNames ( O, kind )
+
+ [...]
+ 2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
+ [...]
+
+ OrdinaryOwnPropertyKeys ( O )
+
+ [...]
+ 3. For each own property key P of O that is a String but is not an array index,
+ in ascending chronological order of property creation, do
+ a. Add P as the last element of keys.
+ [...]
+ 5. Return keys.
+features: [arrow-function]
+includes: [compareArray.js]
+---*/
+
+var fn = () => {};
+fn.a = 1;
+Object.defineProperty(fn, "name", {enumerable: true});
+var fnKeys = Object.entries(fn).map(e => e[0]);
+assert.compareArray(fnKeys, ["name", "a"]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/order-after-define-property.js b/js/src/tests/test262/built-ins/Object/entries/order-after-define-property.js
new file mode 100644
index 0000000000..e36e8f2df0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/order-after-define-property.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: >
+ Property names are returned in ascending chronological order of creation
+ that is unaffected by [[DefineOwnProperty]].
+info: |
+ Object.entries ( O )
+
+ [...]
+ 2. Let nameList be ? EnumerableOwnPropertyNames(obj, key+value).
+ 3. Return CreateArrayFromList(nameList).
+
+ EnumerableOwnPropertyNames ( O, kind )
+
+ [...]
+ 2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
+ [...]
+
+ OrdinaryOwnPropertyKeys ( O )
+
+ [...]
+ 3. For each own property key P of O that is a String but is not an array index,
+ in ascending chronological order of property creation, do
+ a. Add P as the last element of keys.
+ [...]
+ 5. Return keys.
+includes: [compareArray.js]
+---*/
+
+var obj = {};
+obj.a = 1;
+obj.b = 2;
+Object.defineProperty(obj, "a", {writable: false});
+var objKeys = Object.entries(obj).map(e => e[0]);
+assert.compareArray(objKeys, ["a", "b"]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/primitive-booleans.js b/js/src/tests/test262/built-ins/Object/entries/primitive-booleans.js
new file mode 100644
index 0000000000..c1e74354bf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/primitive-booleans.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries accepts boolean primitives.
+author: Jordan Harband
+---*/
+
+var trueResult = Object.entries(true);
+
+assert.sameValue(Array.isArray(trueResult), true, 'trueResult is an array');
+assert.sameValue(trueResult.length, 0, 'trueResult has 0 items');
+
+var falseResult = Object.entries(false);
+
+assert.sameValue(Array.isArray(falseResult), true, 'falseResult is an array');
+assert.sameValue(falseResult.length, 0, 'falseResult has 0 items');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/primitive-numbers.js b/js/src/tests/test262/built-ins/Object/entries/primitive-numbers.js
new file mode 100644
index 0000000000..651d23436a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/primitive-numbers.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries accepts number primitives.
+author: Jordan Harband
+---*/
+
+assert.sameValue(Object.entries(0).length, 0, '0 has zero entries');
+assert.sameValue(Object.entries(-0).length, 0, '-0 has zero entries');
+assert.sameValue(Object.entries(Infinity).length, 0, 'Infinity has zero entries');
+assert.sameValue(Object.entries(-Infinity).length, 0, '-Infinity has zero entries');
+assert.sameValue(Object.entries(NaN).length, 0, 'NaN has zero entries');
+assert.sameValue(Object.entries(Math.PI).length, 0, 'Math.PI has zero entries');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/primitive-strings.js b/js/src/tests/test262/built-ins/Object/entries/primitive-strings.js
new file mode 100644
index 0000000000..4368581531
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/primitive-strings.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries accepts string primitives.
+author: Jordan Harband
+---*/
+
+var result = Object.entries('abc');
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 3, 'result has 3 items');
+
+assert.sameValue(result[0][0], '0', 'first entry has key "0"');
+assert.sameValue(result[0][1], 'a', 'first entry has value "a"');
+assert.sameValue(result[1][0], '1', 'second entry has key "1"');
+assert.sameValue(result[1][1], 'b', 'second entry has value "b"');
+assert.sameValue(result[2][0], '2', 'third entry has key "2"');
+assert.sameValue(result[2][1], 'c', 'third entry has value "c"');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/primitive-symbols.js b/js/src/tests/test262/built-ins/Object/entries/primitive-symbols.js
new file mode 100644
index 0000000000..975fed35c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/primitive-symbols.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries accepts Symbol primitives.
+author: Jordan Harband
+features: [Symbol]
+---*/
+
+var result = Object.entries(Symbol());
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 0, 'result has 0 items');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/return-order.js b/js/src/tests/test262/built-ins/Object/entries/return-order.js
new file mode 100644
index 0000000000..a52ef36b0e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/return-order.js
@@ -0,0 +1,43 @@
+// Copyright 2019 Kevin Gibbons. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries enumeration order
+features: [for-in-order]
+includes: [compareArray.js]
+---*/
+
+var o = {
+ p1: 'p1',
+ p2: 'p2',
+ p3: 'p3',
+};
+
+// This getter will be triggered during enumeration, but the property it adds should not be enumerated.
+Object.defineProperty(o, 'add', {
+ enumerable: true,
+ get: function () {
+ o.extra = 'extra';
+ return 'add';
+ }
+});
+
+o.p4 = 'p4';
+
+o[2] = '2';
+o[0] = '0';
+o[1] = '1';
+
+delete o.p1;
+delete o.p3;
+o.p1 = 'p1';
+
+
+var actual = Object.entries(o).map(function(e) { return e[0]; });
+
+var expected = ['0', '1', '2', 'p2', 'add', 'p4', 'p1'];
+
+assert.compareArray(actual, expected);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/shell.js b/js/src/tests/test262/built-ins/Object/entries/shell.js
new file mode 100644
index 0000000000..bc72493f03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/shell.js
@@ -0,0 +1,33 @@
+// GENERATED, DO NOT EDIT
+// file: proxyTrapsHelper.js
+// Copyright (C) 2016 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Used to assert the correctness of object behavior in the presence
+ and context of Proxy objects.
+defines: [allowProxyTraps]
+---*/
+
+function allowProxyTraps(overrides) {
+ function throwTest262Error(msg) {
+ return function () { throw new Test262Error(msg); };
+ }
+ if (!overrides) { overrides = {}; }
+ return {
+ getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'),
+ setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'),
+ isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'),
+ preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'),
+ getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'),
+ has: overrides.has || throwTest262Error('[[HasProperty]] trap called'),
+ get: overrides.get || throwTest262Error('[[Get]] trap called'),
+ set: overrides.set || throwTest262Error('[[Set]] trap called'),
+ deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'),
+ defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'),
+ enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'),
+ ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'),
+ apply: overrides.apply || throwTest262Error('[[Call]] trap called'),
+ construct: overrides.construct || throwTest262Error('[[Construct]] trap called')
+ };
+}
diff --git a/js/src/tests/test262/built-ins/Object/entries/symbols-omitted.js b/js/src/tests/test262/built-ins/Object/entries/symbols-omitted.js
new file mode 100644
index 0000000000..b69feeff35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/symbols-omitted.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: Object.entries does not include Symbol keys.
+author: Jordan Harband
+features: [Symbol]
+---*/
+
+var value = {};
+var enumSym = Symbol('enum');
+var nonEnumSym = Symbol('nonenum');
+var symValue = Symbol('value');
+
+var obj = {
+ key: symValue
+};
+obj[enumSym] = value;
+Object.defineProperty(obj, nonEnumSym, {
+ enumerable: false,
+ value: value
+});
+
+var result = Object.entries(obj);
+
+assert.sameValue(Array.isArray(result), true, 'result is an array');
+assert.sameValue(result.length, 1, 'result has 1 item');
+
+assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array');
+
+assert.sameValue(result[0][0], 'key', 'first entry has key "key"');
+assert.sameValue(result[0][1], symValue, 'first entry has value `symValue`');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/tamper-with-global-object.js b/js/src/tests/test262/built-ins/Object/entries/tamper-with-global-object.js
new file mode 100644
index 0000000000..150a4bf754
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/tamper-with-global-object.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: >
+ Object.entries should not have its behavior impacted by modifications to the global property Object
+author: Jordan Harband
+---*/
+
+function fakeObject() {
+ throw new Test262Error('The overriden version of Object was called!');
+}
+fakeObject.entries = Object.entries;
+
+var global = Function('return this;')();
+global.Object = fakeObject;
+
+assert.sameValue(Object, fakeObject, 'Sanity check failed: could not modify the global Object');
+assert.sameValue(Object.entries(1).length, 0, 'Expected number primitive to have zero entries');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Object/entries/tamper-with-object-keys.js b/js/src/tests/test262/built-ins/Object/entries/tamper-with-object-keys.js
new file mode 100644
index 0000000000..31dc24ee57
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/entries/tamper-with-object-keys.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-object.entries
+description: >
+ Object.entries should not have its behavior impacted by modifications to Object.keys
+author: Jordan Harband
+---*/
+
+function fakeObjectKeys() {
+ throw new Test262Error('The overriden version of Object.keys was called!');
+}
+
+Object.keys = fakeObjectKeys;
+
+assert.sameValue(Object.keys, fakeObjectKeys, 'Sanity check failed: could not modify the global Object.keys');
+assert.sameValue(Object.entries({
+ a: 1
+}).length, 1, 'Expected object with 1 key to have 1 entry');
+
+reportCompare(0, 0);