Auto merge of #9602 - servo:bc-prop, r=nox

Use JS_GetOwnPropertyDescriptorById in BrowserContext (fixes #6984).

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9602)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-02-11 18:22:59 +05:30
commit 3703e6d4f6

View file

@ -19,9 +19,8 @@ use js::jsapi::{HandleId, HandleObject, MutableHandle, MutableHandleValue};
use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_GetClass}; use js::jsapi::{JSAutoCompartment, JSAutoRequest, JS_GetClass};
use js::jsapi::{JSContext, JSErrNum, JSObject, JSPropertyDescriptor}; use js::jsapi::{JSContext, JSErrNum, JSObject, JSPropertyDescriptor};
use js::jsapi::{JS_AlreadyHasOwnPropertyById, JS_ForwardGetPropertyTo}; use js::jsapi::{JS_AlreadyHasOwnPropertyById, JS_ForwardGetPropertyTo};
use js::jsapi::{JS_DefinePropertyById6, JS_GetPropertyDescriptorById}; use js::jsapi::{JS_DefinePropertyById6, JS_GetOwnPropertyDescriptorById};
use js::jsval::{ObjectValue, UndefinedValue, PrivateValue}; use js::jsval::{ObjectValue, UndefinedValue, PrivateValue};
use std::ptr;
#[dom_struct] #[dom_struct]
pub struct BrowsingContext { pub struct BrowsingContext {
@ -140,16 +139,13 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext,
} }
let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object()); let target = RootedObject::new(cx, GetProxyPrivate(*proxy.ptr).to_object());
// XXX This should be JS_GetOwnPropertyDescriptorById if !JS_GetOwnPropertyDescriptorById(cx, target.handle(), id, desc) {
if !JS_GetPropertyDescriptorById(cx, target.handle(), id, desc) {
return false; return false;
} }
if (*desc.ptr).obj != target.ptr { assert!(desc.get().obj.is_null() || desc.get().obj == target.ptr);
// Not an own property if desc.get().obj == target.ptr {
(*desc.ptr).obj = ptr::null_mut(); desc.get().obj = *proxy.ptr;
} else {
(*desc.ptr).obj = *proxy.ptr;
} }
true true