mirror of
https://github.com/servo/servo.git
synced 2025-07-17 12:23:40 +01:00
script: Correctly convert a jsval to a Promise
(#36403)
Fixes an oversight of #36097, in which converting to a Promise would fail if the value passed wasn't actually a Promise, while in binding code we actually call `Promise::new_resolved` on the value. Testing: There are wpt tests that should pass now --------- Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
parent
3b41a16fcf
commit
64b401696a
2 changed files with 6 additions and 7 deletions
|
@ -411,10 +411,12 @@ impl FromJSValConvertibleRc for Promise {
|
||||||
return Ok(ConversionResult::Failure("not an object".into()));
|
return Ok(ConversionResult::Failure("not an object".into()));
|
||||||
}
|
}
|
||||||
rooted!(in(cx) let obj = value.get().to_object());
|
rooted!(in(cx) let obj = value.get().to_object());
|
||||||
if !IsPromiseObject(obj.handle()) {
|
|
||||||
return Ok(ConversionResult::Failure("not a promise".into()));
|
let cx = SafeJSContext::from_ptr(cx);
|
||||||
}
|
let in_realm_proof = AlreadyInRealm::assert_for_cx(cx);
|
||||||
let promise = Promise::new_with_js_promise(obj.handle(), SafeJSContext::from_ptr(cx));
|
let global_scope = GlobalScope::from_context(*cx, InRealm::Already(&in_realm_proof));
|
||||||
|
|
||||||
|
let promise = Promise::new_resolved(&global_scope, cx, *obj, CanGc::note());
|
||||||
Ok(ConversionResult::Success(promise))
|
Ok(ConversionResult::Success(promise))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
[ClipboardItem({string, Blob}) succeeds with different types]
|
[ClipboardItem({string, Blob}) succeeds with different types]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[ClipboardItem() succeeds with empty options]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[types() returns correct values]
|
[types() returns correct values]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue