From 7fc0484aafa601cc411c2434cfac062559a136fe Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Mon, 14 Dec 2020 03:00:00 +0100 Subject: [PATCH] =?UTF-8?q?Set=C2=A0function=C2=A0`length`=20and=C2=A0`nam?= =?UTF-8?q?e`=20in=C2=A0`CreateBuiltinFunction`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/built-ins/Function/property-order.js | 15 +++++++++ .../Function/prototype/property-order.js | 15 +++++++++ test/built-ins/Object/property-order.js | 15 +++++++++ ...resolve-element-function-property-order.js | 30 ++++++++++++++++++ .../reject-element-function-property-order.js | 31 +++++++++++++++++++ ...resolve-element-function-property-order.js | 31 +++++++++++++++++++ .../reject-element-function-property-order.js | 31 +++++++++++++++++++ .../executor-function-property-order.js | 23 ++++++++++++++ test/built-ins/Promise/property-order.js | 15 +++++++++ .../Promise/reject-function-property-order.js | 20 ++++++++++++ .../resolve-function-property-order.js | 20 ++++++++++++ test/built-ins/Proxy/property-order.js | 16 ++++++++++ .../revocation-function-property-order.js | 17 ++++++++++ .../ThrowTypeError/property-order.js | 20 ++++++++++++ .../compare-function-property-order.js | 16 ++++++++++ .../format/format-function-property-order.js | 16 ++++++++++ .../format/format-function-property-order.js | 16 ++++++++++ 17 files changed, 347 insertions(+) create mode 100644 test/built-ins/Function/property-order.js create mode 100644 test/built-ins/Function/prototype/property-order.js create mode 100644 test/built-ins/Object/property-order.js create mode 100644 test/built-ins/Promise/all/resolve-element-function-property-order.js create mode 100644 test/built-ins/Promise/allSettled/reject-element-function-property-order.js create mode 100644 test/built-ins/Promise/allSettled/resolve-element-function-property-order.js create mode 100644 test/built-ins/Promise/any/reject-element-function-property-order.js create mode 100644 test/built-ins/Promise/executor-function-property-order.js create mode 100644 test/built-ins/Promise/property-order.js create mode 100644 test/built-ins/Promise/reject-function-property-order.js create mode 100644 test/built-ins/Promise/resolve-function-property-order.js create mode 100644 test/built-ins/Proxy/property-order.js create mode 100644 test/built-ins/Proxy/revocable/revocation-function-property-order.js create mode 100644 test/built-ins/ThrowTypeError/property-order.js create mode 100644 test/intl402/Collator/prototype/compare/compare-function-property-order.js create mode 100644 test/intl402/DateTimeFormat/prototype/format/format-function-property-order.js create mode 100644 test/intl402/NumberFormat/prototype/format/format-function-property-order.js diff --git a/test/built-ins/Function/property-order.js b/test/built-ins/Function/property-order.js new file mode 100644 index 00000000000..1b65d7730b4 --- /dev/null +++ b/test/built-ins/Function/property-order.js @@ -0,0 +1,15 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Function constructor property order +info: | + Set order: "length", "name", ... +---*/ + +var propNames = Object.getOwnPropertyNames(Function); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Function/prototype/property-order.js b/test/built-ins/Function/prototype/property-order.js new file mode 100644 index 00000000000..aa67376367b --- /dev/null +++ b/test/built-ins/Function/prototype/property-order.js @@ -0,0 +1,15 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Function constructor property order +info: | + Set order: "length", "name", ... +---*/ + +var propNames = Object.getOwnPropertyNames(Function.prototype); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Object/property-order.js b/test/built-ins/Object/property-order.js new file mode 100644 index 00000000000..508f83e4335 --- /dev/null +++ b/test/built-ins/Object/property-order.js @@ -0,0 +1,15 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Object constructor property order +info: | + Set order: "length", "name", ... +---*/ + +var propNames = Object.getOwnPropertyNames(Object); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/all/resolve-element-function-property-order.js b/test/built-ins/Promise/all/resolve-element-function-property-order.js new file mode 100644 index 00000000000..05c92380ea7 --- /dev/null +++ b/test/built-ins/Promise/all/resolve-element-function-property-order.js @@ -0,0 +1,30 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise.all resolve element function property order +info: | + Set order: "length", "name" +---*/ + +var resolveElementFunction; +var thenable = { + then: function(fulfill) { + resolveElementFunction = fulfill; + } +}; + +function NotPromise(executor) { + executor(function() {}, function() {}); +} +NotPromise.resolve = function(v) { + return v; +}; +Promise.all.call(NotPromise, [thenable]); + +var propNames = Object.getOwnPropertyNames(resolveElementFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/allSettled/reject-element-function-property-order.js b/test/built-ins/Promise/allSettled/reject-element-function-property-order.js new file mode 100644 index 00000000000..c0f0dc95a56 --- /dev/null +++ b/test/built-ins/Promise/allSettled/reject-element-function-property-order.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise.allSettled reject element function property order +info: | + Set order: "length", "name" +features: [Promise.allSettled] +---*/ + +var rejectElementFunction; +var thenable = { + then: function(_, reject) { + rejectElementFunction = reject; + } +}; + +function NotPromise(executor) { + executor(function() {}, function() {}); +} +NotPromise.resolve = function(v) { + return v; +}; +Promise.allSettled.call(NotPromise, [thenable]); + +var propNames = Object.getOwnPropertyNames(rejectElementFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/allSettled/resolve-element-function-property-order.js b/test/built-ins/Promise/allSettled/resolve-element-function-property-order.js new file mode 100644 index 00000000000..61681c0a519 --- /dev/null +++ b/test/built-ins/Promise/allSettled/resolve-element-function-property-order.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise.allSettled resolve element function property order +info: | + Set order: "length", "name" +features: [Promise.allSettled] +---*/ + +var resolveElementFunction; +var thenable = { + then: function(fulfill) { + resolveElementFunction = fulfill; + } +}; + +function NotPromise(executor) { + executor(function() {}, function() {}); +} +NotPromise.resolve = function(v) { + return v; +}; +Promise.allSettled.call(NotPromise, [thenable]); + +var propNames = Object.getOwnPropertyNames(resolveElementFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/any/reject-element-function-property-order.js b/test/built-ins/Promise/any/reject-element-function-property-order.js new file mode 100644 index 00000000000..9fa25f3be06 --- /dev/null +++ b/test/built-ins/Promise/any/reject-element-function-property-order.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise.any resolve element function property order +info: | + Set order: "length", "name" +features: [Promise.any] +---*/ + +var rejectElementFunction; +var thenable = { + then: function(_, reject) { + rejectElementFunction = reject; + } +}; + +function NotPromise(executor) { + executor(function() {}, function() {}); +} +NotPromise.resolve = function(v) { + return v; +}; +Promise.any.call(NotPromise, [thenable]); + +var propNames = Object.getOwnPropertyNames(rejectElementFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/executor-function-property-order.js b/test/built-ins/Promise/executor-function-property-order.js new file mode 100644 index 00000000000..2c358f5b556 --- /dev/null +++ b/test/built-ins/Promise/executor-function-property-order.js @@ -0,0 +1,23 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise executor function property order +info: | + Set order: "length", "name" +---*/ + +var executorFunction; + +function NotPromise(executor) { + executorFunction = executor; + executor(function() {}, function() {}); +} +Promise.resolve.call(NotPromise); + +var propNames = Object.getOwnPropertyNames(executorFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/property-order.js b/test/built-ins/Promise/property-order.js new file mode 100644 index 00000000000..f73c4a672e0 --- /dev/null +++ b/test/built-ins/Promise/property-order.js @@ -0,0 +1,15 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise constructor property order +info: | + Set order: "length", "name", ... +---*/ + +var propNames = Object.getOwnPropertyNames(Promise); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/reject-function-property-order.js b/test/built-ins/Promise/reject-function-property-order.js new file mode 100644 index 00000000000..e710a6c2de4 --- /dev/null +++ b/test/built-ins/Promise/reject-function-property-order.js @@ -0,0 +1,20 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise reject function property order +info: | + Set order: "length", "name" +---*/ + +var rejectFunction; +new Promise(function(_, reject) { + rejectFunction = reject; +}); + +var propNames = Object.getOwnPropertyNames(rejectFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Promise/resolve-function-property-order.js b/test/built-ins/Promise/resolve-function-property-order.js new file mode 100644 index 00000000000..49d04eb6214 --- /dev/null +++ b/test/built-ins/Promise/resolve-function-property-order.js @@ -0,0 +1,20 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Promise resolve function property order +info: | + Set order: "length", "name" +---*/ + +var resolveFunction; +new Promise(function(resolve) { + resolveFunction = resolve; +}); + +var propNames = Object.getOwnPropertyNames(resolveFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Proxy/property-order.js b/test/built-ins/Proxy/property-order.js new file mode 100644 index 00000000000..08604835a87 --- /dev/null +++ b/test/built-ins/Proxy/property-order.js @@ -0,0 +1,16 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Proxy constructor property order +info: | + Set order: "length", "name", ... +features: [Proxy] +---*/ + +var propNames = Object.getOwnPropertyNames(Proxy); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/Proxy/revocable/revocation-function-property-order.js b/test/built-ins/Proxy/revocable/revocation-function-property-order.js new file mode 100644 index 00000000000..f2301e17a20 --- /dev/null +++ b/test/built-ins/Proxy/revocable/revocation-function-property-order.js @@ -0,0 +1,17 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Proxy revocation function property order +info: | + Set order: "length", "name" +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +var propNames = Object.getOwnPropertyNames(revocationFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/built-ins/ThrowTypeError/property-order.js b/test/built-ins/ThrowTypeError/property-order.js new file mode 100644 index 00000000000..fd81901e38e --- /dev/null +++ b/test/built-ins/ThrowTypeError/property-order.js @@ -0,0 +1,20 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: "%ThrowTypeError% function property order" +info: | + Set order: "length", "name" +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +var propNames = Object.getOwnPropertyNames(ThrowTypeError); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/intl402/Collator/prototype/compare/compare-function-property-order.js b/test/intl402/Collator/prototype/compare/compare-function-property-order.js new file mode 100644 index 00000000000..b7b5ecee4b5 --- /dev/null +++ b/test/intl402/Collator/prototype/compare/compare-function-property-order.js @@ -0,0 +1,16 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Collator bound compare function property order +info: | + Set order: "length", "name" +includes: [compareArray.js] +---*/ + +var compareFn = new Intl.Collator().compare; + +assert.compareArray( + Object.getOwnPropertyNames(compareFn), + ['length', 'name'] +); diff --git a/test/intl402/DateTimeFormat/prototype/format/format-function-property-order.js b/test/intl402/DateTimeFormat/prototype/format/format-function-property-order.js new file mode 100644 index 00000000000..4c0a2f8c7b4 --- /dev/null +++ b/test/intl402/DateTimeFormat/prototype/format/format-function-property-order.js @@ -0,0 +1,16 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: DateTimeFormat bound format function property order +info: | + Set order: "length", "name" +includes: [compareArray.js] +---*/ + +var formatFn = new Intl.DateTimeFormat().format; + +assert.compareArray( + Object.getOwnPropertyNames(formatFn), + ['length', 'name'] +); diff --git a/test/intl402/NumberFormat/prototype/format/format-function-property-order.js b/test/intl402/NumberFormat/prototype/format/format-function-property-order.js new file mode 100644 index 00000000000..845a54033ba --- /dev/null +++ b/test/intl402/NumberFormat/prototype/format/format-function-property-order.js @@ -0,0 +1,16 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: NumberFormat bound format function property order +info: | + Set order: "length", "name" +includes: [compareArray.js] +---*/ + +var formatFn = new Intl.NumberFormat().format; + +assert.compareArray( + Object.getOwnPropertyNames(formatFn), + ['length', 'name'] +);