diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index ec1a0a7ec15..e6a4c5c1365 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -4321,10 +4321,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): get = "let index = get_array_index_from_id(cx, id);\n" if indexedGetter: - readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None) + attrs = "JSPROP_ENUMERATE" + if self.descriptor.operations['IndexedSetter'] is None: + attrs += " | JSPROP_READONLY" fillDescriptor = ("desc.get().value = result_root.ptr;\n" "fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, %s);\n" - "return true;" % readonly) + "return true;" % attrs) templateValues = { 'jsvalRef': 'result_root.handle_mut()', 'successCode': fillDescriptor, @@ -4338,10 +4340,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: - readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None) + attrs = "JSPROP_ENUMERATE" + if self.descriptor.operations['IndexedSetter'] is None: + attrs += " | JSPROP_READONLY" fillDescriptor = ("desc.get().value = result_root.ptr;\n" "fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, %s);\n" - "return true;" % readonly) + "return true;" % attrs) templateValues = { 'jsvalRef': 'result_root.handle_mut()', 'successCode': fillDescriptor, diff --git a/components/script/dom/bindings/proxyhandler.rs b/components/script/dom/bindings/proxyhandler.rs index e85d93ce326..3d5a841edb3 100644 --- a/components/script/dom/bindings/proxyhandler.rs +++ b/components/script/dom/bindings/proxyhandler.rs @@ -8,6 +8,7 @@ use dom::bindings::conversions::is_dom_proxy; use dom::bindings::utils::delete_property_by_id; +use js::JSPROP_GETTER; use js::glue::GetProxyExtra; use js::glue::InvokeGetOwnPropertyDescriptor; use js::glue::{GetProxyHandler, SetProxyExtra}; @@ -18,7 +19,6 @@ use js::jsapi::{JSContext, JSObject, JSPropertyDescriptor}; use js::jsapi::{JSErrNum, JS_StrictPropertyStub}; use js::jsapi::{JS_DefinePropertyById6, JS_NewObjectWithGivenProto}; use js::jsval::ObjectValue; -use js::{JSPROP_ENUMERATE, JSPROP_GETTER, JSPROP_READONLY}; use libc; use std::{mem, ptr}; @@ -135,9 +135,9 @@ pub fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject) -> *mut JSOb /// and writable if `readonly` is true. pub fn fill_property_descriptor(desc: &mut JSPropertyDescriptor, obj: *mut JSObject, - readonly: bool) { + attrs: u32) { desc.obj = obj; - desc.attrs = if readonly { JSPROP_READONLY } else { 0 } | JSPROP_ENUMERATE; + desc.attrs = attrs; desc.getter = None; desc.setter = None; } diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs index 7149a365800..c88b4e053e3 100644 --- a/components/script/dom/browsingcontext.rs +++ b/components/script/dom/browsingcontext.rs @@ -12,15 +12,15 @@ use dom::bindings::utils::get_array_index_from_id; use dom::document::Document; use dom::element::Element; use dom::window::Window; -use js::JSCLASS_IS_GLOBAL; -use js::glue::{CreateWrapperProxyHandler, GetProxyPrivate, NewWindowProxy}; -use js::glue::{ProxyTraps, SetProxyExtra}; +use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy}; +use js::glue::{GetProxyPrivate, SetProxyExtra}; use js::jsapi::{Handle, HandleId, HandleObject, JSAutoCompartment, JSAutoRequest, JSContext}; use js::jsapi::{JSErrNum, JSObject, JSPropertyDescriptor, JS_DefinePropertyById6}; use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo, JS_GetClass}; use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_HasPropertyById, MutableHandle}; use js::jsapi::{MutableHandleValue, ObjectOpResult, RootedObject, RootedValue}; -use js::jsval::{ObjectValue, PrivateValue, UndefinedValue}; +use js::jsval::{ObjectValue, UndefinedValue, PrivateValue}; +use js::{JSCLASS_IS_GLOBAL, JSPROP_READONLY}; #[dom_struct] pub struct BrowsingContext { @@ -138,7 +138,7 @@ unsafe extern "C" fn getOwnPropertyDescriptor(cx: *mut JSContext, let mut val = RootedValue::new(cx, UndefinedValue()); window.to_jsval(cx, val.handle_mut()); (*desc.ptr).value = val.ptr; - fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, true); + fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, JSPROP_READONLY); return true; }