static bool FilterPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc) { MOZ_ASSERT(!JS_IsExceptionPending(cx)); bool getAllowed = Policy::check(cx, wrapper, id, Wrapper::GET); if (JS_IsExceptionPending(cx)) return false; bool setAllowed = Policy::check(cx, wrapper, id, Wrapper::SET); if (JS_IsExceptionPending(cx)) return false; MOZ_ASSERT(getAllowed || setAllowed, "Filtering policy should not allow GET_PROPERTY_DESCRIPTOR in this case"); if (!desc.hasGetterOrSetter()) { // Handle value properties. if (!getAllowed) desc.value().setUndefined(); } else { // Handle accessor properties. MOZ_ASSERT(desc.value().isUndefined()); if (!getAllowed) desc.setGetter(nullptr); if (!setAllowed) desc.setSetter(nullptr); } return true; }
static bool FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, JS::MutableHandle<JSPropertyDescriptor> desc) { bool setAllowed = Policy::check(cx, wrapper, id, Wrapper::SET); if (!setAllowed) { if (JS_IsExceptionPending(cx)) return false; desc.setSetter(nullptr); } return true; }