| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2022-01-31 13:07:22 -05:00
										 |  |  |  * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/AbstractOperations.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | #include <LibJS/Runtime/AggregateError.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | #include <LibJS/Runtime/Array.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/GlobalObject.h>
 | 
					
						
							| 
									
										
										
										
											2022-10-02 10:59:22 +01:00
										 |  |  | #include <LibJS/Runtime/PromiseCapability.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | #include <LibJS/Runtime/PromiseResolvingElementFunctions.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 16:22:47 +01:00
										 |  |  | void PromiseValueList::visit_edges(Visitor& visitor) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Cell::visit_edges(visitor); | 
					
						
							|  |  |  |     for (auto& val : m_values) | 
					
						
							|  |  |  |         visitor.visit(val); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseResolvingElementFunction::PromiseResolvingElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype) | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  |     : NativeFunction(prototype) | 
					
						
							|  |  |  |     , m_index(index) | 
					
						
							|  |  |  |     , m_values(values) | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  |     , m_capability(capability) | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  |     , m_remaining_elements(remaining_elements) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-16 00:20:49 +01:00
										 |  |  | void PromiseResolvingElementFunction::initialize(Realm& realm) | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-08-16 00:20:49 +01:00
										 |  |  |     Base::initialize(realm); | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  |     define_direct_property(vm().names.length, Value(1), Attribute::Configurable); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-20 21:16:30 +01:00
										 |  |  | ThrowCompletionOr<Value> PromiseResolvingElementFunction::call() | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_already_called) | 
					
						
							|  |  |  |         return js_undefined(); | 
					
						
							|  |  |  |     m_already_called = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  |     return resolve_element(); | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor) | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     Base::visit_edges(visitor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     visitor.visit(&m_values); | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  |     visitor.visit(m_capability); | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  |     visitor.visit(&m_remaining_elements); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAllResolveElementFunction* PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements) | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-08-27 00:54:55 +01:00
										 |  |  |     return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype) | 
					
						
							|  |  |  |     : PromiseResolvingElementFunction(index, values, capability, remaining_elements, prototype) | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-04 22:04:22 +01:00
										 |  |  | ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element() | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     auto& vm = this->vm(); | 
					
						
							| 
									
										
										
										
											2022-08-22 19:00:49 +01:00
										 |  |  |     auto& realm = *vm.current_realm(); | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 8. Set values[index] to x.
 | 
					
						
							| 
									
										
										
										
											2021-09-11 22:16:30 +02:00
										 |  |  |     m_values.values()[m_index] = vm.argument(0); | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 9. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
 | 
					
						
							|  |  |  |     // 10. If remainingElementsCount.[[Value]] is 0, then
 | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  |     if (--m_remaining_elements.value == 0) { | 
					
						
							| 
									
										
										
										
											2022-05-02 20:54:39 +02:00
										 |  |  |         // a. Let valuesArray be CreateArrayFromList(values).
 | 
					
						
							| 
									
										
										
										
											2022-12-13 20:49:49 +00:00
										 |  |  |         auto values_array = Array::create_from(realm, m_values.values()); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  |         return JS::call(vm, *m_capability->resolve(), js_undefined(), values_array); | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 11. Return undefined.
 | 
					
						
							| 
									
										
										
										
											2021-08-21 15:23:12 -04:00
										 |  |  |     return js_undefined(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAllSettledResolveElementFunction* PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements) | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-08-27 00:54:55 +01:00
										 |  |  |     return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype) | 
					
						
							|  |  |  |     : PromiseResolvingElementFunction(index, values, capability, remaining_elements, prototype) | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-04 22:04:22 +01:00
										 |  |  | ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_element() | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     auto& vm = this->vm(); | 
					
						
							| 
									
										
										
										
											2022-08-22 19:00:49 +01:00
										 |  |  |     auto& realm = *vm.current_realm(); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-02 20:54:39 +02:00
										 |  |  |     // 9. Let obj be OrdinaryObjectCreate(%Object.prototype%).
 | 
					
						
							| 
									
										
										
										
											2022-08-27 00:54:55 +01:00
										 |  |  |     auto* object = Object::create(realm, realm.intrinsics().object_prototype()); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "fulfilled").
 | 
					
						
							| 
									
										
										
										
											2022-12-06 22:17:27 +00:00
										 |  |  |     MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "fulfilled"sv))); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // 11. Perform ! CreateDataPropertyOrThrow(obj, "value", x).
 | 
					
						
							| 
									
										
										
										
											2021-10-03 01:18:46 +01:00
										 |  |  |     MUST(object->create_data_property_or_throw(vm.names.value, vm.argument(0))); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 12. Set values[index] to obj.
 | 
					
						
							| 
									
										
										
										
											2021-09-11 22:16:30 +02:00
										 |  |  |     m_values.values()[m_index] = object; | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
 | 
					
						
							|  |  |  |     // 14. If remainingElementsCount.[[Value]] is 0, then
 | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  |     if (--m_remaining_elements.value == 0) { | 
					
						
							| 
									
										
										
										
											2022-05-02 20:54:39 +02:00
										 |  |  |         // a. Let valuesArray be CreateArrayFromList(values).
 | 
					
						
							| 
									
										
										
										
											2022-12-13 20:49:49 +00:00
										 |  |  |         auto values_array = Array::create_from(realm, m_values.values()); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  |         return JS::call(vm, *m_capability->resolve(), js_undefined(), values_array); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 15. Return undefined.
 | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  |     return js_undefined(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAllSettledRejectElementFunction* PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements) | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-08-27 00:54:55 +01:00
										 |  |  |     return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype) | 
					
						
							|  |  |  |     : PromiseResolvingElementFunction(index, values, capability, remaining_elements, prototype) | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-04 22:04:22 +01:00
										 |  |  | ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element() | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     auto& vm = this->vm(); | 
					
						
							| 
									
										
										
										
											2022-08-22 19:00:49 +01:00
										 |  |  |     auto& realm = *vm.current_realm(); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-02 20:54:39 +02:00
										 |  |  |     // 9. Let obj be OrdinaryObjectCreate(%Object.prototype%).
 | 
					
						
							| 
									
										
										
										
											2022-08-27 00:54:55 +01:00
										 |  |  |     auto* object = Object::create(realm, realm.intrinsics().object_prototype()); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // 10. Perform ! CreateDataPropertyOrThrow(obj, "status", "rejected").
 | 
					
						
							| 
									
										
										
										
											2022-12-06 22:17:27 +00:00
										 |  |  |     MUST(object->create_data_property_or_throw(vm.names.status, PrimitiveString::create(vm, "rejected"sv))); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // 11. Perform ! CreateDataPropertyOrThrow(obj, "reason", x).
 | 
					
						
							| 
									
										
										
										
											2021-10-03 01:18:46 +01:00
										 |  |  |     MUST(object->create_data_property_or_throw(vm.names.reason, vm.argument(0))); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 12. Set values[index] to obj.
 | 
					
						
							| 
									
										
										
										
											2021-09-11 22:16:30 +02:00
										 |  |  |     m_values.values()[m_index] = object; | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 13. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
 | 
					
						
							|  |  |  |     // 14. If remainingElementsCount.[[Value]] is 0, then
 | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  |     if (--m_remaining_elements.value == 0) { | 
					
						
							| 
									
										
										
										
											2022-05-02 20:54:39 +02:00
										 |  |  |         // a. Let valuesArray be CreateArrayFromList(values).
 | 
					
						
							| 
									
										
										
										
											2022-12-13 20:49:49 +00:00
										 |  |  |         auto values_array = Array::create_from(realm, m_values.values()); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // b. Return ? Call(promiseCapability.[[Resolve]], undefined, « valuesArray »).
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  |         return JS::call(vm, *m_capability->resolve(), js_undefined(), values_array); | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 15. Return undefined.
 | 
					
						
							| 
									
										
										
										
											2021-08-21 17:00:48 -04:00
										 |  |  |     return js_undefined(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAnyRejectElementFunction* PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements) | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-08-27 00:54:55 +01:00
										 |  |  |     return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype()); | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  | PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype) | 
					
						
							|  |  |  |     : PromiseResolvingElementFunction(index, errors, capability, remaining_elements, prototype) | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-04 22:04:22 +01:00
										 |  |  | ThrowCompletionOr<Value> PromiseAnyRejectElementFunction::resolve_element() | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     auto& vm = this->vm(); | 
					
						
							| 
									
										
										
										
											2022-08-22 19:00:49 +01:00
										 |  |  |     auto& realm = *vm.current_realm(); | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 8. Set errors[index] to x.
 | 
					
						
							| 
									
										
										
										
											2021-09-11 22:16:30 +02:00
										 |  |  |     m_values.values()[m_index] = vm.argument(0); | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |     // 9. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
 | 
					
						
							|  |  |  |     // 10. If remainingElementsCount.[[Value]] is 0, then
 | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  |     if (--m_remaining_elements.value == 0) { | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |         // a. Let error be a newly created AggregateError object.
 | 
					
						
							| 
									
										
										
										
											2022-12-13 20:49:49 +00:00
										 |  |  |         auto error = AggregateError::create(realm); | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-02 20:54:39 +02:00
										 |  |  |         // b. Perform ! DefinePropertyOrThrow(error, "errors", PropertyDescriptor { [[Configurable]]: true, [[Enumerable]]: false, [[Writable]]: true, [[Value]]: CreateArrayFromList(errors) }).
 | 
					
						
							| 
									
										
										
										
											2022-12-13 20:49:49 +00:00
										 |  |  |         auto errors_array = Array::create_from(realm, m_values.values()); | 
					
						
							| 
									
										
										
										
											2021-10-03 01:35:36 +01:00
										 |  |  |         MUST(error->define_property_or_throw(vm.names.errors, { .value = errors_array, .writable = true, .enumerable = false, .configurable = true })); | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 00:33:16 +00:00
										 |  |  |         // c. Return ? Call(promiseCapability.[[Reject]], undefined, « error »).
 | 
					
						
							| 
									
										
										
										
											2022-10-02 12:11:30 +01:00
										 |  |  |         return JS::call(vm, *m_capability->reject(), js_undefined(), error); | 
					
						
							| 
									
										
										
										
											2021-08-21 16:43:38 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return js_undefined(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-21 13:41:32 -04:00
										 |  |  | } |