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/NativeErrors/ReferenceError | |
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/NativeErrors/ReferenceError')
19 files changed, 373 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/constructor.js new file mode 100644 index 0000000000..ba287131bf --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + ReferenceError is a constructor function. +---*/ + +assert.sameValue(typeof ReferenceError, 'function', 'typeof ReferenceError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/instance-proto.js new file mode 100644 index 0000000000..97944c7113 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of ReferenceError instances is ReferenceError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new ReferenceError), ReferenceError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-a-constructor.js new file mode 100644 index 0000000000..93c39185e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-a-constructor.js @@ -0,0 +1,26 @@ +// 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: > + The ReferenceError constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(ReferenceError), true, 'isConstructor(ReferenceError) must return true'); +new ReferenceError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-error-object.js new file mode 100644 index 0000000000..870bb53320 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + ReferenceError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new ReferenceError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js new file mode 100644 index 0000000000..5a3f07d497 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + ReferenceError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.length, 1); + +verifyNotEnumerable(ReferenceError, "length"); +verifyNotWritable(ReferenceError, "length"); +verifyConfigurable(ReferenceError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js new file mode 100644 index 0000000000..66b0a39351 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + ReferenceError.name is "ReferenceError". +info: | + 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(ReferenceError.name, "ReferenceError"); + +verifyNotEnumerable(ReferenceError, "name"); +verifyNotWritable(ReferenceError, "name"); +verifyConfigurable(ReferenceError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prop-desc.js new file mode 100644 index 0000000000..49cb1ece2d --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-referenceerror +description: Property descriptor for ReferenceError +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "ReferenceError"); +verifyWritable(this, "ReferenceError"); +verifyConfigurable(this, "ReferenceError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..b86ad24a54 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. Return O. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = false; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = 'str'; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = NaN; +err = Reflect.construct(ReferenceError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.ReferenceError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto.js new file mode 100644 index 0000000000..73e8f12c71 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of ReferenceError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(ReferenceError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype.js new file mode 100644 index 0000000000..3031815ead --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of ReferenceError.prototype is the ReferenceError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.prototype, Object.getPrototypeOf(new ReferenceError)); + +verifyNotEnumerable(ReferenceError, "prototype"); +verifyNotWritable(ReferenceError, "prototype"); +verifyNotConfigurable(ReferenceError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/constructor.js new file mode 100644 index 0000000000..891c36eb67 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of ReferenceError.prototype.constructor is the ReferenceError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.prototype.constructor, ReferenceError); + +verifyNotEnumerable(ReferenceError.prototype, "constructor"); +verifyWritable(ReferenceError.prototype, "constructor"); +verifyConfigurable(ReferenceError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/message.js new file mode 100644 index 0000000000..e498b5c85f --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of ReferenceError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.prototype.message, ""); + +verifyNotEnumerable(ReferenceError.prototype, "message"); +verifyWritable(ReferenceError.prototype, "message"); +verifyConfigurable(ReferenceError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js new file mode 100644 index 0000000000..563ec73485 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of ReferenceError.prototype.name is "ReferenceError". +info: | + The initial value of the name property of the prototype for a given NativeError + constructor is a string consisting of the name of the constructor (the name used + instead of NativeError). + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(ReferenceError.prototype.name, "ReferenceError"); + +verifyNotEnumerable(ReferenceError.prototype, "name"); +verifyWritable(ReferenceError.prototype, "name"); +verifyConfigurable(ReferenceError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/not-error-object.js new file mode 100644 index 0000000000..aaf9ab6748 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + ReferenceError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(ReferenceError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/proto.js new file mode 100644 index 0000000000..c702ff1fa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of ReferenceError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(ReferenceError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} |