Truly independent web browser
LibJS: Do not wrap promises returned from Promise.try callbacks
Andreas Kling8079f77458a6
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs b/Libraries/LibJS/Rust/src/runtime/promise_constructor.rsindex 43f2612fa22..6c7b9d4b43c 100644--- a/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs+++ b/Libraries/LibJS/Rust/src/runtime/promise_constructor.rs@@ -833,35 +833,35 @@ impl PromiseConstructor {args.push(vm.argument(index));}- // 1. Let C be the this value.+ // 1. Let ctor be the this value.let constructor = vm.this_value();- // 2. If C is not an Object, throw a TypeError exception.+ // 2. If ctor is not an Object, throw a TypeError exception.if !constructor.is_object() {return vm.throw_completion(ErrorKind::TypeError, ErrorType::NotAnObject, &[&constructor]);}- // 3. Let promiseCapability be ? NewPromiseCapability(C).- let promise_capability = new_promise_capability(vm, constructor)?;-- // 4. Let status be Completion(Call(callback, undefined, args)).+ // 3. Let status be Completion(Call(callback, undefined, args)).let status = call(vm, callback, Value::UNDEFINED, &args.to_vec());match status {- // 5. If status is an abrupt completion, then+ // 4. If status is an abrupt completion, thenErr(throw) => {- // a. Perform ? Call(promiseCapability.[[Reject]], undefined, « status.[[Value]] »).+ // a. Let promiseCapability be ? NewPromiseCapability(ctor).+ let promise_capability = new_promise_capability(vm, constructor)?;++ // b. Perform ? Call(promiseCapability.[[Reject]], undefined, « status.[[Value]] »).call_function_object(vm, promise_capability.reject(), Value::UNDEFINED, &[throw.value()])?;++ // c. Return promiseCapability.[[Promise]].+ Ok(Value::from_object(promise_capability.promise()))}- // 6. Else,+ // 5. Else,Ok(value) => {- // a. Perform ? Call(promiseCapability.[[Resolve]], undefined, « status.[[Value]] »).- call_function_object(vm, promise_capability.resolve(), Value::UNDEFINED, &[value])?;+ // a. Return ? PromiseResolve(ctor, ! status).+ Ok(Value::from_object(promise_resolve(vm, constructor.as_object(), value)?))}}-- // 7. Return promiseCapability.[[Promise]].- Ok(Value::from_object(promise_capability.promise()))}// 27.2.4.9 Promise.withResolvers ( ), https://tc39.es/ecma262/#sec-promise.withResolvers