summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Error/AggregateError.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Error/AggregateError.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Error/AggregateError.js')
-rw-r--r--js/src/tests/non262/Error/AggregateError.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/js/src/tests/non262/Error/AggregateError.js b/js/src/tests/non262/Error/AggregateError.js
new file mode 100644
index 0000000000..d4b4420d67
--- /dev/null
+++ b/js/src/tests/non262/Error/AggregateError.js
@@ -0,0 +1,80 @@
+assertEq(typeof AggregateError, "function");
+assertEq(Object.getPrototypeOf(AggregateError), Error);
+assertEq(AggregateError.name, "AggregateError");
+assertEq(AggregateError.length, 2);
+
+assertEq(Object.getPrototypeOf(AggregateError.prototype), Error.prototype);
+assertEq(AggregateError.prototype.name, "AggregateError");
+assertEq(AggregateError.prototype.message, "");
+
+// The |errors| argument is mandatory.
+assertThrowsInstanceOf(() => new AggregateError(), TypeError);
+assertThrowsInstanceOf(() => AggregateError(), TypeError);
+
+// The .errors data property is an array object.
+{
+ let err = new AggregateError([]);
+
+ let {errors} = err;
+ assertEq(Array.isArray(errors), true);
+ assertEq(errors.length, 0);
+
+ // The errors object is modifiable.
+ errors.push(123);
+ assertEq(errors.length, 1);
+ assertEq(errors[0], 123);
+ assertEq(err.errors[0], 123);
+
+ // The property is writable.
+ err.errors = undefined;
+ assertEq(err.errors, undefined);
+}
+
+// The errors argument can be any iterable.
+{
+ function* g() { yield* [1, 2, 3]; }
+
+ let {errors} = new AggregateError(g());
+ assertEqArray(errors, [1, 2, 3]);
+}
+
+// The message property is populated by the second argument.
+{
+ let err;
+
+ err = new AggregateError([]);
+ assertEq(err.message, "");
+
+ err = new AggregateError([], "my message");
+ assertEq(err.message, "my message");
+}
+
+{
+ assertEq("errors" in AggregateError.prototype, false);
+
+ const {
+ configurable,
+ enumerable,
+ value,
+ writable
+ } = Object.getOwnPropertyDescriptor(new AggregateError([]), "errors");
+ assertEq(configurable, true);
+ assertEq(enumerable, false);
+ assertEq(writable, true);
+ assertEq(value.length, 0);
+
+ const g = newGlobal();
+
+ let obj = {};
+ let errors = new g.AggregateError([obj]).errors;
+
+ assertEq(errors.length, 1);
+ assertEq(errors[0], obj);
+
+ // The prototype is |g.Array.prototype| in the cross-compartment case.
+ let proto = Object.getPrototypeOf(errors);
+ assertEq(proto === g.Array.prototype, true);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);