mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Changes for spidermomkey upgrade.
This commit is contained in:
parent
f1bb3dcad0
commit
bd77a4043c
16 changed files with 245 additions and 186 deletions
|
@ -1886,7 +1886,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
"name": m.identifier.name,
|
||||
"attr": m,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"is_accessor": "true",
|
||||
"kind": "JSPropertySpec_Kind::NativeAccessor",
|
||||
}
|
||||
for m in descriptor.interface.members if
|
||||
m.isAttr() and m.isStatic() == static
|
||||
|
@ -1906,7 +1906,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
"name": "@@toStringTag",
|
||||
"attr": None,
|
||||
"flags": "JSPROP_READONLY",
|
||||
"is_accessor": "false",
|
||||
"kind": "JSPropertySpec_Kind::Value",
|
||||
})
|
||||
|
||||
def generateArray(self, array, name):
|
||||
|
@ -1963,13 +1963,13 @@ class AttrDefiner(PropertyDefiner):
|
|||
|
||||
def specData(attr):
|
||||
if attr["name"] == "@@toStringTag":
|
||||
return (attr["name"][2:], attr["flags"], attr["is_accessor"],
|
||||
return (attr["name"][2:], attr["flags"], attr["kind"],
|
||||
str_to_const_array(self.descriptor.interface.getClassName()))
|
||||
|
||||
flags = attr["flags"]
|
||||
if self.unforgeable:
|
||||
flags += " | JSPROP_PERMANENT"
|
||||
return (str_to_const_array(attr["attr"].identifier.name), flags, attr["is_accessor"], getter(attr),
|
||||
return (str_to_const_array(attr["attr"].identifier.name), flags, attr["kind"], getter(attr),
|
||||
setter(attr))
|
||||
|
||||
def template(m):
|
||||
|
@ -1977,7 +1977,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
return """ JSPropertySpec {
|
||||
name: JSPropertySpec_Name { symbol_: SymbolCode::%s as usize + 1 },
|
||||
attributes_: (%s) as u8,
|
||||
isAccessor_: (%s),
|
||||
kind_: (%s),
|
||||
u: JSPropertySpec_AccessorsOrValue {
|
||||
value: JSPropertySpec_ValueWrapper {
|
||||
type_: JSPropertySpec_ValueWrapper_Type::String,
|
||||
|
@ -1991,7 +1991,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
return """ JSPropertySpec {
|
||||
name: JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char },
|
||||
attributes_: (%s) as u8,
|
||||
isAccessor_: (%s),
|
||||
kind_: (%s),
|
||||
u: JSPropertySpec_AccessorsOrValue {
|
||||
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
|
||||
getter: JSPropertySpec_Accessor {
|
||||
|
@ -2361,7 +2361,6 @@ static CLASS_OPS: js::jsapi::JSClassOps = js::jsapi::JSClassOps {
|
|||
mayResolve: None,
|
||||
finalize: Some(%(finalizeHook)s),
|
||||
call: None,
|
||||
hasInstance: None,
|
||||
construct: None,
|
||||
trace: Some(%(traceHook)s),
|
||||
};
|
||||
|
@ -3620,7 +3619,6 @@ let traps = ProxyTraps {
|
|||
hasOwn: Some(hasOwn),
|
||||
getOwnEnumerablePropertyKeys: Some(%(getOwnEnumerablePropertyKeys)s),
|
||||
nativeCall: None,
|
||||
hasInstance: None,
|
||||
objectClassIs: None,
|
||||
className: Some(className),
|
||||
fun_toString: None,
|
||||
|
@ -5368,7 +5366,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
}
|
||||
self.cgRoot.prepend(instantiateJSToNativeConversionTemplate(
|
||||
template, templateValues, declType, argument.identifier.name))
|
||||
self.cgRoot.prepend(CGGeneric("rooted!(in(*cx) let value = desc.value);"))
|
||||
self.cgRoot.prepend(CGGeneric("rooted!(in(*cx) let value = desc.value_);"))
|
||||
|
||||
def getArguments(self):
|
||||
args = [(a, process_arg(a.identifier.name, a)) for a in self.arguments]
|
||||
|
@ -5471,7 +5469,8 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleId', 'id'),
|
||||
Argument('RawMutableHandle<PropertyDescriptor>', 'mut desc')]
|
||||
Argument('RawMutableHandle<PropertyDescriptor>', 'mut desc'),
|
||||
Argument('*mut bool', 'is_none')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "getOwnPropertyDescriptor",
|
||||
"bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -5487,12 +5486,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
"""
|
||||
if !proxyhandler::is_platform_object_same_origin(cx, proxy) {
|
||||
if !proxyhandler::cross_origin_get_own_property_helper(
|
||||
cx, proxy, &CROSS_ORIGIN_PROPERTIES, id, desc
|
||||
cx, proxy, &CROSS_ORIGIN_PROPERTIES, id, desc, &mut *is_none
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if desc.obj.is_null() {
|
||||
return proxyhandler::cross_origin_property_fallback(cx, proxy, id, desc);
|
||||
if *is_none {
|
||||
return proxyhandler::cross_origin_property_fallback(cx, proxy, id, desc, &mut *is_none);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5507,8 +5506,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
attrs = "JSPROP_ENUMERATE"
|
||||
if self.descriptor.operations['IndexedSetter'] is None:
|
||||
attrs += " | JSPROP_READONLY"
|
||||
fillDescriptor = ("desc.value = result_root.get();\n"
|
||||
"fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), (%s) as u32);\n"
|
||||
fillDescriptor = ("set_property_descriptor(\n"
|
||||
" MutableHandle::from_raw(desc),\n"
|
||||
" result_root.handle(),\n"
|
||||
" (%s) as u32,\n"
|
||||
" &mut *is_none\n"
|
||||
");\n"
|
||||
"return true;" % attrs)
|
||||
templateValues = {
|
||||
'jsvalRef': 'result_root.handle_mut()',
|
||||
|
@ -5532,8 +5535,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
attrs = " | ".join(attrs)
|
||||
else:
|
||||
attrs = "0"
|
||||
fillDescriptor = ("desc.value = result_root.get();\n"
|
||||
"fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), (%s) as u32);\n"
|
||||
fillDescriptor = ("set_property_descriptor(\n"
|
||||
" MutableHandle::from_raw(desc),\n"
|
||||
" result_root.handle(),\n"
|
||||
" (%s) as u32,\n"
|
||||
" &mut *is_none\n"
|
||||
");\n"
|
||||
"return true;" % attrs)
|
||||
templateValues = {
|
||||
'jsvalRef': 'result_root.handle_mut()',
|
||||
|
@ -5542,7 +5549,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
}
|
||||
|
||||
# See the similar-looking in CGDOMJSProxyHandler_get for the spec quote.
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
condition = "id.is_string() || id.is_int()"
|
||||
if indexedGetter:
|
||||
condition = "index.is_none() && (%s)" % condition
|
||||
# Once we start supporting OverrideBuiltins we need to make
|
||||
|
@ -5569,17 +5576,16 @@ get_expando_object(proxy, expando.handle_mut());
|
|||
let proxy_lt = Handle::from_raw(proxy);
|
||||
let id_lt = Handle::from_raw(id);
|
||||
if !expando.is_null() {
|
||||
if !JS_GetPropertyDescriptorById(*cx, expando.handle().into(), id, desc) {
|
||||
rooted!(in(*cx) let mut ignored = ptr::null_mut::<JSObject>());
|
||||
if !JS_GetPropertyDescriptorById(*cx, expando.handle().into(), id, desc, ignored.handle_mut().into(), is_none) {
|
||||
return false;
|
||||
}
|
||||
if !desc.obj.is_null() {
|
||||
if !*is_none {
|
||||
// Pretend the property lives on the wrapper.
|
||||
desc.obj = proxy.get();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
""" + namedGet + """\
|
||||
desc.obj = ptr::null_mut();
|
||||
return true;"""
|
||||
|
||||
def definition_body(self):
|
||||
|
@ -5628,12 +5634,12 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
if self.descriptor.hasUnforgeableMembers:
|
||||
raise TypeError("Can't handle a named setter on an interface that has "
|
||||
"unforgeables. Figure out how that should work!")
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||
set += ("if id.is_string() || id.is_int() {\n"
|
||||
+ CGIndenter(CGProxyNamedSetter(self.descriptor)).define()
|
||||
+ " return (*opresult).succeed();\n"
|
||||
+ "}\n")
|
||||
elif self.descriptor.operations['NamedGetter']:
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||
set += ("if id.is_string() || id.is_int() {\n"
|
||||
+ CGIndenter(CGProxyNamedGetter(self.descriptor)).define()
|
||||
+ " if result.is_some() {\n"
|
||||
" return (*opresult).failNoNamedSetter();\n"
|
||||
|
@ -5839,7 +5845,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
|||
+ "}\n\n")
|
||||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
condition = "id.is_string() || id.is_int()"
|
||||
if indexedGetter:
|
||||
condition = "index.is_none() && (%s)" % condition
|
||||
if namedGetter:
|
||||
|
@ -5939,7 +5945,7 @@ if !expando.is_null() {
|
|||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
if namedGetter:
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
condition = "id.is_string() || id.is_int()"
|
||||
# From step 1:
|
||||
# If O supports indexed properties and P is an array index, then:
|
||||
#
|
||||
|
@ -6139,7 +6145,7 @@ class CGClassFinalizeHook(CGAbstractClassHook):
|
|||
A hook for finalize, used to release our native object.
|
||||
"""
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSFreeOp', '_fop'), Argument('*mut JSObject', 'obj')]
|
||||
args = [Argument('*mut GCContext', '_cx'), Argument('*mut JSObject', 'obj')]
|
||||
CGAbstractClassHook.__init__(self, descriptor, FINALIZE_HOOK_NAME,
|
||||
'void', args)
|
||||
|
||||
|
@ -6302,6 +6308,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::CallArgs',
|
||||
'js::jsapi::CurrentGlobalOrNull',
|
||||
'js::rust::wrappers::GetPropertyKeys',
|
||||
'js::jsapi::GCContext',
|
||||
'js::jsapi::GetWellKnownSymbol',
|
||||
'js::rust::Handle',
|
||||
'js::jsapi::Handle as RawHandle',
|
||||
|
@ -6320,7 +6327,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::JSCLASS_RESERVED_SLOTS_SHIFT',
|
||||
'js::jsapi::JSClass',
|
||||
'js::jsapi::JSContext',
|
||||
'js::jsapi::JSFreeOp',
|
||||
'js::jsapi::JSFunctionSpec',
|
||||
'js::jsapi::JSITER_HIDDEN',
|
||||
'js::jsapi::JSITER_OWNONLY',
|
||||
|
@ -6345,6 +6351,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::JSPropertySpec_Accessor',
|
||||
'js::jsapi::JSPropertySpec_AccessorsOrValue',
|
||||
'js::jsapi::JSPropertySpec_AccessorsOrValue_Accessors',
|
||||
'js::jsapi::JSPropertySpec_Kind',
|
||||
'js::jsapi::JSPropertySpec_Name',
|
||||
'js::jsapi::JSPropertySpec_ValueWrapper',
|
||||
'js::jsapi::JSPropertySpec_ValueWrapper_Type',
|
||||
|
@ -6414,8 +6421,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::glue::SetProxyReservedSlot',
|
||||
'js::rust::wrappers::NewProxyObject',
|
||||
'js::glue::ProxyTraps',
|
||||
'js::glue::RUST_JSID_IS_INT',
|
||||
'js::glue::RUST_JSID_IS_STRING',
|
||||
'js::rust::wrappers::RUST_SYMBOL_TO_JSID',
|
||||
'js::rust::wrappers::int_to_jsid',
|
||||
'js::glue::UnwrapObjectDynamic',
|
||||
|
@ -6521,7 +6526,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'crate::dom::bindings::inheritance::Castable',
|
||||
'crate::dom::bindings::proxyhandler',
|
||||
'crate::dom::bindings::proxyhandler::ensure_expando_object',
|
||||
'crate::dom::bindings::proxyhandler::fill_property_descriptor',
|
||||
'crate::dom::bindings::proxyhandler::set_property_descriptor',
|
||||
'crate::dom::bindings::proxyhandler::get_expando_object',
|
||||
'crate::dom::bindings::record::Record',
|
||||
'std::ptr::NonNull',
|
||||
|
|
|
@ -53,8 +53,6 @@ use js::error::throw_type_error;
|
|||
use js::glue::GetProxyReservedSlot;
|
||||
use js::glue::JS_GetReservedSlot;
|
||||
use js::glue::{IsWrapper, UnwrapObjectDynamic};
|
||||
use js::glue::{RUST_JSID_IS_INT, RUST_JSID_TO_INT};
|
||||
use js::glue::{RUST_JSID_IS_STRING, RUST_JSID_TO_STRING};
|
||||
use js::jsapi::{Heap, JSContext, JSObject, JSString};
|
||||
use js::jsapi::{IsWindowProxy, JS_DeprecatedStringHasLatin1Chars, JS_NewStringCopyN};
|
||||
use js::jsapi::{
|
||||
|
@ -160,13 +158,13 @@ where
|
|||
///
|
||||
/// Handling of invalid UTF-16 in strings depends on the relevant option.
|
||||
pub unsafe fn jsid_to_string(cx: *mut JSContext, id: HandleId) -> Option<DOMString> {
|
||||
let id_raw = id.into();
|
||||
if RUST_JSID_IS_STRING(id_raw) {
|
||||
return Some(jsstring_to_str(cx, RUST_JSID_TO_STRING(id_raw)));
|
||||
let id_raw = *id;
|
||||
if id_raw.is_string() {
|
||||
return Some(jsstring_to_str(cx, id_raw.to_string()));
|
||||
}
|
||||
|
||||
if RUST_JSID_IS_INT(id_raw) {
|
||||
return Some(RUST_JSID_TO_INT(id_raw).to_string().into());
|
||||
if id_raw.is_int() {
|
||||
return Some(id_raw.to_int().to_string().into());
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
@ -105,7 +105,6 @@ impl InterfaceConstructorBehavior {
|
|||
finalize: None,
|
||||
call: Some(invalid_constructor),
|
||||
construct: Some(invalid_constructor),
|
||||
hasInstance: None, // heycam/webidl#356
|
||||
trace: None,
|
||||
})
|
||||
}
|
||||
|
@ -122,7 +121,6 @@ impl InterfaceConstructorBehavior {
|
|||
finalize: None,
|
||||
call: Some(non_new_constructor),
|
||||
construct: Some(hook),
|
||||
hasInstance: None, // heycam/webidl#356
|
||||
trace: None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ use js::jsval::ObjectValue;
|
|||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::JS_AlreadyHasOwnPropertyById;
|
||||
use js::rust::wrappers::JS_NewObjectWithGivenProto;
|
||||
use js::rust::wrappers::{AppendToIdVector, RUST_INTERNED_STRING_TO_JSID};
|
||||
use js::rust::{get_context_realm, Handle, HandleObject, MutableHandle, MutableHandleObject};
|
||||
use js::rust::wrappers::{AppendToIdVector, RUST_INTERNED_STRING_TO_JSID, SetDataPropertyDescriptor};
|
||||
use js::rust::{get_context_realm, Handle, HandleObject, HandleValue, MutableHandle, MutableHandleObject};
|
||||
use std::{ffi::CStr, os::raw::c_char, ptr};
|
||||
|
||||
/// Determine if this id shadows any existing properties for this proxy.
|
||||
|
@ -189,15 +189,16 @@ pub unsafe fn ensure_expando_object(
|
|||
|
||||
/// Set the property descriptor's object to `obj` and set it to enumerable,
|
||||
/// and writable if `readonly` is true.
|
||||
pub fn fill_property_descriptor(
|
||||
mut desc: MutableHandle<PropertyDescriptor>,
|
||||
obj: *mut JSObject,
|
||||
pub fn set_property_descriptor(
|
||||
desc: MutableHandle<PropertyDescriptor>,
|
||||
value: HandleValue,
|
||||
attrs: u32,
|
||||
is_none: &mut bool,
|
||||
) {
|
||||
desc.obj = obj;
|
||||
desc.attrs = attrs;
|
||||
desc.getter = None;
|
||||
desc.setter = None;
|
||||
unsafe {
|
||||
SetDataPropertyDescriptor(desc, value, attrs);
|
||||
}
|
||||
*is_none = false;
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#isplatformobjectsameorigin-(-o-)>
|
||||
|
@ -333,12 +334,14 @@ pub unsafe extern "C" fn maybe_cross_origin_set_rawcx(
|
|||
// OrdinarySet
|
||||
// <https://tc39.es/ecma262/#sec-ordinaryset>
|
||||
rooted!(in(*cx) let mut own_desc = PropertyDescriptor::default());
|
||||
let mut is_none = false;
|
||||
if !InvokeGetOwnPropertyDescriptor(
|
||||
GetProxyHandler(*proxy),
|
||||
*cx,
|
||||
proxy,
|
||||
id,
|
||||
own_desc.handle_mut().into(),
|
||||
&mut is_none,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
@ -439,26 +442,28 @@ pub unsafe fn cross_origin_get(
|
|||
) -> bool {
|
||||
// > 1. Let `desc` be `? O.[[GetOwnProperty]](P)`.
|
||||
rooted!(in(*cx) let mut descriptor = PropertyDescriptor::default());
|
||||
let mut is_none = false;
|
||||
if !InvokeGetOwnPropertyDescriptor(
|
||||
GetProxyHandler(*proxy),
|
||||
*cx,
|
||||
proxy,
|
||||
id,
|
||||
descriptor.handle_mut().into(),
|
||||
&mut is_none,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// > 2. Assert: `desc` is not undefined.
|
||||
assert!(
|
||||
!descriptor.obj.is_null(),
|
||||
!is_none,
|
||||
"Callees should throw in all cases when they are not finding \
|
||||
a property decriptor"
|
||||
);
|
||||
|
||||
// > 3. If `! IsDataDescriptor(desc)` is true, then return `desc.[[Value]]`.
|
||||
if is_data_descriptor(&descriptor) {
|
||||
vp.set(descriptor.value);
|
||||
vp.set(descriptor.value_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -504,19 +509,21 @@ pub unsafe fn cross_origin_set(
|
|||
) -> bool {
|
||||
// > 1. Let desc be ? O.[[GetOwnProperty]](P).
|
||||
rooted!(in(*cx) let mut descriptor = PropertyDescriptor::default());
|
||||
let mut is_none = false;
|
||||
if !InvokeGetOwnPropertyDescriptor(
|
||||
GetProxyHandler(*proxy),
|
||||
*cx,
|
||||
proxy,
|
||||
id,
|
||||
descriptor.handle_mut().into(),
|
||||
&mut is_none,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// > 2. Assert: desc is not undefined.
|
||||
assert!(
|
||||
!descriptor.obj.is_null(),
|
||||
!is_none,
|
||||
"Callees should throw in all cases when they are not finding \
|
||||
a property decriptor"
|
||||
);
|
||||
|
@ -557,32 +564,25 @@ pub unsafe fn cross_origin_set(
|
|||
}
|
||||
|
||||
unsafe fn get_getter_object(d: &PropertyDescriptor, out: RawMutableHandleObject) {
|
||||
if (d.attrs & jsapi::JSPROP_GETTER as u32) != 0 {
|
||||
out.set(std::mem::transmute(d.getter));
|
||||
if d.hasGetter_() {
|
||||
out.set(std::mem::transmute(d.getter_));
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn get_setter_object(d: &PropertyDescriptor, out: RawMutableHandleObject) {
|
||||
if (d.attrs & jsapi::JSPROP_SETTER as u32) != 0 {
|
||||
out.set(std::mem::transmute(d.setter));
|
||||
if d.hasSetter_() {
|
||||
out.set(std::mem::transmute(d.setter_));
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://tc39.es/ecma262/#sec-isaccessordescriptor>
|
||||
fn is_accessor_descriptor(d: &PropertyDescriptor) -> bool {
|
||||
d.attrs & (jsapi::JSPROP_GETTER as u32 | jsapi::JSPROP_SETTER as u32) != 0
|
||||
d.hasSetter_() || d.hasGetter_()
|
||||
}
|
||||
|
||||
/// <https://tc39.es/ecma262/#sec-isdatadescriptor>
|
||||
fn is_data_descriptor(d: &PropertyDescriptor) -> bool {
|
||||
let is_accessor = is_accessor_descriptor(d);
|
||||
let is_generic = d.attrs &
|
||||
(jsapi::JSPROP_GETTER as u32 |
|
||||
jsapi::JSPROP_SETTER as u32 |
|
||||
jsapi::JSPROP_IGNORE_READONLY |
|
||||
jsapi::JSPROP_IGNORE_VALUE) ==
|
||||
jsapi::JSPROP_IGNORE_READONLY | jsapi::JSPROP_IGNORE_VALUE;
|
||||
!is_accessor && !is_generic
|
||||
d.hasWritable_() || d.hasValue_()
|
||||
}
|
||||
|
||||
/// Evaluate `CrossOriginGetOwnPropertyHelper(proxy, id) != null`.
|
||||
|
@ -621,7 +621,8 @@ pub unsafe fn cross_origin_get_own_property_helper(
|
|||
proxy: RawHandleObject,
|
||||
cross_origin_properties: &'static CrossOriginProperties,
|
||||
id: RawHandleId,
|
||||
mut desc: RawMutableHandle<PropertyDescriptor>,
|
||||
desc: RawMutableHandle<PropertyDescriptor>,
|
||||
is_none: &mut bool,
|
||||
) -> bool {
|
||||
rooted!(in(*cx) let mut holder = ptr::null_mut::<JSObject>());
|
||||
|
||||
|
@ -632,15 +633,7 @@ pub unsafe fn cross_origin_get_own_property_helper(
|
|||
holder.handle_mut().into(),
|
||||
);
|
||||
|
||||
if !JS_GetOwnPropertyDescriptorById(*cx, holder.handle().into(), id, desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if !desc.obj.is_null() {
|
||||
desc.obj = proxy.get();
|
||||
}
|
||||
|
||||
true
|
||||
return JS_GetOwnPropertyDescriptorById(*cx, holder.handle().into(), id, desc, is_none);
|
||||
}
|
||||
|
||||
/// Implementation of [`CrossOriginPropertyFallback`].
|
||||
|
@ -651,24 +644,24 @@ pub unsafe fn cross_origin_get_own_property_helper(
|
|||
/// [`CrossOriginPropertyFallback`]: https://html.spec.whatwg.org/multipage/#crossoriginpropertyfallback-(-p-)
|
||||
pub unsafe fn cross_origin_property_fallback(
|
||||
cx: SafeJSContext,
|
||||
proxy: RawHandleObject,
|
||||
_proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
mut desc: RawMutableHandle<PropertyDescriptor>,
|
||||
desc: RawMutableHandle<PropertyDescriptor>,
|
||||
is_none: &mut bool,
|
||||
) -> bool {
|
||||
assert!(desc.obj.is_null(), "why are we being called?");
|
||||
assert!(*is_none, "why are we being called?");
|
||||
|
||||
// > 1. If P is `then`, `@@toStringTag`, `@@hasInstance`, or
|
||||
// > `@@isConcatSpreadable`, then return `PropertyDescriptor{ [[Value]]:
|
||||
// > undefined, [[Writable]]: false, [[Enumerable]]: false,
|
||||
// > [[Configurable]]: true }`.
|
||||
if is_cross_origin_allowlisted_prop(cx, id) {
|
||||
*desc = PropertyDescriptor {
|
||||
getter: None,
|
||||
setter: None,
|
||||
value: UndefinedValue(),
|
||||
attrs: jsapi::JSPROP_READONLY as u32,
|
||||
obj: proxy.get(),
|
||||
};
|
||||
set_property_descriptor(
|
||||
MutableHandle::from_raw(desc),
|
||||
HandleValue::undefined(),
|
||||
jsapi::JSPROP_READONLY as u32,
|
||||
is_none,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -695,7 +688,7 @@ unsafe fn is_cross_origin_allowlisted_prop(cx: SafeJSContext, id: RawHandleId) -
|
|||
);
|
||||
// `jsid`s containing `JS::Symbol *` can be compared by
|
||||
// referential equality
|
||||
allowed_id.get().asBits == id.asBits
|
||||
allowed_id.get().asBits_ == id.asBits_
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use js::jsval::ObjectValue;
|
|||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::GetPropertyKeys;
|
||||
use js::rust::wrappers::JS_DefineUCProperty2;
|
||||
use js::rust::wrappers::JS_GetOwnPropertyDescriptorById;
|
||||
use js::jsapi::glue::JS_GetOwnPropertyDescriptorById;
|
||||
use js::rust::wrappers::JS_GetPropertyById;
|
||||
use js::rust::wrappers::JS_IdToValue;
|
||||
use js::rust::HandleId;
|
||||
|
@ -135,12 +135,13 @@ where
|
|||
rooted!(in(cx) let id = *id);
|
||||
rooted!(in(cx) let mut desc = PropertyDescriptor::default());
|
||||
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, object.handle(), id.handle(), desc.handle_mut())
|
||||
let mut is_none = false;
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, object.handle().into(), id.handle().into(), desc.handle_mut().into(), &mut is_none)
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
|
||||
if (JSPROP_ENUMERATE as u32) & desc.attrs == 0 {
|
||||
if !desc.enumerable_() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,6 +306,7 @@ pub fn write(
|
|||
let policy = CloneDataPolicy {
|
||||
allowIntraClusterClonableSharedObjects_: false,
|
||||
allowSharedMemoryObjects_: false,
|
||||
allowErrorStackFrames_: false,
|
||||
};
|
||||
let result = JS_WriteStructuredClone(
|
||||
*cx,
|
||||
|
@ -382,6 +383,7 @@ pub fn read(
|
|||
&CloneDataPolicy {
|
||||
allowIntraClusterClonableSharedObjects_: false,
|
||||
allowSharedMemoryObjects_: false,
|
||||
allowErrorStackFrames_: false,
|
||||
},
|
||||
&STRUCTURED_CLONE_CALLBACKS,
|
||||
sc_holder_ptr as *mut raw::c_void,
|
||||
|
|
|
@ -82,7 +82,7 @@ use js::jsapi::{
|
|||
GCTraceKindToAscii, Heap, JSObject, JSScript, JSString, JSTracer, JobQueue, TraceKind,
|
||||
};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::{GCMethods, Handle, Runtime};
|
||||
use js::rust::{GCMethods, Handle, Runtime, Stencil};
|
||||
use js::typedarray::TypedArray;
|
||||
use js::typedarray::TypedArrayElement;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
|
@ -677,6 +677,7 @@ unsafe_no_jsmanaged_fields!(MediaMetadata);
|
|||
unsafe_no_jsmanaged_fields!(WebrenderIpcSender);
|
||||
unsafe_no_jsmanaged_fields!(StreamConsumer);
|
||||
unsafe_no_jsmanaged_fields!(DocumentAnimationSet);
|
||||
unsafe_no_jsmanaged_fields!(Stencil);
|
||||
|
||||
unsafe impl<'a> JSTraceable for &'a str {
|
||||
#[inline]
|
||||
|
|
|
@ -19,10 +19,8 @@ use crate::script_runtime::JSContext as SafeJSContext;
|
|||
use js::conversions::ToJSValConvertible;
|
||||
use js::glue::JS_GetReservedSlot;
|
||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||
use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic, RUST_JSID_TO_INT, RUST_JSID_TO_STRING};
|
||||
use js::glue::{
|
||||
RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID_IS_INT, RUST_JSID_IS_STRING, RUST_JSID_IS_VOID,
|
||||
};
|
||||
use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic};
|
||||
use js::glue::RUST_FUNCTION_VALUE_TO_JITINFO;
|
||||
use js::jsapi::HandleId as RawHandleId;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector;
|
||||
|
@ -192,16 +190,16 @@ pub unsafe fn get_property_on_prototype(
|
|||
/// Get an array index from the given `jsid`. Returns `None` if the given
|
||||
/// `jsid` is not an integer.
|
||||
pub unsafe fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32> {
|
||||
let raw_id = id.into();
|
||||
if RUST_JSID_IS_INT(raw_id) {
|
||||
return Some(RUST_JSID_TO_INT(raw_id) as u32);
|
||||
let raw_id = *id;
|
||||
if raw_id.is_int() {
|
||||
return Some(raw_id.to_int() as u32);
|
||||
}
|
||||
|
||||
if RUST_JSID_IS_VOID(raw_id) || !RUST_JSID_IS_STRING(raw_id) {
|
||||
if raw_id.is_void() || !raw_id.is_string() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let atom = RUST_JSID_TO_STRING(raw_id) as *mut JSAtom;
|
||||
let atom = raw_id.to_string() as *mut JSAtom;
|
||||
let s = AtomToLinearString(atom);
|
||||
if GetLinearStringLength(s) == 0 {
|
||||
return None;
|
||||
|
@ -451,12 +449,12 @@ pub unsafe extern "C" fn resolve_global(
|
|||
if *rval {
|
||||
return true;
|
||||
}
|
||||
if !RUST_JSID_IS_STRING(id) {
|
||||
if !id.is_string() {
|
||||
*rval = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
let string = RUST_JSID_TO_STRING(id);
|
||||
let string = id.to_string();
|
||||
if !JS_DeprecatedStringHasLatin1Chars(string) {
|
||||
*rval = false;
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue