author | Bobby Holley <bobbyholley@gmail.com> |
Wed, 30 Jul 2014 12:23:03 -0700 | |
changeset 196847 | 60dcc2593586391ef35aa365e4ecab8543d02421 |
parent 196846 | 2a6260b2ae9c9e8209ede753f7fd505fe55fb038 |
child 196848 | a5b95c1ec2528af2da5c4517055bac74623ff43c |
push id | 46984 |
push user | bobbyholley@gmail.com |
push date | Wed, 30 Jul 2014 19:24:00 +0000 |
treeherder | mozilla-inbound@22e1b7b69877 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gabor |
bugs | 965898 |
milestone | 34.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/xpconnect/wrappers/FilteringWrapper.cpp +++ b/js/xpconnect/wrappers/FilteringWrapper.cpp @@ -40,49 +40,67 @@ Filter(JSContext *cx, HandleObject wrapp return false; } props.resize(w); return true; } template <typename Policy> static bool -FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, JS::MutableHandle<JSPropertyDescriptor> desc) +FilterPropertyDescriptor(JSContext *cx, JSObject *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 (!setAllowed) { - if (JS_IsExceptionPending(cx)) - return false; - desc.setSetter(nullptr); + 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; } template <typename Base, typename Policy> bool FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc) const { assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET); if (!Base::getPropertyDescriptor(cx, wrapper, id, desc)) return false; - return FilterSetter<Policy>(cx, wrapper, id, desc); + return FilterPropertyDescriptor<Policy>(cx, wrapper, id, desc); } template <typename Base, typename Policy> bool FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc) const { assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET); if (!Base::getOwnPropertyDescriptor(cx, wrapper, id, desc)) return false; - return FilterSetter<Policy>(cx, wrapper, id, desc); + return FilterPropertyDescriptor<Policy>(cx, wrapper, id, desc); } template <typename Base, typename Policy> bool FilteringWrapper<Base, Policy>::getOwnPropertyNames(JSContext *cx, HandleObject wrapper, AutoIdVector &props) const { assertEnteredPolicy(cx, wrapper, JSID_VOID, BaseProxyHandler::ENUMERATE);