script: Move operations in window_named_properties::get_own_property_descriptor & webdriver_handlers::clone_an_object into unsafe blocks (#38951)

Testing: Covered by existing tests
Part of https://github.com/servo/servo/issues/35955

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-08-26 23:48:25 +02:00 committed by GitHub
parent 87fe202ded
commit de6feb469a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 87 additions and 57 deletions

View file

@ -89,11 +89,13 @@ unsafe extern "C" fn get_own_property_descriptor(
let cx = unsafe { SafeJSContext::from_ptr(cx) };
if id.is_symbol() {
if id.get().asBits_ == SymbolId(GetWellKnownSymbol(*cx, SymbolCode::toStringTag)).asBits_ {
if id.get().asBits_ ==
SymbolId(unsafe { GetWellKnownSymbol(*cx, SymbolCode::toStringTag) }).asBits_
{
rooted!(in(*cx) let mut rval = UndefinedValue());
"WindowProperties".to_jsval(*cx, rval.handle_mut());
unsafe { "WindowProperties".to_jsval(*cx, rval.handle_mut()) };
set_property_descriptor(
RustMutableHandle::from_raw(desc),
unsafe { RustMutableHandle::from_raw(desc) },
rval.handle(),
JSPROP_READONLY.into(),
unsafe { &mut *is_none },
@ -103,12 +105,15 @@ unsafe extern "C" fn get_own_property_descriptor(
}
let mut found = false;
if !has_property_on_prototype(
*cx,
RustHandle::from_raw(proxy),
RustHandle::from_raw(id),
&mut found,
) {
let lookup_succeeded = unsafe {
has_property_on_prototype(
*cx,
RustHandle::from_raw(proxy),
RustHandle::from_raw(id),
&mut found,
)
};
if !lookup_succeeded {
return false;
}
if found {
@ -136,7 +141,9 @@ unsafe extern "C" fn get_own_property_descriptor(
.expect("global is not a window");
if let Some(obj) = window.NamedGetter(s.into()) {
rooted!(in(*cx) let mut rval = UndefinedValue());
obj.to_jsval(*cx, rval.handle_mut());
unsafe {
obj.to_jsval(*cx, rval.handle_mut());
}
set_property_descriptor(
unsafe { RustMutableHandle::from_raw(desc) },
rval.handle(),