mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Implement the delete proxy trap (fixes #2213).
This commit is contained in:
parent
1f04ce807d
commit
6b44f92c4f
3 changed files with 23 additions and 4 deletions
|
@ -2061,7 +2061,7 @@ let traps = ProxyTraps {
|
||||||
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
||||||
defineProperty: Some(defineProperty),
|
defineProperty: Some(defineProperty),
|
||||||
getOwnPropertyNames: ptr::null(),
|
getOwnPropertyNames: ptr::null(),
|
||||||
delete_: None,
|
delete_: Some(delete_),
|
||||||
enumerate: ptr::null(),
|
enumerate: ptr::null(),
|
||||||
|
|
||||||
has: None,
|
has: None,
|
||||||
|
@ -4541,7 +4541,7 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::proxyhandler',
|
'dom::bindings::proxyhandler',
|
||||||
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
||||||
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
|
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
|
||||||
'dom::bindings::proxyhandler::{getPropertyDescriptor}',
|
'dom::bindings::proxyhandler::{delete_, getPropertyDescriptor}',
|
||||||
'dom::bindings::str::ByteString',
|
'dom::bindings::str::ByteString',
|
||||||
'page::JSPageInfo',
|
'page::JSPageInfo',
|
||||||
'libc',
|
'libc',
|
||||||
|
|
|
@ -10,7 +10,8 @@ use js::jsapi::{JS_GetPropertyDescriptorById, JS_NewUCString, JS_malloc, JS_free
|
||||||
use js::jsapi::{JSBool, JS_DefinePropertyById, JS_NewObjectWithGivenProto};
|
use js::jsapi::{JSBool, JS_DefinePropertyById, JS_NewObjectWithGivenProto};
|
||||||
use js::jsapi::{JS_ReportErrorFlagsAndNumber, JS_StrictPropertyStub};
|
use js::jsapi::{JS_ReportErrorFlagsAndNumber, JS_StrictPropertyStub};
|
||||||
use js::jsapi::{JSREPORT_WARNING, JSREPORT_STRICT, JSREPORT_STRICT_MODE_ERROR};
|
use js::jsapi::{JSREPORT_WARNING, JSREPORT_STRICT, JSREPORT_STRICT_MODE_ERROR};
|
||||||
use js::jsval::ObjectValue;
|
use js::jsapi::JS_DeletePropertyById2;
|
||||||
|
use js::jsval::{UndefinedValue, ObjectValue};
|
||||||
use js::glue::GetProxyExtra;
|
use js::glue::GetProxyExtra;
|
||||||
use js::glue::{GetObjectProto, GetObjectParent, SetProxyExtra, GetProxyHandler};
|
use js::glue::{GetObjectProto, GetObjectParent, SetProxyExtra, GetProxyHandler};
|
||||||
use js::glue::InvokeGetOwnPropertyDescriptor;
|
use js::glue::InvokeGetOwnPropertyDescriptor;
|
||||||
|
@ -78,6 +79,24 @@ pub extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
defineProperty_(cx, proxy, id, desc)
|
defineProperty_(cx, proxy, id, desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
|
bp: *mut bool) -> JSBool {
|
||||||
|
unsafe {
|
||||||
|
let expando = EnsureExpandoObject(cx, proxy);
|
||||||
|
if expando.is_null() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut value = UndefinedValue();
|
||||||
|
if JS_DeletePropertyById2(cx, expando, id, &mut value) == 0 {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*bp = value.to_boolean();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn _obj_toString(cx: *mut JSContext, className: *libc::c_char) -> *mut JSString {
|
pub fn _obj_toString(cx: *mut JSContext, className: *libc::c_char) -> *mut JSString {
|
||||||
unsafe {
|
unsafe {
|
||||||
let name = str::raw::from_c_str(className);
|
let name = str::raw::from_c_str(className);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 718a634f8ce07596844e56c3b53399d9d01bab06
|
Subproject commit 6fa1d8f73287056adbac9e9df90308e04cca6eb4
|
Loading…
Add table
Add a link
Reference in a new issue