mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
feat(script): enable js::ProxyOptions::setLazyProto
for maybe-cross-origin objects
Setting the lazy proto option allows proxy handlers to provide dynamic prototype objects. This is necessary for the customization of `ProxyTraps::{get,set}PrototypeOf` to actually take effect.
This commit is contained in:
parent
722a239715
commit
bdd20f0139
2 changed files with 15 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3808,7 +3808,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mozjs"
|
name = "mozjs"
|
||||||
version = "0.14.1"
|
version = "0.14.1"
|
||||||
source = "git+https://github.com/servo/rust-mozjs#2e4c6a82c9f94210da7c452bb29de210fb658c1a"
|
source = "git+https://github.com/servo/rust-mozjs#09edacd032fadc861b0cb3a70711a5c8a9bd7f8e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|
|
@ -2874,6 +2874,13 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
unforgeable = CopyUnforgeablePropertiesToInstance(self.descriptor)
|
unforgeable = CopyUnforgeablePropertiesToInstance(self.descriptor)
|
||||||
if self.descriptor.proxy:
|
if self.descriptor.proxy:
|
||||||
|
if self.descriptor.isMaybeCrossOriginObject():
|
||||||
|
proto = "ptr::null_mut()"
|
||||||
|
lazyProto = "true" # Our proxy handler will manage the prototype
|
||||||
|
else:
|
||||||
|
proto = "proto.get()"
|
||||||
|
lazyProto = "false"
|
||||||
|
|
||||||
create = """
|
create = """
|
||||||
let handler: *const libc::c_void =
|
let handler: *const libc::c_void =
|
||||||
RegisterBindings::proxy_handlers::%(concreteType)s
|
RegisterBindings::proxy_handlers::%(concreteType)s
|
||||||
|
@ -2882,8 +2889,9 @@ rooted!(in(*cx) let obj = NewProxyObject(
|
||||||
*cx,
|
*cx,
|
||||||
handler,
|
handler,
|
||||||
Handle::from_raw(UndefinedHandleValue),
|
Handle::from_raw(UndefinedHandleValue),
|
||||||
proto.get(),
|
%(proto)s,
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
|
%(lazyProto)s,
|
||||||
));
|
));
|
||||||
assert!(!obj.is_null());
|
assert!(!obj.is_null());
|
||||||
SetProxyReservedSlot(
|
SetProxyReservedSlot(
|
||||||
|
@ -2892,7 +2900,11 @@ SetProxyReservedSlot(
|
||||||
&PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
|
&PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
|
create = create % {"concreteType": self.descriptor.concreteType,
|
||||||
|
"proto": proto,
|
||||||
|
"lazyProto": lazyProto}
|
||||||
else:
|
else:
|
||||||
|
lazyProto = None
|
||||||
create = """
|
create = """
|
||||||
rooted!(in(*cx) let obj = JS_NewObjectWithGivenProto(
|
rooted!(in(*cx) let obj = JS_NewObjectWithGivenProto(
|
||||||
*cx,
|
*cx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue