From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../Object/getOwnPropertyNames/15.2.3.4-0-1.js | 11 +++++ .../Object/getOwnPropertyNames/15.2.3.4-0-2.js | 13 +++++ .../Object/getOwnPropertyNames/15.2.3.4-1-2.js | 14 ++++++ .../Object/getOwnPropertyNames/15.2.3.4-1-3.js | 14 ++++++ .../Object/getOwnPropertyNames/15.2.3.4-1-4.js | 13 +++++ .../Object/getOwnPropertyNames/15.2.3.4-1-5.js | 13 +++++ .../Object/getOwnPropertyNames/15.2.3.4-1.js | 13 +++++ .../Object/getOwnPropertyNames/15.2.3.4-2-1.js | 16 +++++++ .../Object/getOwnPropertyNames/15.2.3.4-2-2.js | 14 ++++++ .../Object/getOwnPropertyNames/15.2.3.4-2-3.js | 16 +++++++ .../Object/getOwnPropertyNames/15.2.3.4-2-4.js | 22 +++++++++ .../Object/getOwnPropertyNames/15.2.3.4-3-1.js | 20 ++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-1.js | 21 ++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-2.js | 27 +++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-36.js | 26 ++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-37.js | 30 ++++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-38.js | 19 ++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-39.js | 23 +++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-40.js | 21 ++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-41.js | 26 ++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-42.js | 31 ++++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-43.js | 33 +++++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-44.js | 17 +++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-45.js | 21 ++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-46.js | 26 ++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-47.js | 27 +++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-48.js | 33 +++++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-49.js | 15 ++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-50.js | 23 +++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-b-1.js | 21 ++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-b-2.js | 40 ++++++++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-b-3.js | 28 +++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-b-4.js | 24 ++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-b-5.js | 28 +++++++++++ .../Object/getOwnPropertyNames/15.2.3.4-4-b-6.js | 24 ++++++++++ .../Object/getOwnPropertyNames/S15.2.3.4_A1_T1.js | 22 +++++++++ .../Object/getOwnPropertyNames/browser.js | 0 .../built-ins/Object/getOwnPropertyNames/name.js | 28 +++++++++++ .../non-object-argument-invalid.js | 35 ++++++++++++++ .../non-object-argument-valid.js | 47 ++++++++++++++++++ .../getOwnPropertyNames/not-a-constructor.js | 35 ++++++++++++++ .../order-after-define-property.js | 50 +++++++++++++++++++ ...invariant-absent-not-configurable-symbol-key.js | 56 ++++++++++++++++++++++ .../proxy-invariant-duplicate-symbol-entry.js | 38 +++++++++++++++ ...y-invariant-not-extensible-absent-symbol-key.js | 54 +++++++++++++++++++++ ...xy-invariant-not-extensible-extra-symbol-key.js | 51 ++++++++++++++++++++ .../built-ins/Object/getOwnPropertyNames/shell.js | 0 47 files changed, 1179 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-2.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-2.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-3.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-4.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-5.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-2.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-3.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-4.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-3-1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-2.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-36.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-37.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-38.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-39.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-40.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-41.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-42.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-43.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-44.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-45.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-46.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-47.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-48.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-49.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-50.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-2.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-3.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-4.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-5.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-6.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/S15.2.3.4_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/browser.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/non-object-argument-invalid.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/non-object-argument-valid.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/order-after-define-property.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-absent-not-configurable-symbol-key.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-duplicate-symbol-entry.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-absent-symbol-key.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-extra-symbol-key.js create mode 100644 js/src/tests/test262/built-ins/Object/getOwnPropertyNames/shell.js (limited to 'js/src/tests/test262/built-ins/Object/getOwnPropertyNames') diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-1.js new file mode 100644 index 0000000000..39afec9007 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-1.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-0-1 +description: Object.getOwnPropertyNames must exist as a function +---*/ + +assert.sameValue(typeof(Object.getOwnPropertyNames), "function", 'typeof(Object.getOwnPropertyNames)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-2.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-2.js new file mode 100644 index 0000000000..a3c2840381 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-0-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-0-2 +description: > + Object.getOwnPropertyNames must exist as a function taking 1 + parameter +---*/ + +assert.sameValue(Object.getOwnPropertyNames.length, 1, 'Object.getOwnPropertyNames.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-2.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-2.js new file mode 100644 index 0000000000..8a55376ed4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-1-2 +description: Object.getOwnPropertyNames throws TypeError if 'O' is undefined +---*/ + + +assert.throws(TypeError, function() { + Object.getOwnPropertyNames(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-3.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-3.js new file mode 100644 index 0000000000..6b4a1410a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-1-3 +description: Object.getOwnPropertyNames throws TypeError if 'O' is null +---*/ + + +assert.throws(TypeError, function() { + Object.getOwnPropertyNames(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-4.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-4.js new file mode 100644 index 0000000000..d56ea4b702 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-1-4 +description: > + Object.getOwnPropertyNames does not throw TypeError if 'O' is a + boolean +---*/ + +Object.getOwnPropertyNames(true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-5.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-5.js new file mode 100644 index 0000000000..f830ebe3e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1-5.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-1-5 +description: > + Object.getOwnPropertyNames does not throw TypeError if 'O' is a + string +---*/ + +Object.getOwnPropertyNames("abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1.js new file mode 100644 index 0000000000..7da9dbbaba --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-1 +description: > + Object.getOwnPropertyNames does not throw TypeError if type of + first param is not Object +---*/ + +Object.getOwnPropertyNames(0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-1.js new file mode 100644 index 0000000000..3e1bf71ffa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-2-1 +description: > + Object.getOwnPropertyNames - returned array is an array according + to Array.isArray +---*/ + +var obj = {}; +var result = Object.getOwnPropertyNames(obj); + +assert(Array.isArray(result), 'Array.isArray(result) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-2.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-2.js new file mode 100644 index 0000000000..18ad55b732 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-2-2 +description: Object.getOwnPropertyNames - returned array is an instance of Array +---*/ + +var obj = {}; +var result = Object.getOwnPropertyNames(obj); + +assert(result instanceof Array, 'result instanceof Array !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-3.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-3.js new file mode 100644 index 0000000000..b47f219245 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-3.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-2-3 +description: > + Object.getOwnPropertyNames - length of returned array is + initialized to 0 +---*/ + +var obj = {}; +var result = Object.getOwnPropertyNames(obj); + +assert.sameValue(result.length, 0, 'result.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-4.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-4.js new file mode 100644 index 0000000000..5b1c233efa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-2-4.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-2-4 +description: > + Object.getOwnPropertyNames - returned array is the standard + built-in constructor +---*/ + +var oldArray = Array; +Array = function() { + throw new Error("invoke customer defined Array!"); +}; + +var obj = {}; + +var result = Object.getOwnPropertyNames(obj); + +assert.sameValue(Object.prototype.toString.call(result), "[object Array]", 'Object.prototype.toString.call(result)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-3-1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-3-1.js new file mode 100644 index 0000000000..7e6f562502 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-3-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-3-1 +description: > + Object.getOwnPropertyNames - elements of the returned array start + from index 0 +---*/ + +var obj = { + prop1: 1001 +}; + +var arr = Object.getOwnPropertyNames(obj); + +assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true'); +assert.sameValue(arr[0], "prop1", 'arr[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-1.js new file mode 100644 index 0000000000..a0a57a3728 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-1.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-1 +description: Object.getOwnPropertyNames returns array of property names (Global) +---*/ + +var result = Object.getOwnPropertyNames(this); +var expResult = ["NaN", "Infinity", "undefined", "eval", "parseInt", "parseFloat", "isNaN", "isFinite", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "Object", "Function", "Array", "String", "Boolean", "Number", "Date", "Date", "RegExp", "Error", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "Math", "JSON"]; + +var result1 = {}; +for (var p in result) { + result1[result[p]] = true; +} + +for (var p1 in expResult) { + assert(result1[expResult[p1]], 'result1[expResult[p1]] !== true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-2.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-2.js new file mode 100644 index 0000000000..2870645c46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-2.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-2 +description: Object.getOwnPropertyNames returns array of property names (Object) +---*/ + +var result = Object.getOwnPropertyNames(Object); + +assert(result.indexOf("getPrototypeOf") > -1, "getPrototypeOf"); +assert(result.indexOf("getOwnPropertyDescriptor") > -1, "getOwnPropertyDescriptor"); +assert(result.indexOf("getOwnPropertyNames") > -1, "getOwnPropertyNames"); +assert(result.indexOf("create") > -1, "create"); +assert(result.indexOf("defineProperty") > -1, "defineProperty"); +assert(result.indexOf("defineProperties") > -1, "defineProperties"); +assert(result.indexOf("seal") > -1, "seal"); +assert(result.indexOf("freeze") > -1, "freeze"); +assert(result.indexOf("preventExtensions") > -1, "preventExtensions"); +assert(result.indexOf("isSealed") > -1, "isSealed"); +assert(result.indexOf("isFrozen") > -1, "isFrozen"); +assert(result.indexOf("isExtensible") > -1, "isExtensible"); +assert(result.indexOf("keys") > -1, "keys"); +assert(result.indexOf("prototype") > -1, "prototype"); +assert(result.indexOf("length") > -1, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-36.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-36.js new file mode 100644 index 0000000000..d93719c7ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-36.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-36 +description: > + Object.getOwnPropertyNames - inherited data properties are not + pushed into the returned array +---*/ + +var proto = { + "parent": "parent" +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +var result = Object.getOwnPropertyNames(child); + +for (var p in result) { + assert.notSameValue(result[p], "parent", 'result[p]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-37.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-37.js new file mode 100644 index 0000000000..a5901e3f26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-37.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-37 +description: > + Object.getOwnPropertyNames - inherited accessor properties are not + pushed into the returned array +---*/ + +var proto = {}; +Object.defineProperty(proto, "parent", { + get: function() { + return "parent"; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +var result = Object.getOwnPropertyNames(child); + +for (var p in result) { + assert.notSameValue(result[p], "parent", 'result[p]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-38.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-38.js new file mode 100644 index 0000000000..de2274173f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-38.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-38 +description: > + Object.getOwnPropertyNames - own data properties are pushed into + the returned array +---*/ + +var obj = { + "a": "a" +}; + +var result = Object.getOwnPropertyNames(obj); + +assert.sameValue(result[0], "a", 'result[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-39.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-39.js new file mode 100644 index 0000000000..681b07a3da --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-39.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-39 +description: > + Object.getOwnPropertyNames - own accessor properties are pushed + into the returned array +---*/ + +var obj = {}; +Object.defineProperty(obj, "a", { + get: function() { + return "a"; + }, + configurable: true +}); + +var result = Object.getOwnPropertyNames(obj); + +assert.sameValue(result[0], "a", 'result[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-40.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-40.js new file mode 100644 index 0000000000..c57effcf8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-40.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-40 +description: > + Object.getOwnPropertyNames - inherited data property of String + object 'O' is not pushed into the returned array +---*/ + +var str = new String("abc"); + +String.prototype.protoProperty = "protoString"; + +var result = Object.getOwnPropertyNames(str); + +for (var p in result) { + assert.notSameValue(result[p], "protoProperty", 'result[p]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-41.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-41.js new file mode 100644 index 0000000000..bb0c8fb0d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-41.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-41 +description: > + Object.getOwnPropertyNames - inherited accessor property of String + object 'O' is not pushed into the returned array +---*/ + +var str = new String("abc"); + +Object.defineProperty(String.prototype, "protoProperty", { + get: function() { + return "protoString"; + }, + configurable: true +}); + +var result = Object.getOwnPropertyNames(str); + +for (var p in result) { + assert.notSameValue(result[p], "protoProperty", 'result[p]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-42.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-42.js new file mode 100644 index 0000000000..c89f56d2f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-42.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-42 +description: > + Object.getOwnPropertyNames - own data property of String object + 'O' is pushed into the returned array +---*/ + +var propertyFound = false; + +var str = new String("abc"); + +Object.defineProperty(str, "ownProperty", { + value: "ownString", + configurable: true +}); + +var result = Object.getOwnPropertyNames(str); + +for (var p in result) { + if (result[p] === "ownProperty") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-43.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-43.js new file mode 100644 index 0000000000..81354318e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-43.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-43 +description: > + Object.getOwnPropertyNames - own accessor property of String + object 'O' is pushed into the returned array +---*/ + +var propertyFound = false; + +var str = new String("abc"); + +Object.defineProperty(str, "ownProperty", { + get: function() { + return "ownString"; + }, + configurable: true +}); + +var result = Object.getOwnPropertyNames(str); + +for (var p in result) { + if (result[p] === "ownProperty") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-44.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-44.js new file mode 100644 index 0000000000..5aaccf652c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-44.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-44 +description: > + Object.getOwnPropertyNames - own index properties of String object + are pushed into the returned Array +includes: [compareArray.js] +---*/ + +var str = new String("abc"); +str[5] = "de"; + +assert.compareArray(Object.getOwnPropertyNames(str), ["0", "1", "2", "5", "length"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-45.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-45.js new file mode 100644 index 0000000000..44f7db4b82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-45.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-45 +description: > + Object.getOwnPropertyNames - inherited data property of Array + object 'O' is not pushed into the returned array. +---*/ + +var arr = [0, 1, 2]; + +Array.prototype.protoProperty = "protoArray"; + +var result = Object.getOwnPropertyNames(arr); + +for (var p in result) { + assert.notSameValue(result[p], "protoProperty", 'result[p]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-46.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-46.js new file mode 100644 index 0000000000..6cf340270a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-46.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-46 +description: > + Object.getOwnPropertyNames - inherited accessor property of Array + object 'O' is not pushed into the returned array. +---*/ + +var arr = [0, 1, 2]; + +Object.defineProperty(Array.prototype, "protoProperty", { + get: function() { + return "protoArray"; + }, + configurable: true +}); + +var result = Object.getOwnPropertyNames(arr); + +for (var p in result) { + assert.notSameValue(result[p], "protoProperty", 'result[p]'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-47.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-47.js new file mode 100644 index 0000000000..26c2b53a98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-47.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-47 +description: > + Object.getOwnPropertyNames - own data property of Array object 'O' + is pushed into the returned array +---*/ + +var propertyFound = false; + +var arr = [0, 1, 2]; +arr.ownProperty = "ownArray"; + +var result = Object.getOwnPropertyNames(arr); + +for (var p in result) { + if (result[p] === "ownProperty") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-48.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-48.js new file mode 100644 index 0000000000..d2a9542b25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-48.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-48 +description: > + Object.getOwnPropertyNames - own accessor property of Array object + 'O' is pushed into the returned array. +---*/ + +var propertyFound = false; + +var arr = [0, 1, 2]; + +Object.defineProperty(arr, "ownProperty", { + get: function() { + return "ownArray"; + }, + configurable: true +}); + +var result = Object.getOwnPropertyNames(arr); + +for (var p in result) { + if (result[p] === "ownProperty") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-49.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-49.js new file mode 100644 index 0000000000..d8f23995c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-49.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-49 +description: > + Object.getOwnPropertyNames - own index properties of Array objcect + are pushed into the returned Array +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +assert.compareArray(Object.getOwnPropertyNames(arr), ["0", "1", "2", "length"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-50.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-50.js new file mode 100644 index 0000000000..e410daee67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-50.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-50 +description: > + Object.getOwnPropertyNames - non-enumerable own property of 'O' is + pushed into the returned Array +---*/ + +var obj = {}; + +Object.defineProperty(obj, "nonEnumerableProp", { + value: 10, + enumerable: false, + configurable: true +}); + +var result = Object.getOwnPropertyNames(obj); + +assert.sameValue(result[0], "nonEnumerableProp", 'result[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-1.js new file mode 100644 index 0000000000..c75480cbfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-1.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-b-1 +description: > + Object.getOwnPropertyNames - descriptor of resultant array is all + true +---*/ + +var obj = new Object(); +obj.x = 1; +obj.y = 2; +var result = Object.getOwnPropertyNames(obj); +var desc = Object.getOwnPropertyDescriptor(result, "0"); + +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(desc.writable, true, 'desc.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-2.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-2.js new file mode 100644 index 0000000000..4317af80fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-2.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-b-2 +description: > + Object.getOwnPropertyNames - all own properties are pushed into + the returned array +includes: [compareArray.js] +---*/ + +var obj = { + "a": "a" +}; + +Object.defineProperty(obj, "b", { + get: function() { + return "b"; + }, + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "c", { + get: function() { + return "c"; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "d", { + value: "d", + enumerable: false, + configurable: true +}); + +assert.compareArray(Object.getOwnPropertyNames(obj), ["a", "b", "c", "d"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-3.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-3.js new file mode 100644 index 0000000000..d03ba0945a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-3.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-b-3 +description: > + Object.getOwnPropertyNames - own property named empty('') is + pushed into the returned array +---*/ + +var propertyFound = false; + +var obj = { + "": "empty" +}; + +var result = Object.getOwnPropertyNames(obj); + +for (var p in result) { + if (result[p] === "") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-4.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-4.js new file mode 100644 index 0000000000..237dd11959 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-b-4 +description: > + Object.getOwnPropertyNames - elements of the returned array are + writable +---*/ + +var obj = { + "a": "a" +}; + +var result = Object.getOwnPropertyNames(obj); + +var beforeOverride = (result[0] === "a"); +result[0] = "b"; +var afterOverride = (result[0] === "b"); + +assert(beforeOverride, 'beforeOverride !== true'); +assert(afterOverride, 'afterOverride !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-5.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-5.js new file mode 100644 index 0000000000..e7931c5940 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-5.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-b-5 +description: > + Object.getOwnPropertyNames - elements of the returned array are + enumerable +---*/ + +var propertyFound = false; + +var obj = { + "a": "a" +}; + +var result = Object.getOwnPropertyNames(obj); + +for (var p in result) { + if (result[p] === "a") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-6.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-6.js new file mode 100644 index 0000000000..c958718539 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.4-4-b-6 +description: > + Object.getOwnPropertyNames - elements of the returned array are + configurable +---*/ + +var obj = { + "a": "a" +}; + +var result = Object.getOwnPropertyNames(obj); + +var beforeDeleted = (result.hasOwnProperty("0")); +delete result[0]; +var afterDeleted = (result.hasOwnProperty("0")); + +assert(beforeDeleted, 'beforeDeleted !== true'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/S15.2.3.4_A1_T1.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/S15.2.3.4_A1_T1.js new file mode 100644 index 0000000000..c683929cbb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/S15.2.3.4_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2011 Google, Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Object.getOwnProperties and Object.prototype.hasOwnProperty should + agree on what the own properties are. +es5id: 15.2.3.4_A1_T1 +description: > + Check that all the own property names reported by + Object.getOwnPropertyNames on a strict function are names that + hasOwnProperty agrees are own properties. +---*/ + +function foo() {} + +var names = Object.getOwnPropertyNames(foo); +for (var i = 0, len = names.length; i < len; i++) { + assert(!!foo.hasOwnProperty(names[i]), 'The value of !!foo.hasOwnProperty(names[i]) is expected to be true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/browser.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js new file mode 100644 index 0000000000..9ed3603700 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/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. + +/*--- +es6id: 19.1.2.7 +description: > + Object.getOwnPropertyNames.name is "getOwnPropertyNames". +info: | + Object.getOwnPropertyNames ( 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.getOwnPropertyNames.name, "getOwnPropertyNames"); + +verifyNotEnumerable(Object.getOwnPropertyNames, "name"); +verifyNotWritable(Object.getOwnPropertyNames, "name"); +verifyConfigurable(Object.getOwnPropertyNames, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/non-object-argument-invalid.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/non-object-argument-invalid.js new file mode 100644 index 0000000000..9f31f06545 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/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.getownpropertynames +description: > + Object.getOwnPropertyNames 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.getOwnPropertyNames(undefined); +}, '`Object.getOwnPropertyNames(undefined)` throws TypeError'); + +assert.throws(TypeError, () => { + count++; + Object.getOwnPropertyNames(null); +}, '`Object.getOwnPropertyNames(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/getOwnPropertyNames/non-object-argument-valid.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/non-object-argument-valid.js new file mode 100644 index 0000000000..93e8001262 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/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.getownpropertynames +description: > + Object.getOwnPropertyNames 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.getOwnPropertyNames(true), [], + 'Object.getOwnPropertyNames(true) must return []' +); +assert.compareArray( + Object.getOwnPropertyNames(false), [], + 'Object.getOwnPropertyNames(false) must return []' +); +assert.compareArray( + Object.getOwnPropertyNames(1), [], + 'Object.getOwnPropertyNames(1) must return []' +); +assert.compareArray( + Object.getOwnPropertyNames(0), [], + 'Object.getOwnPropertyNames(0) must return []' +); +assert.compareArray( + Object.getOwnPropertyNames(""), ["length"], + 'Object.getOwnPropertyNames("") must return ["length"]' +); +assert.compareArray( + Object.getOwnPropertyNames(Symbol()), [], + 'Object.getOwnPropertyNames(Symbol()) must return []' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js new file mode 100644 index 0000000000..70a205d5a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/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.getOwnPropertyNames 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.getOwnPropertyNames), + false, + 'isConstructor(Object.getOwnPropertyNames) must return false' +); + +assert.throws(TypeError, () => { + new Object.getOwnPropertyNames({}); +}, '`new Object.getOwnPropertyNames({})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/order-after-define-property.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/order-after-define-property.js new file mode 100644 index 0000000000..ee8a079462 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/order-after-define-property.js @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertynames +description: > + Property names are returned in ascending chronological order of creation + that is unaffected by [[DefineOwnProperty]]. +info: | + Object.getOwnPropertyNames ( O ) + + 1. Return ? GetOwnPropertyKeys(O, String). + + GetOwnPropertyKeys ( O, type ) + + 1. Let obj be ? ToObject(O). + 2. Let keys be ? obj.[[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 obj = {}; +Object.defineProperty(obj, "a", { + get: function() {}, + set: function(_value) {}, + enumerable: true, + configurable: true, +}) +obj.b = 2; +Object.defineProperty(obj, "a", { + set: function(_value) {}, +}); +assert.compareArray(Object.getOwnPropertyNames(obj), ["a", "b"]); + +var arr = []; +arr.a = 1; +Object.defineProperty(arr, "length", {value: 2}); +assert.compareArray(Object.getOwnPropertyNames(arr), ["length", "a"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-absent-not-configurable-symbol-key.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-absent-not-configurable-symbol-key.js new file mode 100644 index 0000000000..8064daff4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-absent-not-configurable-symbol-key.js @@ -0,0 +1,56 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertynames +description: > + Proxy [[OwnPropertyKeys]] trap does not skip symbol keys when validating invariant: + * The result List must contain the keys of all non-configurable own properties of + the target object. +info: | + Object.getOwnPropertyNames ( O ) + + 1. Return ? GetOwnPropertyKeys(O, String). + + 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, Symbol] +---*/ + +var target = {}; +var symbol = Symbol(); +Object.defineProperty(target, symbol, { + value: 1, + writable: true, + enumerable: true, + configurable: false, +}); + +var proxy = new Proxy(target, { + ownKeys: function() { + return []; + }, +}); + +assert.throws(TypeError, function() { + Object.getOwnPropertyNames(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-duplicate-symbol-entry.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-duplicate-symbol-entry.js new file mode 100644 index 0000000000..fe3757163f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-duplicate-symbol-entry.js @@ -0,0 +1,38 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertynames +description: > + Proxy [[OwnPropertyKeys]] trap does not skip symbol keys when validating invariant: + * The returned List contains no duplicate entries. +info: | + Object.getOwnPropertyNames ( O ) + + 1. Return ? GetOwnPropertyKeys(O, String). + + 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, Symbol] +---*/ + +var symbol = Symbol(); +var proxy = new Proxy({}, { + ownKeys: function() { + return [symbol, symbol]; + }, +}); + +assert.throws(TypeError, function() { + Object.getOwnPropertyNames(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-absent-symbol-key.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-absent-symbol-key.js new file mode 100644 index 0000000000..20edc78cf9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-absent-symbol-key.js @@ -0,0 +1,54 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.getownpropertynames +description: > + Proxy [[OwnPropertyKeys]] trap does not skip symbol 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.getOwnPropertyNames ( O ) + + 1. Return ? GetOwnPropertyKeys(O, String). + + 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, Symbol] +---*/ + +var target = {}; +var symbol = Symbol(); +target[symbol] = 2; + +var proxy = new Proxy(target, { + ownKeys: function() { + return []; + }, +}); + +Object.preventExtensions(target); + +assert.throws(TypeError, function() { + Object.getOwnPropertyNames(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-extra-symbol-key.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-extra-symbol-key.js new file mode 100644 index 0000000000..e03c0d9fb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/proxy-invariant-not-extensible-extra-symbol-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.getownpropertynames +description: > + Proxy [[OwnPropertyKeys]] trap does not skip symbol 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.getOwnPropertyNames ( O ) + + 1. Return ? GetOwnPropertyKeys(O, String). + + 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, Symbol] +---*/ + +var target = {}; +var symbol = Symbol(); +var proxy = new Proxy(target, { + ownKeys: function() { + return [symbol]; + }, +}); + +Object.preventExtensions(target); + +assert.throws(TypeError, function() { + Object.getOwnPropertyNames(proxy); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/shell.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/shell.js new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3