Skip to content

Commit

Permalink
Implement the delete proxy trap (fixes #2213).
Browse files Browse the repository at this point in the history
  • Loading branch information
ngsankha authored and Ms2ger committed Jul 29, 2014
1 parent 1f04ce8 commit 6b44f92
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -2061,7 +2061,7 @@ def definition_body(self):
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
defineProperty: Some(defineProperty),
getOwnPropertyNames: ptr::null(),
delete_: None,
delete_: Some(delete_),
enumerate: ptr::null(),
has: None,
Expand Down Expand Up @@ -4541,7 +4541,7 @@ def __init__(self, config, prefix, webIDLFile):
'dom::bindings::proxyhandler',
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
'dom::bindings::proxyhandler::{getPropertyDescriptor}',
'dom::bindings::proxyhandler::{delete_, getPropertyDescriptor}',
'dom::bindings::str::ByteString',
'page::JSPageInfo',
'libc',
Expand Down
21 changes: 20 additions & 1 deletion src/components/script/dom/bindings/proxyhandler.rs
Expand Up @@ -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::{JS_ReportErrorFlagsAndNumber, JS_StrictPropertyStub};
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::{GetObjectProto, GetObjectParent, SetProxyExtra, GetProxyHandler};
use js::glue::InvokeGetOwnPropertyDescriptor;
Expand Down Expand Up @@ -78,6 +79,24 @@ pub extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
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 {
unsafe {
let name = str::raw::from_c_str(className);
Expand Down
2 changes: 1 addition & 1 deletion src/support/spidermonkey/rust-mozjs
Submodule rust-mozjs updated 1 files
+21 −0 jsval.rs

0 comments on commit 6b44f92

Please sign in to comment.