summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Promise/allSettled
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Promise/allSettled
parentInitial commit. (diff)
downloadfirefox-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/Promise/allSettled')
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-after-return.js57
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-items.js61
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element.js51
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-called-twice.js108
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-not-callable.js109
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js66
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-reject.js60
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor-throws.js26
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor.js36
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-ctor.js22
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-object.js38
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/does-not-invoke-array-setters.js47
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-close.js46
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-reject.js35
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error-reject.js35
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error.js41
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js49
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js45
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-custom.js44
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-promise.js35
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-values-every-iteration-of-promise.js35
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-return.js44
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-close.js45
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-reject.js33
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-close.js47
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-reject.js34
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/invoke-then.js55
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/is-function.js12
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-false-reject.js37
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-null-reject.js37
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-number-reject.js37
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-poisoned.js43
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-string-resolve.js36
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-symbol-reject.js50
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-true-reject.js50
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-undefined-reject.js50
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-false-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-null-reject.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-number-reject.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-string-reject.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-symbol-reject.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-true-reject.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-undefined-reject.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-next-err-reject.js55
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-no-close.js58
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-reject.js51
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-false-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-null-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-number-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-string-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-symbol-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-true-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-undefined-reject.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-no-close.js54
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-reject.js53
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/length.js30
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/name.js31
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/new-reject-function.js50
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/new-resolve-function.js52
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/prop-desc.js23
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-deferred.js47
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-extensible.js31
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-length.js42
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-multiple-calls.js56
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-name.js41
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-nonconstructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-property-order.js33
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-prototype.js33
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-deferred.js53
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-immed.js44
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/reject-immed.js31
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit-from-same.js85
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit.js81
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-extensible.js31
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-length.js40
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-name.js41
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-property-order.js33
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-prototype.js33
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-from-same-thenable.js91
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection-deferred.js45
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection.js41
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-callable.js37
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-thenable.js40
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-not-callable-reject-with-typeerror.js29
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-poisoned-then.js47
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolve-thenable.js30
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-fulfilled.js65
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-mixed.js78
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-rejected.js65
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-immed.js27
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-extra-ticks.js48
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-mixed.js63
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-with-rejections.js53
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence.js53
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolved-then-catch-finally.js70
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolves-empty-array.js28
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/resolves-to-array.js29
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/returns-promise.js26
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Promise/allSettled/species-get-error.js31
104 files changed, 4763 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/browser.js b/js/src/tests/test262/built-ins/Promise/allSettled/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/browser.js
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-after-return.js b/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-after-return.js
new file mode 100644
index 0000000000..bfc4795f8d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-after-return.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: >
+ Cannot change result value of resolved Promise.allSettled element after Promise.allSettled() returned.
+info: |
+ Promise.allSettled Resolve Element Functions
+
+ 1. Let F be the active function object.
+ 2. Let alreadyCalled be F.[[AlreadyCalled]].
+ 3. If alreadyCalled.[[Value]] is true, return undefined.
+ 4. Set alreadyCalled.[[Value]] to true.
+ ...
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var callCount = 0;
+var valuesArray;
+var expected = [{ status: 'fulfilled', value: 'expectedValue' }];
+
+function Constructor(executor) {
+ function resolve(values) {
+ callCount += 1;
+ valuesArray = values;
+ checkSettledPromises(values, expected, 'values');
+ }
+ executor(resolve, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var p1OnFulfilled;
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ p1OnFulfilled = onFulfilled;
+ onFulfilled('expectedValue');
+ }
+};
+
+assert.sameValue(callCount, 0, 'callCount before call to all()');
+
+Promise.allSettled.call(Constructor, [p1]);
+
+assert.sameValue(callCount, 1, 'callCount after call to all()');
+checkSettledPromises(valuesArray, expected, 'valuesArray after call to all()');
+
+p1OnFulfilled('unexpectedValue');
+
+assert.sameValue(callCount, 1, 'callCount after call to onFulfilled()');
+checkSettledPromises(valuesArray, expected, 'valuesArray after call to onFulfilled()');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-items.js b/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-items.js
new file mode 100644
index 0000000000..a49adfa8e5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-items.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: >
+ Cannot change result value of resolved Promise.allSettled elements.
+info: |
+ Promise.allSettled Resolve Element Functions
+
+ 1. Let F be the active function object.
+ 2. Let alreadyCalled be F.[[AlreadyCalled]].
+ 3. If alreadyCalled.[[Value]] is true, return undefined.
+ 4. Set alreadyCalled.[[Value]] to true.
+ ...
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var callCount = 0;
+
+function Constructor(executor) {
+ function resolve(values) {
+ callCount += 1;
+ checkSettledPromises(values, [
+ {
+ status: 'fulfilled',
+ value: 'expectedValue-p1'
+ },
+ {
+ status: 'fulfilled',
+ value: 'expectedValue-p2'
+ }
+ ], 'values');
+ }
+ executor(resolve, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ onFulfilled('expectedValue-p1');
+ onFulfilled('unexpectedValue-p1');
+ }
+};
+var p2 = {
+ then(onFulfilled, onRejected) {
+ onFulfilled('expectedValue-p2');
+ onFulfilled('unexpectedValue-p2');
+ }
+};
+
+assert.sameValue(callCount, 0, 'callCount before call to all()');
+
+Promise.allSettled.call(Constructor, [p1, p2]);
+
+assert.sameValue(callCount, 1, 'callCount after call to all()');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element.js b/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element.js
new file mode 100644
index 0000000000..511b3a14b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: >
+ Cannot change result value of resolved Promise.allSettled element.
+info: |
+ Promise.allSettled Resolve Element Functions
+
+ 1. Let F be the active function object.
+ 2. Let alreadyCalled be F.[[AlreadyCalled]].
+ 3. If alreadyCalled.[[Value]] is true, return undefined.
+ 4. Set alreadyCalled.[[Value]] to true.
+ ...
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var callCount = 0;
+
+function Constructor(executor) {
+ function resolve(values) {
+ callCount += 1;
+ checkSettledPromises(values, [
+ {
+ status: 'fulfilled',
+ value: 'expectedValue'
+ }
+ ], 'values');
+ }
+ executor(resolve, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ onFulfilled('expectedValue');
+ onFulfilled('unexpectedValue');
+ }
+};
+
+assert.sameValue(callCount, 0, 'callCount before call to all()');
+
+Promise.allSettled.call(Constructor, [p1]);
+
+assert.sameValue(callCount, 1, 'callCount after call to all()');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-called-twice.js b/js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-called-twice.js
new file mode 100644
index 0000000000..9380bda0f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-called-twice.js
@@ -0,0 +1,108 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Throws a TypeError if capabilities executor already called with non-undefined values.
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ ...
+
+ GetCapabilitiesExecutor Functions
+
+ ...
+ 4. If promiseCapability.[[Resolve]] is not undefined, throw a TypeError exception.
+ 5. If promiseCapability.[[Reject]] is not undefined, throw a TypeError exception.
+ 6. Set promiseCapability.[[Resolve]] to resolve.
+ 7. Set promiseCapability.[[Reject]] to reject.
+ ...
+features: [Promise.allSettled]
+---*/
+
+var checkPoint = '';
+function fn1(executor) {
+ checkPoint += 'a';
+ executor();
+ checkPoint += 'b';
+ executor(function() {}, function() {});
+ checkPoint += 'c';
+}
+fn1.resolve = function() {
+ throw new Test262Error();
+};
+Promise.allSettled.call(fn1, []);
+assert.sameValue(checkPoint, 'abc', 'executor initially called with no arguments');
+
+checkPoint = '';
+function fn2(executor) {
+ checkPoint += 'a';
+ executor(undefined, undefined);
+ checkPoint += 'b';
+ executor(function() {}, function() {});
+ checkPoint += 'c';
+}
+fn2.resolve = function() {
+ throw new Test262Error();
+};
+Promise.allSettled.call(fn2, []);
+assert.sameValue(checkPoint, 'abc', 'executor initially called with (undefined, undefined)');
+
+checkPoint = '';
+function fn3(executor) {
+ checkPoint += 'a';
+ executor(undefined, function() {});
+ checkPoint += 'b';
+ executor(function() {}, function() {});
+ checkPoint += 'c';
+}
+Object.defineProperty(fn3, 'resolve', {
+ get() {
+ throw new Test262Error();
+ }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn3, []);
+}, 'executor initially called with (undefined, function)');
+assert.sameValue(checkPoint, 'ab', 'executor initially called with (undefined, function)');
+
+checkPoint = '';
+function fn4(executor) {
+ checkPoint += 'a';
+ executor(function() {}, undefined);
+ checkPoint += 'b';
+ executor(function() {}, function() {});
+ checkPoint += 'c';
+}
+Object.defineProperty(fn4, 'resolve', {
+ get() {
+ throw new Test262Error();
+ }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn4, []);
+}, 'executor initially called with (function, undefined)');
+assert.sameValue(checkPoint, 'ab', 'executor initially called with (function, undefined)');
+
+checkPoint = '';
+function fn5(executor) {
+ checkPoint += 'a';
+ executor('invalid value', 123);
+ checkPoint += 'b';
+ executor(function() {}, function() {});
+ checkPoint += 'c';
+}
+Object.defineProperty(fn5, 'resolve', {
+ get() {
+ throw new Test262Error();
+ }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn5, []);
+}, 'executor initially called with (String, Number)');
+assert.sameValue(checkPoint, 'ab', 'executor initially called with (String, Number)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-not-callable.js b/js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-not-callable.js
new file mode 100644
index 0000000000..02a29909b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/capability-executor-not-callable.js
@@ -0,0 +1,109 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Throws a TypeError if either resolve or reject capability is not callable.
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ ...
+
+ NewPromiseCapability ( C )
+
+ ...
+ 5. Let executor be CreateBuiltinFunction(steps, « [[Capability]] »).
+ 6. Set executor.[[Capability]] to promiseCapability.
+ 7. Let promise be ? Construct(C, « executor »).
+ 8. If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception.
+ 9. If IsCallable(promiseCapability.[[Reject]]) is false, throw a TypeError exception.
+ ...
+features: [Promise.allSettled]
+---*/
+
+var checkPoint = '';
+function fn1(executor) {
+ checkPoint += 'a';
+}
+Object.defineProperty(fn1, 'resolve', {
+ get() { throw new Test262Error(); }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn1, []);
+}, 'executor not called at all');
+assert.sameValue(checkPoint, 'a', 'executor not called at all');
+
+checkPoint = '';
+function fn2(executor) {
+ checkPoint += 'a';
+ executor();
+ checkPoint += 'b';
+}
+Object.defineProperty(fn2, 'resolve', {
+ get() { throw new Test262Error(); }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn2, []);
+}, 'executor called with no arguments');
+assert.sameValue(checkPoint, 'ab', 'executor called with no arguments');
+
+checkPoint = '';
+function fn3(executor) {
+ checkPoint += 'a';
+ executor(undefined, undefined);
+ checkPoint += 'b';
+}
+Object.defineProperty(fn3, 'resolve', {
+ get() { throw new Test262Error(); }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn3, []);
+}, 'executor called with (undefined, undefined)');
+assert.sameValue(checkPoint, 'ab', 'executor called with (undefined, undefined)');
+
+checkPoint = '';
+function fn4(executor) {
+ checkPoint += 'a';
+ executor(undefined, function() {});
+ checkPoint += 'b';
+}
+Object.defineProperty(fn4, 'resolve', {
+ get() { throw new Test262Error(); }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn4, []);
+}, 'executor called with (undefined, function)');
+assert.sameValue(checkPoint, 'ab', 'executor called with (undefined, function)');
+
+checkPoint = '';
+function fn5(executor) {
+ checkPoint += 'a';
+ executor(function() {}, undefined);
+ checkPoint += 'b';
+}
+Object.defineProperty(fn5, 'resolve', {
+ get() { throw new Test262Error(); }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn5, []);
+}, 'executor called with (function, undefined)');
+assert.sameValue(checkPoint, 'ab', 'executor called with (function, undefined)');
+
+checkPoint = '';
+function fn6(executor) {
+ checkPoint += 'a';
+ executor(123, 'invalid value');
+ checkPoint += 'b';
+}
+Object.defineProperty(fn6, 'resolve', {
+ get() { throw new Test262Error(); }
+});
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(fn6, []);
+}, 'executor called with (Number, String)');
+assert.sameValue(checkPoint, 'ab', 'executor called with (Number, String)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js
new file mode 100644
index 0000000000..e59ca8916e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-no-close.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-promise.allsettled
+description: >
+ Iterator is not closed when the "resolve" capability returns an abrupt
+ completion.
+info: |
+ ...
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ ...
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+ 8. Return Completion(result).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ ...
+ 6. Repeat
+ ...
+ d. If next is false, then
+ ...
+ iii. If remainingElementsCount.[[Value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+
+ IfAbruptRejectPromise
+
+ 1. IfAbruptRejectPromise(value, capability).
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+var returnCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return {
+ done: true
+ };
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+ };
+};
+var P = function(executor) {
+ return new Promise(function(_, reject) {
+ executor(function() {
+ throw new Test262Error();
+ }, reject);
+ });
+};
+
+P.resolve = function() {
+ throw new Test262Error();
+};
+
+Promise.allSettled.call(P, iter);
+
+assert.sameValue(returnCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-reject.js
new file mode 100644
index 0000000000..5e02b835d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/capability-resolve-throws-reject.js
@@ -0,0 +1,60 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-promise.allsettled
+description: >
+ Promise is rejected when the "resolve" capability returns an abrupt
+ completion.
+info: |
+ ...
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ ...
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+ 8. Return Completion(result).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ ...
+ 6. Repeat
+ ...
+ d. If next is false, then
+ ...
+ iii. If remainingElementsCount.[[Value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+
+
+ IfAbruptRejectPromise
+
+ 1. IfAbruptRejectPromise(value, capability).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var thrown = new Test262Error();
+var P = function(executor) {
+ return new Promise(function(_, reject) {
+ executor(function() {
+ throw thrown;
+ }, reject);
+ });
+};
+
+P.resolve = function() {
+ throw new Test262Error();
+};
+
+Promise.allSettled.call(P, [])
+ .then(function() {
+ $DONE('Promise incorrectly fulfilled.');
+ }, function(reason) {
+ if (reason !== thrown) {
+ $DONE('Promise rejected with incorrect "reason."');
+ return;
+ }
+ $DONE();
+ });
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor-throws.js b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor-throws.js
new file mode 100644
index 0000000000..322690025e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor-throws.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Promise.allSettled invoked on a constructor value that throws an error
+esid: sec-promise.allsettled
+info: |
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+
+ NewPromiseCapability
+
+ ...
+ 7. Let promise be ? Construct(C, « executor »).
+features: [Promise.allSettled]
+---*/
+
+var CustomPromise = function() {
+ throw new Test262Error();
+};
+
+assert.throws(Test262Error, function() {
+ Promise.allSettled.call(CustomPromise);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor.js b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor.js
new file mode 100644
index 0000000000..66fa8d387b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-ctor.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Promise.allSettled invoked on a constructor value
+esid: sec-promise.allsettled
+info: |
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ ...
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ ...
+ 8. Return Completion(result).
+features: [Promise.allSettled, class]
+---*/
+
+var executor = null;
+var callCount = 0;
+
+class SubPromise extends Promise {
+ constructor(a) {
+ super(a);
+ executor = a;
+ callCount += 1;
+ }
+}
+
+var instance = Promise.allSettled.call(SubPromise, []);
+
+assert.sameValue(instance.constructor, SubPromise);
+assert.sameValue(instance instanceof SubPromise, true);
+
+assert.sameValue(callCount, 1);
+assert.sameValue(typeof executor, 'function');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-ctor.js b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-ctor.js
new file mode 100644
index 0000000000..3850884632
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-ctor.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Promise.allSettled invoked on a non-constructor value
+esid: sec-promise.allsettled
+info: |
+ ...
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+
+ NewPromiseCapability ( C )
+
+ 1. If IsConstructor(C) is false, throw a TypeError exception.
+features: [Promise.allSettled]
+---*/
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(eval);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-object.js b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-object.js
new file mode 100644
index 0000000000..a44e2ba28b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/ctx-non-object.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Promise.allSettled invoked on a non-object value
+esid: sec-promise.allsettled
+info: |
+ 1. Let C be the this value.
+ 2. If Type(C) is not Object, throw a TypeError exception.
+features: [Promise.allSettled, Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(undefined, []);
+});
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(null, []);
+});
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(86, []);
+});
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call('string', []);
+});
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(true, []);
+});
+
+assert.throws(TypeError, function() {
+ Promise.allSettled.call(Symbol(), []);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/does-not-invoke-array-setters.js b/js/src/tests/test262/built-ins/Promise/allSettled/does-not-invoke-array-setters.js
new file mode 100644
index 0000000000..7105446411
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/does-not-invoke-array-setters.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Indexed setter properties on Array.prototype are not invoked.
+info: |
+ Promise.allSettled ( iterable )
+
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b, IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ ...
+ 4. Let remainingElementsCount be a new Record { [[value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0,
+ 1. Let valuesArray be CreateArrayFromList(values).
+ ...
+ ...
+
+ 7.3.16 CreateArrayFromList (elements)
+ ...
+ 4. For each element e of elements
+ a. Let status be CreateDataProperty(array, ToString(n), e).
+ b. Assert: status is true.
+ ...
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+Object.defineProperty(Array.prototype, 0, {
+ set() {
+ throw new Test262Error('Setter on Array.prototype called');
+ }
+});
+
+Promise.allSettled([42]).then(function() {
+ $DONE();
+}, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-close.js
new file mode 100644
index 0000000000..8855a5e989
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-close.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Explicit iterator closing in response to error
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ i. Let nextPromise be ? Invoke(constructor, "resolve", « nextValue »).
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+var iterDoneSpy = {};
+var callCount = 0;
+iterDoneSpy[Symbol.iterator] = function() {
+ return {
+ next() {
+ return {
+ value: null,
+ done: false
+ };
+ },
+ return() {
+ callCount += 1;
+ }
+ };
+};
+
+Promise.resolve = function() {
+ throw new Error();
+};
+
+Promise.allSettled(iterDoneSpy);
+
+assert.sameValue(callCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-reject.js
new file mode 100644
index 0000000000..8d44515c1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-error-reject.js
@@ -0,0 +1,35 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Promise rejection in response to error
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ i. Let nextPromise be ? Invoke(constructor, "resolve", « nextValue »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var thrown = new Test262Error();
+Promise.resolve = function() {
+ throw thrown;
+};
+
+Promise.allSettled([1])
+ .then(function() {
+ throw new Test262Error('The promise should not be fulfilled.');
+ }, function(reason) {
+ if (reason !== thrown) {
+ throw new Test262Error('The promise should be rejected with the thrown error object');
+ }
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error-reject.js
new file mode 100644
index 0000000000..ffc8525c37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error-reject.js
@@ -0,0 +1,35 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Error retrieving the constructor's `resolve` method (rejecting promise)
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ i. Let nextPromise be ? Invoke(constructor, "resolve", « nextValue »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var error = new Test262Error();
+Object.defineProperty(Promise, 'resolve', {
+ get() {
+ throw error;
+ }
+});
+
+Promise.allSettled([new Promise(function() {})]).then(function() {
+ throw new Test262Error('The promise should be rejected');
+}, function(reason) {
+ assert.sameValue(reason, error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error.js
new file mode 100644
index 0000000000..c4e560b61e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-error.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Promise.resolve is retrieved before GetIterator call (abrupt lookup).
+info: |
+ Promise.allSettled ( iterable )
+
+ [...]
+ 3. Let promiseResolve be GetPromiseResolve(C).
+ 4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
+
+ GetPromiseResolve ( promiseConstructor )
+
+ [...]
+ 2. Let promiseResolve be ? Get(promiseConstructor, "resolve").
+flags: [async]
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+const iter = {
+ get [Symbol.iterator]() {
+ throw new Test262Error('unreachable');
+ },
+};
+
+const resolveError = { name: 'MyError' };
+Object.defineProperty(Promise, 'resolve', {
+ get() {
+ throw resolveError;
+ },
+});
+
+Promise.allSettled(iter).then(() => {
+ throw new Test262Error('The promise should be rejected, but it was resolved');
+}, (reason) => {
+ assert.sameValue(reason, resolveError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js
new file mode 100644
index 0000000000..9dc562bb57
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Gets constructor's `resolve` method once from zero to many invocations.
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Let promiseResolve be ? Get(constructor, `"resolve"`).
+ 7. 1. If IsCallable(promiseResolve) is false, throw a TypeError exception.
+ 8. Repeat
+ ...
+ i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
+features: [Promise.allSettled]
+---*/
+
+var p1 = Promise.resolve(1);
+var p2 = Promise.resolve(1);
+var p3 = Promise.reject(1);
+var p4 = Promise.resolve(1);
+var resolve = Promise.resolve;
+var getCount = 0;
+var callCount = 0;
+
+Object.defineProperty(Promise, 'resolve', {
+ configurable: true,
+ get() {
+ getCount += 1;
+ return function() {
+ callCount += 1;
+ return resolve.apply(Promise, arguments);
+ };
+ }
+});
+
+Promise.allSettled([p1, p2, p3, p4]);
+
+assert.sameValue(
+ getCount, 1, 'Got `resolve` only once for each iterated value'
+);
+assert.sameValue(
+ callCount, 4, '`resolve` invoked once for each iterated value'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js
new file mode 100644
index 0000000000..1be9e774be
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Gets constructor's `resolve` method once from zero to many invocations.
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Let promiseResolve be ? Get(constructor, `"resolve"`).
+ 7. 1. If IsCallable(promiseResolve) is false, throw a TypeError exception.
+ 8. Repeat
+ ...
+ i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
+features: [Promise.allSettled]
+---*/
+
+var resolve = Promise.resolve;
+var getCount = 0;
+var callCount = 0;
+
+Object.defineProperty(Promise, 'resolve', {
+ configurable: true,
+ get() {
+ getCount += 1;
+ return function() {
+ callCount += 1;
+ return resolve.apply(Promise, arguments);
+ };
+ }
+});
+
+Promise.allSettled([]);
+
+assert.sameValue(
+ getCount, 1, 'Got `resolve` only once for each iterated value'
+);
+assert.sameValue(
+ callCount, 0, '`resolve` not called for empty iterator'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-custom.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-custom.js
new file mode 100644
index 0000000000..46502e00ab
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-custom.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Invocation of the constructor's `resolve` method for iterable with promise values
+esid: sec-promise.allSettled
+info: |
+ 7. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 7. Repeat
+ ...
+ i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
+
+flags: [async]
+features: [Promise.allSettled, class, arrow-function]
+---*/
+class Custom extends Promise {}
+
+let values = [1, 1, 1];
+let cresolveCallCount = 0;
+let presolveCallCount = 0;
+let boundCustomResolve = Custom.resolve.bind(Custom);
+let boundPromiseResolve = Promise.resolve.bind(Promise);
+
+Custom.resolve = function(...args) {
+ cresolveCallCount += 1;
+ return boundCustomResolve(...args);
+};
+
+Promise.resolve = function(...args) {
+ presolveCallCount += 1;
+ return boundPromiseResolve(...args);
+};
+
+Promise.allSettled.call(Custom, values)
+ .then(() => {
+ assert.sameValue(presolveCallCount, 0, '`Promise.resolve` is never invoked');
+ assert.sameValue(cresolveCallCount, 3, '`Custom.resolve` invoked once for every iterated promise');
+ }).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-promise.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-promise.js
new file mode 100644
index 0000000000..52e8992abb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-promises-every-iteration-of-promise.js
@@ -0,0 +1,35 @@
+// |reftest| async
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Invocation of the constructor's `resolve` method for iterable with promise values
+esid: sec-promise.allSettled
+info: |
+ 7. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 7. Repeat
+ ...
+ i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
+
+flags: [async]
+features: [Promise.allSettled, arrow-function]
+---*/
+
+let values = [1,1,1];
+let callCount = 0;
+let boundPromiseResolve = Promise.resolve.bind(Promise);
+
+Promise.resolve = function(...args) {
+ callCount += 1;
+ return boundPromiseResolve(...args);
+};
+
+Promise.allSettled(values)
+ .then(() => {
+ assert.sameValue(callCount, 3, '`then` invoked once for every iterated promise');
+ }).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-values-every-iteration-of-promise.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-values-every-iteration-of-promise.js
new file mode 100644
index 0000000000..2c8678c381
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-on-values-every-iteration-of-promise.js
@@ -0,0 +1,35 @@
+// |reftest| async
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Invocation of the constructor's `resolve` method for iterable with non-promise values
+esid: sec-promise.allSettled
+info: |
+ 5. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 8. Repeat
+ ...
+ i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
+
+flags: [async]
+features: [Promise.allSettled, arrow-function]
+---*/
+
+let values = [1, 2, 3];
+let callCount = 0;
+let boundPromiseResolve = Promise.resolve.bind(Promise);
+
+Promise.resolve = function(...args) {
+ callCount += 1;
+ return boundPromiseResolve(...args);
+};
+
+Promise.allSettled(values)
+ .then(() => {
+ assert.sameValue(callCount, 3, '`Promise.resolve` invoked once for every iterated value');
+ }).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-return.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-return.js
new file mode 100644
index 0000000000..99d28cde15
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve-return.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Use of the value returned by the constructor's `resolve` method.
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ i. Let nextPromise be ? Invoke(constructor, "resolve", « nextValue »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+features: [Promise.allSettled]
+---*/
+
+var originalCallCount = 0;
+var newCallCount = 0;
+var P = function(executor) {
+ executor(function() {}, function() {});
+};
+P.resolve = function() {
+ return newThenable;
+};
+
+var originalThenable = {
+ then() {
+ originalCallCount += 1;
+ }
+};
+var newThenable = {
+ then() {
+ newCallCount += 1;
+ }
+};
+
+Promise.allSettled.call(P, [originalThenable]);
+
+assert.sameValue(originalCallCount, 0, 'original `then` method not invoked');
+assert.sameValue(newCallCount, 1, 'new `then` method invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve.js
new file mode 100644
index 0000000000..c7f500609f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-resolve.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Invocation of the constructor's `resolve` method
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ i. Let nextPromise be ? Invoke(constructor, "resolve", « nextValue »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+features: [Promise.allSettled]
+---*/
+
+var p1 = new Promise(function() {});
+var p2 = new Promise(function() {});
+var p3 = new Promise(function() {});
+var resolve = Promise.resolve;
+var callCount = 0;
+var current = p1;
+var next = p2;
+var afterNext = p3;
+
+Promise.resolve = function(nextValue) {
+ assert.sameValue(
+ nextValue, current, '`resolve` invoked with next iterated value'
+ );
+ assert.sameValue(
+ arguments.length, 1, '`resolve` invoked with a single argument'
+ );
+ assert.sameValue(this, Promise, '`this` value is the constructor');
+
+ current = next;
+ next = afterNext;
+ afterNext = null;
+
+ callCount += 1;
+
+ return resolve.apply(Promise, arguments);
+};
+
+Promise.allSettled([p1, p2, p3]);
+
+assert.sameValue(
+ callCount, 3, '`resolve` invoked once for each iterated value'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-close.js
new file mode 100644
index 0000000000..68134047a7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-close.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ Error thrown when invoking the instance's `then` method (closing iterator)
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+var promise = new Promise(function() {});
+var returnCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return {
+ done: false,
+ value: promise
+ };
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+ };
+};
+
+promise.then = function() {
+ throw new Test262Error();
+};
+
+Promise.allSettled(iter);
+
+assert.sameValue(returnCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-reject.js
new file mode 100644
index 0000000000..a6b1e70670
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-error-reject.js
@@ -0,0 +1,33 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Error thrown when invoking the instance's `then` method (rejecting Promise)
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var promise = new Promise(function() {});
+var error = new Test262Error();
+
+promise.then = function() {
+ throw error;
+};
+
+Promise.allSettled([promise]).then(function() {
+ throw new Test262Error('The promise should be rejected');
+}, function(reason) {
+ assert.sameValue(reason, error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-close.js
new file mode 100644
index 0000000000..e5bf42c056
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-close.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ Error thrown when accesing the instance's `then` method (closing iterator)
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+var promise = new Promise(function() {});
+var returnCount = 0;
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next() {
+ return {
+ done: false,
+ value: promise
+ };
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+ };
+};
+
+Object.defineProperty(promise, 'then', {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+Promise.allSettled(iter);
+
+assert.sameValue(returnCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-reject.js
new file mode 100644
index 0000000000..53fc2ab99d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then-get-error-reject.js
@@ -0,0 +1,34 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ Error thrown when accessing the instance's `then` method (rejecting Promise)
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var promise = new Promise(function() {});
+var error = new Test262Error();
+
+Object.defineProperty(promise, 'then', {
+ get() {
+ throw error;
+ }
+});
+
+Promise.allSettled([promise]).then(function() {
+ throw new Test262Error('The promise should be rejected');
+}, function(reason) {
+ assert.sameValue(reason, error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then.js b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then.js
new file mode 100644
index 0000000000..e042be9470
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/invoke-then.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Invocation of the instance's `then` method
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+features: [Promise.allSettled]
+---*/
+
+var p1 = new Promise(function() {});
+var p2 = new Promise(function() {});
+var p3 = new Promise(function() {});
+var callCount = 0;
+var currentThis = p1;
+var nextThis = p2;
+var afterNextThis = p3;
+
+p1.then = p2.then = p3.then = function(a, b) {
+ assert.sameValue(typeof a, 'function', 'type of first argument');
+ assert.sameValue(
+ a.length,
+ 1,
+ 'The length property of a promise resolve function is 1.'
+ );
+ assert.sameValue(typeof b, 'function', 'type of second argument');
+ assert.sameValue(
+ b.length,
+ 1,
+ 'The length property of a promise reject function is 1.'
+ );
+ assert.sameValue(arguments.length, 2, '`then` invoked with two arguments');
+ assert.sameValue(this, currentThis, '`this` value');
+
+ currentThis = nextThis;
+ nextThis = afterNextThis;
+ afterNextThis = null;
+
+ callCount += 1;
+};
+
+Promise.allSettled([p1, p2, p3]);
+
+assert.sameValue(callCount, 3, '`then` invoked once for every iterated value');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/is-function.js b/js/src/tests/test262/built-ins/Promise/allSettled/is-function.js
new file mode 100644
index 0000000000..daf7e13c23
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/is-function.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled is callable
+features: [Promise.allSettled]
+---*/
+
+assert.sameValue(typeof Promise.allSettled, 'function');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-false-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-false-reject.js
new file mode 100644
index 0000000000..922a04af41
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-false-reject.js
@@ -0,0 +1,37 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument is `false`
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ #sec-getiterator
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ Let iterator be ? Call(method, obj).
+ If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled(false).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-null-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-null-reject.js
new file mode 100644
index 0000000000..b168fd1bb9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-null-reject.js
@@ -0,0 +1,37 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument is `null`
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ #sec-getiterator
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ Let iterator be ? Call(method, obj).
+ If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled(null).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-number-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-number-reject.js
new file mode 100644
index 0000000000..1acd2b92f4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-number-reject.js
@@ -0,0 +1,37 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument is a number
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ #sec-getiterator
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ Let iterator be ? Call(method, obj).
+ If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled(1).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-poisoned.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-poisoned.js
new file mode 100644
index 0000000000..0062464619
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-poisoned.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject with abrupt completion from GetIterator
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ #sec-getiterator
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ Let iterator be ? Call(method, obj).
+ ...
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+var poison = [];
+var error = new Test262Error();
+Object.defineProperty(poison, Symbol.iterator, {
+ get() {
+ throw error;
+ }
+});
+
+try {
+ Promise.allSettled(poison).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(err) {
+ assert.sameValue(err, error);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-string-resolve.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-string-resolve.js
new file mode 100644
index 0000000000..44b36a28b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-string-resolve.js
@@ -0,0 +1,36 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Resolve when argument is a string
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ #sec-getiterator
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ Let iterator be ? Call(method, obj).
+ If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled('').then(function(v) {
+ assert.sameValue(v.length, 0);
+ }, function() {
+ $DONE('The promise should be resolved, but was rejected');
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be resolved, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-symbol-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-symbol-reject.js
new file mode 100644
index 0000000000..d5a8f6ab23
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-symbol-reject.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument is a symbol
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled(Symbol()).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-true-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-true-reject.js
new file mode 100644
index 0000000000..938a896bed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-true-reject.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument is `true`
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled(true).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-undefined-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-undefined-reject.js
new file mode 100644
index 0000000000..fb06afbe2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-arg-is-undefined-reject.js
@@ -0,0 +1,50 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument is `undefined`
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled(undefined).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-false-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-false-reject.js
new file mode 100644
index 0000000000..f6f0480626
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-false-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value false
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ i. Set method to ? GetMethod(obj, @@asyncIterator).
+ ii. If method is undefined, then
+ 1. Let syncMethod be ? GetMethod(obj, @@iterator).
+ 2. Let syncIteratorRecord be ? GetIterator(obj, sync, syncMethod).
+ ...
+ 4. Let iterator be ? Call(method, obj).
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: false
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-null-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-null-reject.js
new file mode 100644
index 0000000000..920c1014ba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-null-reject.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value null
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: null
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-number-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-number-reject.js
new file mode 100644
index 0000000000..6aa69307e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-number-reject.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value 1
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: 1
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-string-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-string-reject.js
new file mode 100644
index 0000000000..4154d30463
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-string-reject.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value ""
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: ''
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-symbol-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-symbol-reject.js
new file mode 100644
index 0000000000..63797534c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-symbol-reject.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value Symbol()
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: Symbol()
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-true-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-true-reject.js
new file mode 100644
index 0000000000..e7edd2e6c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-true-reject.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value true
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: true
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-undefined-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-undefined-reject.js
new file mode 100644
index 0000000000..6ab397c63d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-assigned-undefined-reject.js
@@ -0,0 +1,52 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator property has the value undefined
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]: undefined
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-err-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-err-reject.js
new file mode 100644
index 0000000000..11c0bc77ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-err-reject.js
@@ -0,0 +1,55 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Error when call an iterator next step (rejecting promise)
+info: |
+ Promise.allSettled ( iterable )
+
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ ...
+ 6. Repeat
+ a. Let next be IteratorStep(iteratorRecord).
+ b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
+ c. ReturnIfAbrupt(next).
+ ...
+
+ IteratorStep ( iteratorRecord )
+
+ 1. Let result be ? IteratorNext(iteratorRecord).
+
+ IteratorNext ( iteratorRecord [ , value ] )
+
+ 1. If value is not present, then
+ a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
+ 2. Else,
+ a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
+ ...
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+var iterNextValThrows = {};
+var error = new Test262Error();
+iterNextValThrows[Symbol.iterator] = function() {
+ return {
+ next() {
+ throw error;
+ }
+ };
+};
+
+Promise.allSettled(iterNextValThrows).then(function() {
+ $DONE('The promise should be rejected.');
+}, function(reason) {
+ assert.sameValue(reason, error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-no-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-no-close.js
new file mode 100644
index 0000000000..368c72d590
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-no-close.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Error when accessing an iterator result's `value` property (not closing
+ iterator)
+info: |
+ Promise.allSettled ( iterable )
+
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ ...
+ 6. Repeat
+ ...
+ e. Let nextValue be IteratorValue(next).
+ f. If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to true.
+ g. ReturnIfAbrupt(nextValue).
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+var iterNextValThrows = {};
+var returnCount = 0;
+var nextCount = 0;
+var poisonedVal = {
+ done: false
+};
+var error = new Test262Error();
+Object.defineProperty(poisonedVal, 'value', {
+ get() {
+ throw error;
+ }
+});
+iterNextValThrows[Symbol.iterator] = function() {
+ return {
+ next() {
+ nextCount += 1;
+ return poisonedVal;
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+ };
+};
+
+Promise.allSettled(iterNextValThrows);
+
+assert.sameValue(returnCount, 0);
+assert.sameValue(nextCount, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-reject.js
new file mode 100644
index 0000000000..a5855e5efb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-next-val-err-reject.js
@@ -0,0 +1,51 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Error when accessing an iterator result's `value` property (rejecting promise)
+info: |
+ Promise.allSettled ( iterable )
+
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ ...
+ 6. Repeat
+ ...
+ e. Let nextValue be IteratorValue(next).
+ f. If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to true.
+ g. ReturnIfAbrupt(nextValue).
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+var iterNextValThrows = {};
+var poisonedVal = {
+ done: false
+};
+var error = new Test262Error();
+Object.defineProperty(poisonedVal, 'value', {
+ get() {
+ throw error;
+ }
+});
+iterNextValThrows[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedVal;
+ }
+ };
+};
+
+Promise.allSettled(iterNextValThrows).then(function() {
+ $DONE('The promise should be rejected.');
+}, function(reason) {
+ assert.sameValue(reason, error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-false-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-false-reject.js
new file mode 100644
index 0000000000..61ade03c35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-false-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns false
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return false;
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-null-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-null-reject.js
new file mode 100644
index 0000000000..06772c0d74
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-null-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns null
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return null;
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-number-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-number-reject.js
new file mode 100644
index 0000000000..4a49159127
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-number-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns a number
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return 1;
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-string-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-string-reject.js
new file mode 100644
index 0000000000..85094a5763
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-string-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns a string
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return '';
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-symbol-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-symbol-reject.js
new file mode 100644
index 0000000000..2a31e898f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-symbol-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns a symbol
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return Symbol();
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-true-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-true-reject.js
new file mode 100644
index 0000000000..4a31be5163
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-true-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns true
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return true;
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-undefined-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-undefined-reject.js
new file mode 100644
index 0000000000..48dd3c1ba7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-returns-undefined-reject.js
@@ -0,0 +1,54 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Reject when argument's Symbol.iterator returns undefined
+info: |
+ Promise.allSettled ( iterable )
+
+ ...
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ ...
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ ...
+
+ GetMethod
+
+ 2. Let func be ? GetV(V, P).
+ 3. If func is either undefined or null, return undefined.
+ 4. If IsCallable(func) is false, throw a TypeError exception.
+
+ Call ( F, V [ , argumentsList ] )
+
+ 2. If IsCallable(F) is false, throw a TypeError exception.
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+try {
+ Promise.allSettled({
+ [Symbol.iterator]() {
+ return undefined;
+ }
+ }).then(function() {
+ $DONE('The promise should be rejected, but was resolved');
+ }, function(error) {
+ assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
+ assert(error instanceof TypeError);
+ }).then($DONE, $DONE);
+} catch (error) {
+ $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
+}
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-no-close.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-no-close.js
new file mode 100644
index 0000000000..c7c988138b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-no-close.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Error when advancing the provided iterable (not closing iterator)
+info: |
+ Promise.allSettled ( iterable )
+
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ a. Let next be IteratorStep(iteratorRecord).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+var iterStepThrows = {};
+var poisonedDone = {};
+var returnCount = 0;
+var error = new Test262Error();
+Object.defineProperty(poisonedDone, 'done', {
+ get() {
+ throw error;
+ }
+});
+Object.defineProperty(poisonedDone, 'value', {
+ get() {}
+});
+
+iterStepThrows[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedDone;
+ },
+ return() {
+ returnCount += 1;
+ return {};
+ }
+ };
+};
+
+Promise.allSettled(iterStepThrows);
+
+assert.sameValue(returnCount, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-reject.js b/js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-reject.js
new file mode 100644
index 0000000000..874f3018e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/iter-step-err-reject.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Error when advancing the provided iterable (rejecting promise)
+info: |
+ Promise.allSettled ( iterable )
+
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ a. Let next be IteratorStep(iteratorRecord).
+ b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
+ c. ReturnIfAbrupt(next).
+features: [Promise.allSettled, Symbol.iterator]
+flags: [async]
+---*/
+
+var iterStepThrows = {};
+var poisonedDone = {};
+var error = new Test262Error();
+Object.defineProperty(poisonedDone, 'done', {
+ get() {
+ throw error;
+ }
+});
+Object.defineProperty(poisonedDone, 'value', {
+ get() {
+ $DONE('The `value` property should not be accessed.');
+ }
+});
+
+iterStepThrows[Symbol.iterator] = function() {
+ return {
+ next() {
+ return poisonedDone;
+ }
+ };
+};
+
+Promise.allSettled(iterStepThrows).then(function() {
+ $DONE('The promise should be rejected.');
+}, function(reason) {
+ assert.sameValue(reason, error);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/length.js b/js/src/tests/test262/built-ins/Promise/allSettled/length.js
new file mode 100644
index 0000000000..c0ffb02fb5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/length.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled `length` property
+info: |
+ ES Section 17:
+ 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.
+
+ [...]
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Promise.allSettled]
+---*/
+
+verifyProperty(Promise.allSettled, 'length', {
+ configurable: true,
+ writable: false,
+ enumerable: false,
+ value: 1,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/name.js b/js/src/tests/test262/built-ins/Promise/allSettled/name.js
new file mode 100644
index 0000000000..fe9c2497d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled `name` property
+info: |
+ ES Section 17:
+
+ 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, this value is the name that is given to
+ the function in this specification.
+
+ [...]
+
+ 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]
+features: [Promise.allSettled]
+---*/
+
+verifyProperty(Promise.allSettled, 'name', {
+ configurable: true,
+ writable: false,
+ enumerable: false,
+ value: 'allSettled',
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/new-reject-function.js b/js/src/tests/test262/built-ins/Promise/allSettled/new-reject-function.js
new file mode 100644
index 0000000000..16e4ed0e2d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/new-reject-function.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Each Promise.allSettled element is called with a new Promise.allSettled Reject Element function.
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+ ...
+features: [Promise.allSettled]
+---*/
+
+function rejectFunction() {}
+
+function Constructor(executor) {
+ executor(rejectFunction, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var callCount1 = 0,
+ callCount2 = 0;
+var p1OnRejected;
+
+var p1 = {
+ then(_, onRejected) {
+ callCount1 += 1;
+ p1OnRejected = onRejected;
+ assert.notSameValue(onRejected, rejectFunction, 'p1.then');
+ }
+};
+var p2 = {
+ then(_, onRejected) {
+ callCount2 += 1;
+ assert.notSameValue(onRejected, rejectFunction, 'p2.then');
+ assert.notSameValue(onRejected, p1OnRejected, 'p1.onRejected != p2.onRejected');
+ }
+};
+
+Promise.allSettled.call(Constructor, [p1, p2]);
+
+assert.sameValue(callCount1, 1, 'p1.then call count');
+assert.sameValue(callCount2, 1, 'p2.then call count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/new-resolve-function.js b/js/src/tests/test262/built-ins/Promise/allSettled/new-resolve-function.js
new file mode 100644
index 0000000000..048d664dc2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/new-resolve-function.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Each Promise.allSettled element is called with a new Promise.allSettled Resolve Element function.
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ ...
+ k Let resolveElement be ! CreateBuiltinFunction(steps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+ ...
+features: [Promise.allSettled]
+---*/
+
+function resolveFunction() {}
+
+function Constructor(executor) {
+ executor(resolveFunction, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var callCount1 = 0,
+ callCount2 = 0;
+var p1OnFulfilled;
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ callCount1 += 1;
+ p1OnFulfilled = onFulfilled;
+ assert.notSameValue(onFulfilled, resolveFunction, 'p1.then');
+ }
+};
+var p2 = {
+ then(onFulfilled, onRejected) {
+ callCount2 += 1;
+ assert.notSameValue(onFulfilled, resolveFunction, 'p2.then');
+ assert.notSameValue(onFulfilled, p1OnFulfilled, 'p1.onFulfilled != p2.onFulfilled');
+ }
+};
+
+Promise.allSettled.call(Constructor, [p1, p2]);
+
+assert.sameValue(callCount1, 1, 'p1.then call count');
+assert.sameValue(callCount2, 1, 'p2.then call count');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js
new file mode 100644
index 0000000000..98dc3d6401
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js
@@ -0,0 +1,31 @@
+// 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: >
+ Promise.allSettled 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, Promise.allSettled, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Promise.allSettled), false, 'isConstructor(Promise.allSettled) must return false');
+
+assert.throws(TypeError, () => {
+ new Promise.allSettled();
+}, '`new Promise.allSettled()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/prop-desc.js b/js/src/tests/test262/built-ins/Promise/allSettled/prop-desc.js
new file mode 100644
index 0000000000..46ae80be70
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/prop-desc.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled property descriptor
+info: |
+ ES Section 17
+
+ 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]
+features: [Promise.allSettled]
+---*/
+
+verifyProperty(Promise, 'allSettled', {
+ configurable: true,
+ writable: true,
+ enumerable: false,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-deferred.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-deferred.js
new file mode 100644
index 0000000000..6eec5d809b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-deferred.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Rejecting through deferred invocation of the provided resolving function
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+
+ Promise.allSettled Reject Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "rejected").
+ 11. Perform ! CreateDataProperty(obj, "reason", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var simulation = {};
+var thenable = {
+ then(_, reject) {
+ new Promise(function(resolve) {
+ resolve();
+ })
+ .then(function() {
+ reject(simulation);
+ });
+ }
+};
+
+Promise.allSettled([thenable])
+ .then((settleds) => {
+ assert.sameValue(settleds.length, 1);
+ assert.sameValue(settleds[0].status, 'rejected');
+ assert.sameValue(settleds[0].reason, simulation);
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-extensible.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-extensible.js
new file mode 100644
index 0000000000..5672b6e9dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-extensible.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-reject-element-functions
+description: The [[Extensible]] slot of Promise.allSettled Reject Element functions
+info: |
+ 17 ECMAScript Standard Built-in Objects:
+ Unless specified otherwise, the [[Extensible]] internal slot
+ of a built-in object initially has the value true.
+features: [Promise.allSettled]
+---*/
+
+var rejectElementFunction;
+var thenable = {
+ then(_, reject) {
+ rejectElementFunction = reject;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert(Object.isExtensible(rejectElementFunction));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-length.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-length.js
new file mode 100644
index 0000000000..9c92566180
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-length.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-reject-element-functions
+description: The `length` property of Promise.allSettled Reject Element functions
+info: |
+ The length property of a Promise.allSettled Reject Element function is 1.
+
+ 17 ECMAScript Standard Built-in Objects:
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var rejectElementFunction;
+var thenable = {
+ then(_, reject) {
+ rejectElementFunction = reject;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert.sameValue(rejectElementFunction.length, 1);
+
+verifyProperty(rejectElementFunction, 'length', {
+ value: 1,
+ enumerable: false,
+ writable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-multiple-calls.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-multiple-calls.js
new file mode 100644
index 0000000000..2cbc89007d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-multiple-calls.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Cannot tamper with remainingElementsCount when Promise.allSettled reject element function is called multiple times.
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability, )
+
+ If alreadyCalled.[[Value]] is true, return undefined.
+
+features: [Promise.allSettled]
+---*/
+
+let rejectCallCount = 0;
+let returnValue = {};
+let error = new Test262Error();
+
+function Constructor(executor) {
+ function reject(value) {
+ assert.sameValue(value, error);
+ rejectCallCount += 1;
+ return returnValue;
+ }
+ executor(() => {throw error}, reject);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+Constructor.reject = function(v) {
+ return v;
+};
+
+let pOnRejected;
+
+let p = {
+ then(onResolved, onRejected) {
+ pOnRejected = onRejected;
+ onResolved();
+ }
+};
+
+assert.sameValue(rejectCallCount, 0, 'rejectCallCount before call to allSettled()');
+
+Promise.allSettled.call(Constructor, [p]);
+
+assert.sameValue(rejectCallCount, 1, 'rejectCallCount after call to allSettled()');
+assert.sameValue(pOnRejected(), undefined);
+assert.sameValue(rejectCallCount, 1, 'rejectCallCount after call to pOnRejected()');
+pOnRejected();
+assert.sameValue(rejectCallCount, 1, 'rejectCallCount after call to pOnRejected()');
+
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-name.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-name.js
new file mode 100644
index 0000000000..dce6efeb06
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-name.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-reject-element-functions
+description: The `name` property of Promise.allSettled Reject Element functions
+info: |
+ A promise resolve function is an anonymous built-in function.
+
+ 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]
+features: [Promise.allSettled]
+---*/
+
+var rejectElementFunction;
+var thenable = {
+ then(_, reject) {
+ rejectElementFunction = reject;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+verifyProperty(rejectElementFunction, "name", {
+ value: "", writable: false, enumerable: false, configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-nonconstructor.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-nonconstructor.js
new file mode 100644
index 0000000000..e6803c37cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-nonconstructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-reject-element-functions
+description: Promise.allSettled Reject Element functions are not constructors
+info: |
+ 17 ECMAScript Standard Built-in 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.
+features: [Promise.allSettled]
+---*/
+
+var rejectElementFunction;
+var thenable = {
+ then(_, reject) {
+ rejectElementFunction = reject;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert.sameValue(Object.prototype.hasOwnProperty.call(rejectElementFunction, 'prototype'), false);
+assert.throws(TypeError, function() {
+ new rejectElementFunction();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-property-order.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-property-order.js
new file mode 100644
index 0000000000..44a71240e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-property-order.js
@@ -0,0 +1,33 @@
+// 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");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-prototype.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-prototype.js
new file mode 100644
index 0000000000..79067c1e53
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-element-function-prototype.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-reject-element-functions
+description: The [[Prototype]] of Promise.allSettled Reject Element functions
+info: |
+ 17 ECMAScript Standard Built-in Objects:
+ Unless otherwise specified every built-in function and every built-in
+ constructor has the Function prototype object, which is the initial
+ value of the expression Function.prototype (19.2.3), as the value of
+ its [[Prototype]] internal slot.
+features: [Promise.allSettled]
+---*/
+
+var rejectElementFunction;
+var thenable = {
+ then(_, reject) {
+ rejectElementFunction = reject;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert.sameValue(Object.getPrototypeOf(rejectElementFunction), Function.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-deferred.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-deferred.js
new file mode 100644
index 0000000000..c249c2cfe8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-deferred.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Resolved promises ignore rejections through deferred invocation of the
+ provided resolving function
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var simulation = {};
+
+var fulfiller = {
+ then(resolve) {
+ new Promise(function(resolve) {
+ resolve();
+ })
+ .then(function() {
+ resolve(42);
+ });
+ }
+};
+var rejector = {
+ then(resolve, reject) {
+ new Promise(function(resolve) {
+ resolve();
+ })
+ .then(function() {
+ resolve(simulation);
+ reject();
+ });
+ }
+};
+
+Promise.allSettled([fulfiller, rejector])
+ .then((settleds) => {
+ assert.sameValue(settleds.length, 2);
+ assert.sameValue(settleds[0].status, 'fulfilled');
+ assert.sameValue(settleds[0].value, 42);
+ assert.sameValue(settleds[1].status, 'fulfilled');
+ assert.sameValue(settleds[1].value, simulation);
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-immed.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-immed.js
new file mode 100644
index 0000000000..d06df2b019
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-ignored-immed.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Resolved promises ignore rejections through immediate invocation of the
+ provided resolving function
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var simulation = {};
+
+var fulfiller = {
+ then(resolve) {
+ resolve(42);
+ }
+};
+
+var lateRejector = {
+ then(resolve, reject) {
+ resolve(simulation);
+ reject();
+ }
+};
+
+Promise.allSettled([fulfiller, lateRejector])
+ .then((settleds) => {
+ assert.sameValue(settleds.length, 2);
+ assert.sameValue(settleds[0].status, 'fulfilled');
+ assert.sameValue(settleds[0].value, 42);
+ assert.sameValue(settleds[1].status, 'fulfilled');
+ assert.sameValue(settleds[1].value, simulation);
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/reject-immed.js b/js/src/tests/test262/built-ins/Promise/allSettled/reject-immed.js
new file mode 100644
index 0000000000..aa5fff5c59
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/reject-immed.js
@@ -0,0 +1,31 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Rejecting through immediate invocation of the provided resolving function
+esid: sec-promise.allsettled
+info: |
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var simulation = {};
+var thenable = {
+ then(_, reject) {
+ reject(simulation);
+ }
+};
+
+Promise.allSettled([thenable])
+ .then((settleds) => {
+ checkSettledPromises(settleds, [{ status: 'rejected', reason: simulation }]);
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit-from-same.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit-from-same.js
new file mode 100644
index 0000000000..d5bc9325e0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit-from-same.js
@@ -0,0 +1,85 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Cannot tamper remainingElementsCount when Promise.allSettled resolve element function is called twice in a row.
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+
+ Promise.allSettled Resolve Element Functions
+
+ 2. Let alreadyCalled be F.[[AlreadyCalled]].
+ 3. If alreadyCalled.[[Value]] is true, return undefined.
+ 4. Set alreadyCalled.[[Value]] to true.
+ ...
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var callCount = 0;
+
+function Constructor(executor) {
+ function resolve(values) {
+ callCount += 1;
+ checkSettledPromises(values, [
+ {
+ status: 'fulfilled',
+ value: 'p1-fulfill'
+ },
+ {
+ status: 'fulfilled',
+ value: 'p2-fulfill'
+ },
+ {
+ status: 'fulfilled',
+ value: 'p3-fulfill'
+ }
+ ], 'values');
+ }
+ executor(resolve, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var p1OnFulfilled;
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ p1OnFulfilled = onFulfilled;
+ }
+};
+var p2 = {
+ then(onFulfilled, onRejected) {
+ onFulfilled('p2-fulfill');
+ onFulfilled('p2-fulfill-unexpected');
+ }
+};
+var p3 = {
+ then(onFulfilled, onRejected) {
+ onFulfilled('p3-fulfill');
+ }
+};
+
+assert.sameValue(callCount, 0, 'callCount before call to all()');
+
+Promise.allSettled.call(Constructor, [p1, p2, p3]);
+
+assert.sameValue(callCount, 0, 'callCount after call to all()');
+
+p1OnFulfilled('p1-fulfill');
+
+assert.sameValue(callCount, 1, 'callCount after resolving p1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit.js
new file mode 100644
index 0000000000..159168f2eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-before-loop-exit.js
@@ -0,0 +1,81 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Cannot tamper remainingElementsCount when two Promise.allSettled resolve element functions are called in succession.
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+
+ Promise.allSettled Resolve Element Functions
+
+ 2. Let alreadyCalled be F.[[AlreadyCalled]].
+ 3. If alreadyCalled.[[Value]] is true, return undefined.
+ 4. Set alreadyCalled.[[Value]] to true.
+ ...
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var callCount = 0;
+
+function Constructor(executor) {
+ function resolve(values) {
+ callCount += 1;
+ checkSettledPromises(values, [
+ {
+ status: 'fulfilled',
+ value: 'p1-fulfill'
+ },
+ {
+ status: 'fulfilled',
+ value: 'p2-fulfill'
+ },
+ {
+ status: 'fulfilled',
+ value: 'p3-fulfill'
+ }
+ ], 'values');
+ }
+ executor(resolve, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var p1OnFulfilled;
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ p1OnFulfilled = onFulfilled;
+ }
+};
+var p2 = {
+ then(onFulfilled, onRejected) {
+ p1OnFulfilled('p1-fulfill');
+ onFulfilled('p2-fulfill');
+ }
+};
+var p3 = {
+ then(onFulfilled, onRejected) {
+ onFulfilled('p3-fulfill');
+ }
+};
+
+assert.sameValue(callCount, 0, 'callCount before call to all()');
+
+Promise.allSettled.call(Constructor, [p1, p2, p3]);
+
+assert.sameValue(callCount, 1, 'callCount after call to all()');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-extensible.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-extensible.js
new file mode 100644
index 0000000000..0a469e3f67
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-extensible.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: The [[Extensible]] slot of Promise.allSettled Resolve Element functions
+info: |
+ 17 ECMAScript Standard Built-in Objects:
+ Unless specified otherwise, the [[Extensible]] internal slot
+ of a built-in object initially has the value true.
+features: [Promise.allSettled]
+---*/
+
+var resolveElementFunction;
+var thenable = {
+ then(fulfill) {
+ resolveElementFunction = fulfill;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert(Object.isExtensible(resolveElementFunction));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-length.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-length.js
new file mode 100644
index 0000000000..16cfbe3219
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-length.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: The `length` property of Promise.allSettled Resolve Element functions
+info: |
+ The length property of a Promise.allSettled resolve element function is 1.
+
+ 17 ECMAScript Standard Built-in Objects:
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var resolveElementFunction;
+var thenable = {
+ then(fulfill) {
+ resolveElementFunction = fulfill;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+verifyProperty(resolveElementFunction, 'length', {
+ value: 1,
+ enumerable: false,
+ writable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-name.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-name.js
new file mode 100644
index 0000000000..eb6a7d1ddc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-name.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: The `name` property of Promise.allSettled Resolve Element functions
+info: |
+ A promise resolve function is an anonymous built-in function.
+
+ 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]
+features: [Promise.allSettled]
+---*/
+
+var resolveElementFunction;
+var thenable = {
+ then(fulfill) {
+ resolveElementFunction = fulfill;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+verifyProperty(resolveElementFunction, "name", {
+ value: "", writable: false, enumerable: false, configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js
new file mode 100644
index 0000000000..5c1ca93aa5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: Promise.allSettled Resolve Element functions are not constructors
+info: |
+ 17 ECMAScript Standard Built-in 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.
+features: [Promise.allSettled]
+---*/
+
+var resolveElementFunction;
+var thenable = {
+ then(fulfill) {
+ resolveElementFunction = fulfill;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, 'prototype'), false);
+assert.throws(TypeError, function() {
+ new resolveElementFunction();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-property-order.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-property-order.js
new file mode 100644
index 0000000000..5914500a1e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-property-order.js
@@ -0,0 +1,33 @@
+// 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");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-prototype.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-prototype.js
new file mode 100644
index 0000000000..fc3a86235d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-element-function-prototype.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled-resolve-element-functions
+description: The [[Prototype]] of Promise.allSettled Resolve Element functions
+info: |
+ 17 ECMAScript Standard Built-in Objects:
+ Unless otherwise specified every built-in function and every built-in
+ constructor has the Function prototype object, which is the initial
+ value of the expression Function.prototype (19.2.3), as the value of
+ its [[Prototype]] internal slot.
+features: [Promise.allSettled]
+---*/
+
+var resolveElementFunction;
+var thenable = {
+ then(fulfill) {
+ resolveElementFunction = fulfill;
+ }
+};
+
+function NotPromise(executor) {
+ executor(function() {}, function() {});
+}
+NotPromise.resolve = function(v) {
+ return v;
+};
+Promise.allSettled.call(NotPromise, [thenable]);
+
+assert.sameValue(Object.getPrototypeOf(resolveElementFunction), Function.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-from-same-thenable.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-from-same-thenable.js
new file mode 100644
index 0000000000..f51b3406f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-from-same-thenable.js
@@ -0,0 +1,91 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-performpromiseallsettled
+description: >
+ Cannot tamper remainingElementsCount when Promise.allSettled resolve element function is called multiple times.
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+
+ Promise.allSettled Resolve Element Functions
+
+ 2. Let alreadyCalled be F.[[AlreadyCalled]].
+ 3. If alreadyCalled.[[Value]] is true, return undefined.
+ 4. Set alreadyCalled.[[Value]] to true.
+ ...
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var callCount = 0;
+
+function Constructor(executor) {
+ function resolve(values) {
+ callCount += 1;
+ checkSettledPromises(values, [
+ {
+ status: 'fulfilled',
+ value: 'p1-fulfill'
+ },
+ {
+ status: 'fulfilled',
+ value: 'p2-fulfill'
+ },
+ {
+ status: 'fulfilled',
+ value: 'p3-fulfill'
+ }
+ ], 'values');
+ }
+ executor(resolve, Test262Error.thrower);
+}
+Constructor.resolve = function(v) {
+ return v;
+};
+
+var p1OnFulfilled, p2OnFulfilled, p3OnFulfilled;
+
+var p1 = {
+ then(onFulfilled, onRejected) {
+ p1OnFulfilled = onFulfilled;
+ }
+};
+var p2 = {
+ then(onFulfilled, onRejected) {
+ p2OnFulfilled = onFulfilled;
+ }
+};
+var p3 = {
+ then(onFulfilled, onRejected) {
+ p3OnFulfilled = onFulfilled;
+ }
+};
+
+assert.sameValue(callCount, 0, 'callCount before call to allSettled()');
+
+Promise.allSettled.call(Constructor, [p1, p2, p3]);
+
+assert.sameValue(callCount, 0, 'callCount after call to allSettled()');
+
+p1OnFulfilled('p1-fulfill');
+p1OnFulfilled('p1-fulfill-unexpected-1');
+p1OnFulfilled('p1-fulfill-unexpected-2');
+
+assert.sameValue(callCount, 0, 'callCount after resolving p1');
+
+p2OnFulfilled('p2-fulfill');
+p3OnFulfilled('p3-fulfill');
+
+assert.sameValue(callCount, 1, 'callCount after resolving all elements');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection-deferred.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection-deferred.js
new file mode 100644
index 0000000000..1697045af9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection-deferred.js
@@ -0,0 +1,45 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter, 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Resolved promises ignore rejections through deferred invocation of the
+ provided resolving function
+esid: sec-promise.allSettled
+info: |
+ Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ Repeat
+ ...
+ r. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], rejectElement »).
+
+flags: [async]
+features: [Promise.allSettled, arrow-function]
+---*/
+
+var resolver = {
+ then(resolve) {
+ new Promise((resolve) => resolve())
+ .then(() => resolve(42));
+ }
+};
+var lateRejector = {
+ then(resolve, reject) {
+ new Promise((resolve) => resolve())
+ .then(() => {
+ resolve(9);
+ reject();
+ });
+ }
+};
+
+Promise.allSettled([resolver, lateRejector])
+ .then(resolution => {
+ assert.sameValue(resolution[0].value, 42);
+ assert.sameValue(resolution[0].status, 'fulfilled');
+ assert.sameValue(resolution[1].value, 9);
+ assert.sameValue(resolution[1].status, 'fulfilled');
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection.js
new file mode 100644
index 0000000000..d7847a7b6d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-ignores-late-rejection.js
@@ -0,0 +1,41 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter, 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Resolved promises ignore rejections through immediate invocation of the
+ provided resolving function
+esid: sec-promise.allSettled
+info: |
+ Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ Repeat
+ ...
+ r. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], rejectElement »).
+
+flags: [async]
+features: [Promise.allSettled, arrow-function]
+---*/
+
+var resolver = {
+ then(resolve) {
+ resolve(42);
+ }
+};
+var lateRejector = {
+ then(resolve, reject) {
+ resolve(33);
+ reject();
+ }
+};
+
+Promise.allSettled([resolver, lateRejector])
+ .then(resolution => {
+ assert.sameValue(resolution[0].value, 42);
+ assert.sameValue(resolution[0].status, 'fulfilled');
+ assert.sameValue(resolution[1].value, 33);
+ assert.sameValue(resolution[1].status, 'fulfilled');
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-callable.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-callable.js
new file mode 100644
index 0000000000..ebc4350938
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-callable.js
@@ -0,0 +1,37 @@
+// |reftest| async
+// Copyright (C) 2020 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Promise.resolve is retrieved before GetIterator call (non-callable).
+info: |
+ Promise.allSettled ( iterable )
+
+ [...]
+ 3. Let promiseResolve be GetPromiseResolve(C).
+ 4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
+
+ GetPromiseResolve ( promiseConstructor )
+
+ [...]
+ 2. Let promiseResolve be ? Get(promiseConstructor, "resolve").
+ 3. If IsCallable(promiseResolve) is false, throw a TypeError exception.
+flags: [async]
+features: [Promise.allSettled, Symbol.iterator]
+---*/
+
+const iter = { 
+ get [Symbol.iterator]() {
+ throw new Test262Error("unreachable");
+ },
+};
+
+Promise.resolve = "certainly not callable";
+
+Promise.allSettled(iter).then(() => {
+ throw new Test262Error("The promise should be rejected, but it was resolved");
+}, (reason) => {
+ assert(reason instanceof TypeError);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-thenable.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-thenable.js
new file mode 100644
index 0000000000..389ea47977
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-non-thenable.js
@@ -0,0 +1,40 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Resolving with a non-thenable object value
+esid: sec-promise.allsettled
+info: |
+ Promise.allSettled Resolve Element Functions
+
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be ! CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var v1 = {};
+var v2 = {};
+var v3 = {};
+
+Promise.allSettled([v1, v2, v3])
+ .then(function(values) {
+ checkSettledPromises(values, [
+ {
+ status: 'fulfilled',
+ value: v1
+ },
+ {
+ status: 'fulfilled',
+ value: v2
+ },
+ {
+ status: 'fulfilled',
+ value: v3
+ }
+ ], 'values');
+ }, function() {
+ $DONE('The promise should not be rejected.');
+ }).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-not-callable-reject-with-typeerror.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-not-callable-reject-with-typeerror.js
new file mode 100644
index 0000000000..c6f9c19173
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-not-callable-reject-with-typeerror.js
@@ -0,0 +1,29 @@
+// |reftest| async
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allSettled
+description: >
+ If the constructor's `resolve` method is not callable, reject with a TypeError.
+info: |
+ Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+
+ Runtime Semantics: PerformPromiseAllSettled
+
+ Let promiseResolve be ? Get(constructor, "resolve").
+ If ! IsCallable(promiseResolve) is false, throw a TypeError exception.
+
+flags: [async]
+features: [Promise.allSettled, arrow-function]
+---*/
+
+Promise.resolve = null;
+
+Promise.allSettled([1])
+ .then(
+ () => $DONE('The promise should not be resolved.'),
+ error => {
+ assert(error instanceof TypeError);
+ }
+ ).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-poisoned-then.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-poisoned-then.js
new file mode 100644
index 0000000000..7d37bfa2c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-poisoned-then.js
@@ -0,0 +1,47 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Resolving with an object with a "poisoned" `then` property
+esid: sec-promise.allsettled
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var value = {};
+var promise;
+
+try {
+ Object.defineProperty(Array.prototype, 'then', {
+ get() {
+ throw value;
+ },
+ configurable: true
+ });
+
+ promise = Promise.allSettled([]);
+} finally {
+ delete Array.prototype.then;
+}
+
+promise.then(function() {
+ $DONE('The promise should not be fulfilled.');
+}, function(val) {
+ if (val !== value) {
+ $DONE('The promise should be rejected with the expected value.');
+ return;
+ }
+
+ $DONE();
+});
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolve-thenable.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-thenable.js
new file mode 100644
index 0000000000..008e9525e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolve-thenable.js
@@ -0,0 +1,30 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: Resolving with a thenable object value
+esid: sec-promise.allsettled
+info: |
+ Let promiseCapability be NewPromiseCapability(C).
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var value = {};
+var promise;
+
+try {
+ Array.prototype.then = function(resolve) {
+ resolve(value);
+ };
+
+ promise = Promise.allSettled([]);
+} finally {
+ delete Array.prototype.then;
+}
+
+promise.then(function(val) {
+ assert.sameValue(val, value);
+}, function() {
+ $DONE('The promise should not be rejected.');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-fulfilled.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-fulfilled.js
new file mode 100644
index 0000000000..cfface3843
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-fulfilled.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Resolution is a collection of all the settled values (all fulfilled)
+info: |
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat,
+ ...
+ j. Let steps be the algorithm steps defined in Promise.allSettled Resolve Element Functions.
+ k. Let resolveElement be ! CreateBuiltinFunction(steps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ r. Let rejectSteps be the algorithm steps defined in Promise.allSettled Reject Element Functions.
+ s. Let rejectElement be ! CreateBuiltinFunction(rejectSteps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+
+ Promise.allSettled Resolve Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "fulfilled").
+ 11. Perform ! CreateDataProperty(obj, "value", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be ! CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+
+ Promise.allSettled Reject Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "rejected").
+ 11. Perform ! CreateDataProperty(obj, "reason", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var obj = {};
+var p1 = new Promise(function(resolve) {
+ resolve(1);
+});
+var p2 = new Promise(function(resolve) {
+ resolve('test262');
+});
+var p3 = new Promise(function(resolve) {
+ resolve(obj);
+});
+
+Promise.allSettled([p1, p2, p3]).then(function(settled) {
+ checkSettledPromises(settled, [
+ { status: 'fulfilled', value: 1 },
+ { status: 'fulfilled', value: 'test262' },
+ { status: 'fulfilled', value: obj }
+ ], 'settled');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-mixed.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-mixed.js
new file mode 100644
index 0000000000..8a598f77a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-mixed.js
@@ -0,0 +1,78 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Resolution is a collection of all the settled values (fulfilled and rejected)
+info: |
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat,
+ ...
+ j. Let steps be the algorithm steps defined in Promise.allSettled Resolve Element Functions.
+ k. Let resolveElement be ! CreateBuiltinFunction(steps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ r. Let rejectSteps be the algorithm steps defined in Promise.allSettled Reject Element Functions.
+ s. Let rejectElement be ! CreateBuiltinFunction(rejectSteps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+
+ Promise.allSettled Resolve Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "fulfilled").
+ 11. Perform ! CreateDataProperty(obj, "value", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be ! CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+
+ Promise.allSettled Reject Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "rejected").
+ 11. Perform ! CreateDataProperty(obj, "reason", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var obj1 = {};
+var obj2 = {};
+var r1 = new Promise(function(_, reject) {
+ reject(1);
+});
+var f1 = new Promise(function(resolve) {
+ resolve(2);
+});
+var f2 = new Promise(function(resolve) {
+ resolve('tc39');
+});
+var r2 = new Promise(function(_, reject) {
+ reject('test262');
+});
+var r3 = new Promise(function(_, reject) {
+ reject(obj1);
+});
+var f3 = new Promise(function(resolve) {
+ resolve(obj2);
+});
+
+Promise.allSettled([r1, f1, f2, r2, r3, f3]).then(function(settled) {
+ checkSettledPromises(settled, [
+ { status: 'rejected', reason: 1 },
+ { status: 'fulfilled', value: 2 },
+ { status: 'fulfilled', value: 'tc39' },
+ { status: 'rejected', reason: 'test262' },
+ { status: 'rejected', reason: obj1 },
+ { status: 'fulfilled', value: obj2 }
+ ], 'settled');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-rejected.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-rejected.js
new file mode 100644
index 0000000000..943b98c01f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-all-rejected.js
@@ -0,0 +1,65 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Resolution is a collection of all the settled values (fulfiled and rejected promises)
+info: |
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat,
+ ...
+ j. Let steps be the algorithm steps defined in Promise.allSettled Resolve Element Functions.
+ k. Let resolveElement be ! CreateBuiltinFunction(steps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ r. Let rejectSteps be the algorithm steps defined in Promise.allSettled Reject Element Functions.
+ s. Let rejectElement be ! CreateBuiltinFunction(rejectSteps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+
+ Promise.allSettled Resolve Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "fulfilled").
+ 11. Perform ! CreateDataProperty(obj, "value", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be ! CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+
+ Promise.allSettled Reject Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "rejected").
+ 11. Perform ! CreateDataProperty(obj, "reason", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var obj = {};
+var p1 = new Promise(function(_, reject) {
+ reject(1);
+});
+var p2 = new Promise(function(_, reject) {
+ reject('test262');
+});
+var p3 = new Promise(function(_, reject) {
+ reject(obj);
+});
+
+Promise.allSettled([p1, p2, p3]).then(function(settled) {
+ checkSettledPromises(settled, [
+ { status: 'rejected', reason: 1 },
+ { status: 'rejected', reason: 'test262' },
+ { status: 'rejected', reason: obj }
+ ], 'settled');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-immed.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-immed.js
new file mode 100644
index 0000000000..c6c2d4fcb4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-immed.js
@@ -0,0 +1,27 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled([]) returns immediately
+includes: [promiseHelper.js]
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var sequence = [];
+
+Promise.allSettled([]).then(function() {
+ sequence.push(2);
+}).catch($DONE);
+
+Promise.resolve().then(function() {
+ sequence.push(3);
+}).then(function() {
+ sequence.push(4);
+ assert.sameValue(sequence.length, 4);
+checkSequence(sequence, 'Promises resolved in unexpected sequence');
+}).then($DONE, $DONE);
+
+sequence.push(1);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-extra-ticks.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-extra-ticks.js
new file mode 100644
index 0000000000..e52ea2a348
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-extra-ticks.js
@@ -0,0 +1,48 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Resolution ticks are set in a predictable sequence with extra then calls
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var sequence = [];
+
+var p1 = new Promise(function(resolve) {
+ resolve({});
+});
+
+sequence.push(1);
+
+Promise.allSettled([p1]).then(function(resolved) {
+ sequence.push(4);
+ assert.sameValue(sequence.length, 4);
+ checkSequence(sequence, 'Expected Promise.allSettled().then to queue second');
+}).catch($DONE);
+
+p1.then(function() {
+ sequence.push(3);
+ assert.sameValue(sequence.length, 3);
+ checkSequence(sequence, 'Expected p1.then to queue first');
+}).then(function() {
+ sequence.push(5);
+ assert.sameValue(sequence.length, 5);
+ checkSequence(sequence, 'Expected final then to queue last');
+}).then($DONE, $DONE);
+
+sequence.push(2);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-mixed.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-mixed.js
new file mode 100644
index 0000000000..27bd4bcf3b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-mixed.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Resolution ticks are set in a predictable sequence of mixed fulfilled and rejected promises
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var sequence = [];
+
+var p1 = new Promise(function(_, reject) {
+ reject('');
+});
+var p2 = new Promise(function(resolve) {
+ resolve('');
+});
+var p3 = new Promise(function(_, reject) {
+ reject('');
+});
+
+sequence.push(1);
+
+p1.catch(function() {
+ sequence.push(3);
+ assert.sameValue(sequence.length, 3);
+ checkSequence(sequence, 'Expected to be called first.');
+});
+
+Promise.allSettled([p1, p2, p3]).then(function() {
+ sequence.push(6);
+ assert.sameValue(sequence.length, 6);
+ checkSequence(sequence, 'Expected to be called fourth.');
+}).then($DONE, $DONE);
+
+p2.then(function() {
+ sequence.push(4);
+ assert.sameValue(sequence.length, 4);
+ checkSequence(sequence, 'Expected to be called second.');
+});
+
+sequence.push(2);
+
+p3.catch(function() {
+ sequence.push(5);
+ assert.sameValue(sequence.length, 5);
+ checkSequence(sequence, 'Expected to be called third.');
+});
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-with-rejections.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-with-rejections.js
new file mode 100644
index 0000000000..959cbb40d1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence-with-rejections.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Resolution ticks are set in a predictable sequence
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var sequence = [];
+
+var p1 = new Promise(function(_, reject) {
+ reject('foo');
+});
+var p2 = new Promise(function(_, reject) {
+ reject('bar');
+});
+
+sequence.push(1);
+
+p1.catch(function() {
+ sequence.push(3);
+ assert.sameValue(sequence.length, 3);
+ checkSequence(sequence, 'Expected to be called first.');
+}).catch($DONE);
+
+Promise.allSettled([p1, p2]).then(function() {
+ sequence.push(5);
+ assert.sameValue(sequence.length, 5);
+ checkSequence(sequence, 'Expected to be called third.');
+}).then($DONE, $DONE);
+
+p2.catch(function() {
+ sequence.push(4);
+ assert.sameValue(sequence.length, 4);
+ checkSequence(sequence, 'Expected to be called second.');
+}).catch($DONE);
+
+sequence.push(2);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence.js
new file mode 100644
index 0000000000..879d234c1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-sequence.js
@@ -0,0 +1,53 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Resolution ticks are set in a predictable sequence
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var sequence = [];
+
+var p1 = new Promise(function(resolve) {
+ resolve(1);
+});
+var p2 = new Promise(function(resolve) {
+ resolve(2);
+});
+
+sequence.push(1);
+
+p1.then(function() {
+ sequence.push(3);
+ assert.sameValue(sequence.length, 3);
+ checkSequence(sequence, 'Expected to be called first.');
+}).catch($DONE);
+
+Promise.allSettled([p1, p2]).then(function() {
+ sequence.push(5);
+ assert.sameValue(sequence.length, 5);
+ checkSequence(sequence, 'Expected to be called third.');
+}).then($DONE, $DONE);
+
+p2.then(function() {
+ sequence.push(4);
+ assert.sameValue(sequence.length, 4);
+ checkSequence(sequence, 'Expected to be called second.');
+}).catch($DONE);
+
+sequence.push(2);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolved-then-catch-finally.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-then-catch-finally.js
new file mode 100644
index 0000000000..15a987cb7c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolved-then-catch-finally.js
@@ -0,0 +1,70 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: >
+ Resolution is a collection of all the settled values (all fulfilled)
+info: |
+ Runtime Semantics: PerformPromiseAllSettled
+
+ 6. Repeat,
+ ...
+ j. Let steps be the algorithm steps defined in Promise.allSettled Resolve Element Functions.
+ k. Let resolveElement be ! CreateBuiltinFunction(steps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ r. Let rejectSteps be the algorithm steps defined in Promise.allSettled Reject Element Functions.
+ s. Let rejectElement be ! CreateBuiltinFunction(rejectSteps, « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
+ ...
+ z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
+
+ Promise.allSettled Resolve Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "fulfilled").
+ 11. Perform ! CreateDataProperty(obj, "value", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be ! CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+
+ Promise.allSettled Reject Element Functions
+
+ 9. Let obj be ! ObjectCreate(%ObjectPrototype%).
+ 10. Perform ! CreateDataProperty(obj, "status", "rejected").
+ 11. Perform ! CreateDataProperty(obj, "reason", x).
+ 12. Set values[index] to be obj.
+ 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
+ 14. If remainingElementsCount.[[Value]] is 0, then
+ a. Let valuesArray be CreateArrayFromList(values).
+ b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var p0 = Promise.resolve(2).then(v => v + 1);
+var p1 = Promise.reject(21).catch(v => v * 2);
+var p2 = Promise.resolve('nope').then(() => { throw 'foo' });
+var p3 = Promise.reject('yes').then(() => { throw 'nope'; });
+var p4 = Promise.resolve('here').finally(() => 'nope');
+var p5 = Promise.reject('here too').finally(() => 'nope');
+var p6 = Promise.resolve('nope').finally(() => { throw 'finally'; });
+var p7 = Promise.reject('nope').finally(() => { throw 'finally after rejected'; });
+var p8 = Promise.reject(1).then(() => 'nope', () => 0);
+
+Promise.allSettled([p0, p1, p2, p3, p4, p5, p6, p7, p8]).then(function(settled) {
+ checkSettledPromises(settled, [
+ { status: 'fulfilled', value: 3 },
+ { status: 'fulfilled', value: 42 },
+ { status: 'rejected', reason: 'foo' },
+ { status: 'rejected', reason: 'yes' },
+ { status: 'fulfilled', value: 'here' },
+ { status: 'rejected', reason: 'here too' },
+ { status: 'rejected', reason: 'finally' },
+ { status: 'rejected', reason: 'finally after rejected' },
+ { status: 'fulfilled', value: 0 },
+ ], 'settled');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolves-empty-array.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolves-empty-array.js
new file mode 100644
index 0000000000..4ca58b35a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolves-empty-array.js
@@ -0,0 +1,28 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled([]) returns a Promise for an empty array
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+includes: [promiseHelper.js]
+features: [Promise.allSettled]
+---*/
+
+var arg = [];
+
+Promise.allSettled(arg).then(function(result) {
+ checkSettledPromises(result, []);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/resolves-to-array.js b/js/src/tests/test262/built-ins/Promise/allSettled/resolves-to-array.js
new file mode 100644
index 0000000000..27f3419b9c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/resolves-to-array.js
@@ -0,0 +1,29 @@
+// |reftest| async
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled returned a promise resolves into an array
+info: |
+ Runtime Semantics: PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
+
+ 4. Let remainingElementsCount be a new Record { [[Value]]: 1 }.
+ ...
+ 6.d ...
+ ii. Set remainingElementsCount.[[value]] to remainingElementsCount.[[value]] − 1.
+ iii. If remainingElementsCount.[[value]] is 0, then
+ 1. Let valuesArray be CreateArrayFromList(values).
+ 2. Perform ? Call(resultCapability.[[Resolve]], undefined, « valuesArray »).
+ ...
+flags: [async]
+features: [Promise.allSettled]
+---*/
+
+var arg = [];
+
+Promise.allSettled([]).then(function(result) {
+ assert(Array.isArray(result));
+ assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
+ assert.notSameValue(result, arg, 'the resolved array is a new array');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/returns-promise.js b/js/src/tests/test262/built-ins/Promise/allSettled/returns-promise.js
new file mode 100644
index 0000000000..4a57525a6f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/returns-promise.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-promise.allsettled
+description: Promise.allSettled returns a Promise
+info: |
+ Promise.allSettled ( iterable )
+
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ 4. Let iteratorRecord be GetIterator(iterable).
+ 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
+ 6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
+ 7. If result is an abrupt completion, then
+ a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
+ b. IfAbruptRejectPromise(result, promiseCapability).
+ 8. Return Completion(result).
+features: [Promise.allSettled]
+---*/
+
+var p = Promise.allSettled([]);
+
+assert(p instanceof Promise);
+assert.sameValue(Object.getPrototypeOf(p), Promise.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/shell.js b/js/src/tests/test262/built-ins/Promise/allSettled/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/shell.js
diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/species-get-error.js b/js/src/tests/test262/built-ins/Promise/allSettled/species-get-error.js
new file mode 100644
index 0000000000..5f2bf79d86
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Promise/allSettled/species-get-error.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Promise.allSettled() does not retrieve `Symbol.species` property of the `this` value
+esid: sec-promise.allsettled
+info: |
+ 1. Let C be the this value.
+ 2. If Type(C) is not Object, throw a TypeError exception.
+ 3. Let promiseCapability be ? NewPromiseCapability(C).
+ ...
+features: [Promise.allSettled, Symbol.species]
+---*/
+
+function C(executor) {
+ executor(function() {}, function() {});
+}
+Object.defineProperty(C, Symbol.species, {
+ get() {
+ throw new Test262Error('Getter for Symbol.species called');
+ }
+});
+
+C.resolve = function() {
+ throw new Test262Error();
+};
+
+Promise.allSettled.call(C, []);
+
+reportCompare(0, 0);