diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/ThrowTypeError | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/ThrowTypeError')
16 files changed, 392 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/browser.js b/js/src/tests/test262/built-ins/ThrowTypeError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/browser.js diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/distinct-cross-realm.js b/js/src/tests/test262/built-ins/ThrowTypeError/distinct-cross-realm.js new file mode 100644 index 0000000000..548e393b7c --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/distinct-cross-realm.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is defined once for each realm. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var localArgs = function() { + "use strict"; + return arguments; +}(); +var otherArgs = (new other.Function('return arguments;'))(); +var localThrowTypeError = Object.getOwnPropertyDescriptor(localArgs, "callee").get; +var otherThrowTypeError = Object.getOwnPropertyDescriptor(otherArgs, "callee").get; + +assert.notSameValue(localThrowTypeError, otherThrowTypeError); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/extensible.js b/js/src/tests/test262/built-ins/ThrowTypeError/extensible.js new file mode 100644 index 0000000000..fb95c21017 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/extensible.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is not extensible. +info: | + %ThrowTypeError% ( ) + + The value of the [[Extensible]] internal slot of a %ThrowTypeError% + function is false. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(Object.isExtensible(ThrowTypeError), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/forbidden-arguments.js b/js/src/tests/test262/built-ins/ThrowTypeError/forbidden-arguments.js new file mode 100644 index 0000000000..06a71a2186 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/forbidden-arguments.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% does not have an own "arguments" property. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. + + 16.2 Forbidden Extensions + + Other than as defined in this specification, ECMAScript Function + objects defined using syntactic constructors in strict mode code + must not be created with own properties named "caller" or + "arguments" other than those that are created by applying the + AddRestrictedFunctionProperties abstract operation (9.2.7) to + the function. [...] Built-in functions, strict mode functions + created using the Function constructor, generator functions + created using the Generator constructor, and functions created + using the bind method also must not be created with such own + properties. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(Object.prototype.hasOwnProperty.call(ThrowTypeError, "arguments"), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/forbidden-caller.js b/js/src/tests/test262/built-ins/ThrowTypeError/forbidden-caller.js new file mode 100644 index 0000000000..68f410546e --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/forbidden-caller.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% does not have an own "caller" property. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. + + 16.2 Forbidden Extensions + + Other than as defined in this specification, ECMAScript Function + objects defined using syntactic constructors in strict mode code + must not be created with own properties named "caller" or + "arguments" other than those that are created by applying the + AddRestrictedFunctionProperties abstract operation (9.2.7) to + the function. [...] Built-in functions, strict mode functions + created using the Function constructor, generator functions + created using the Generator constructor, and functions created + using the bind method also must not be created with such own + properties. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(Object.prototype.hasOwnProperty.call(ThrowTypeError, "caller"), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/frozen.js b/js/src/tests/test262/built-ins/ThrowTypeError/frozen.js new file mode 100644 index 0000000000..d3d2c7763d --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/frozen.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + The integrity level of %ThrowTypeError% is "frozen". +info: | + %ThrowTypeError% ( ) + + The value of the [[Extensible]] internal slot of a %ThrowTypeError% + function is false. + The length property of a %ThrowTypeError% function has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(Object.isFrozen(ThrowTypeError), true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/is-function.js b/js/src/tests/test262/built-ins/ThrowTypeError/is-function.js new file mode 100644 index 0000000000..8afcacca4e --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/is-function.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is a function object. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(typeof ThrowTypeError, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/length.js b/js/src/tests/test262/built-ins/ThrowTypeError/length.js new file mode 100644 index 0000000000..d30e3ec045 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/length.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError%.length is 0. +info: | + %ThrowTypeError% ( ) + + The length property of a %ThrowTypeError% function has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(ThrowTypeError.length, 0); + +verifyNotEnumerable(ThrowTypeError, "length"); +verifyNotWritable(ThrowTypeError, "length"); +verifyNotConfigurable(ThrowTypeError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/name.js b/js/src/tests/test262/built-ins/ThrowTypeError/name.js new file mode 100644 index 0000000000..570307492f --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/name.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is an anonymous function. +info: | + %ThrowTypeError% ( ) + + 9.2.9.1 %ThrowTypeError% ( ) + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each Realm. The `name` property of a + %ThrowTypeError% function has the attributes { [[Writable]]: *false*, + [[Enumerable]]: *false*, [[Configurable]]: *false* }. + + 17 ECMAScript Standard Built-in Objects: + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +verifyProperty(ThrowTypeError, "name", { + value: "", writable: false, enumerable: false, configurable: false +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/property-order.js b/js/src/tests/test262/built-ins/ThrowTypeError/property-order.js new file mode 100644 index 0000000000..af82b17116 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/property-order.js @@ -0,0 +1,22 @@ +// 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"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/prototype.js b/js/src/tests/test262/built-ins/ThrowTypeError/prototype.js new file mode 100644 index 0000000000..eca4cda299 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/prototype.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + The value of the [[Prototype]] internal slot of %ThrowTypeError% is the + intrinsic object %FunctionPrototype%. +info: | + 8.2.2 CreateIntrinsics ( realmRec ) + + ... + 6. Let thrower be CreateBuiltinFunction(realmRec, throwerSteps, null). + 7. Set intrinsics.[[%ThrowTypeError%]] to thrower. + 8. Let noSteps be an empty sequence of algorithm steps. + 9. Let funcProto be CreateBuiltinFunction(realmRec, noSteps, objProto). + 10. Set intrinsics.[[%FunctionPrototype%]] to funcProto. + 11. Call thrower.[[SetPrototypeOf]](funcProto). + ... +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.sameValue(Object.getPrototypeOf(ThrowTypeError), Function.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/shell.js b/js/src/tests/test262/built-ins/ThrowTypeError/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/shell.js diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/throws-type-error.js b/js/src/tests/test262/built-ins/ThrowTypeError/throws-type-error.js new file mode 100644 index 0000000000..f7cad44306 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/throws-type-error.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% throws a TypeError when called. +info: | + %ThrowTypeError% ( ) + + When %ThrowTypeError% is called it performs the following steps: + + 1. Throw a TypeError exception. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +assert.throws(TypeError, function() { + ThrowTypeError(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-function-proto.js b/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-function-proto.js new file mode 100644 index 0000000000..ff4db54cb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-function-proto.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is defined once for each realm. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +// Test with Function.prototype.arguments and Function.prototype.caller properties. +var argumentsDesc = Object.getOwnPropertyDescriptor(Function.prototype, "arguments"); +var callerDesc = Object.getOwnPropertyDescriptor(Function.prototype, "caller"); + +assert.sameValue(ThrowTypeError, argumentsDesc.get, "arguments.get"); +assert.sameValue(ThrowTypeError, argumentsDesc.set, "arguments.set"); +assert.sameValue(ThrowTypeError, callerDesc.set, "caller.set"); +assert.sameValue(ThrowTypeError, callerDesc.get, "caller.get"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-non-simple.js b/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-non-simple.js new file mode 100644 index 0000000000..9bca6d664b --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-non-simple.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is defined once for each realm. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +// Test with unmapped arguments object from function with non-simple parameters list. +function nonSimple(a = 0) { + return arguments; +} +var unmappedCalleeDesc = Object.getOwnPropertyDescriptor(nonSimple(), "callee"); + +assert.sameValue(ThrowTypeError, unmappedCalleeDesc.get, "callee.get"); +assert.sameValue(ThrowTypeError, unmappedCalleeDesc.set, "callee.set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-unmapped-args.js b/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-unmapped-args.js new file mode 100644 index 0000000000..d1aac2a6cf --- /dev/null +++ b/js/src/tests/test262/built-ins/ThrowTypeError/unique-per-realm-unmapped-args.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%throwtypeerror% +description: > + %ThrowTypeError% is defined once for each realm. +info: | + %ThrowTypeError% ( ) + + The %ThrowTypeError% intrinsic is an anonymous built-in function + object that is defined once for each realm. +---*/ + +var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { + "use strict"; + return arguments; +}(), "callee").get; + +// Test with unmapped arguments object from strict-mode function. +function strictFn() { + "use strict"; + return arguments; +} +var unmappedCalleeDesc = Object.getOwnPropertyDescriptor(strictFn(), "callee"); + +assert.sameValue(ThrowTypeError, unmappedCalleeDesc.get, "callee.get"); +assert.sameValue(ThrowTypeError, unmappedCalleeDesc.set, "callee.set"); + +reportCompare(0, 0); |