зеркало из https://github.com/mozilla/gecko-dev.git
Bug 805807 - Filter setters. r=mrbkap
This commit is contained in:
Родитель
de1677f0a5
Коммит
e0e591c636
|
@ -45,6 +45,39 @@ Filter(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename Policy>
|
||||
static bool
|
||||
FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, js::PropertyDescriptor *desc)
|
||||
{
|
||||
bool setAllowed = Policy::check(cx, wrapper, id, Wrapper::SET);
|
||||
if (!setAllowed) {
|
||||
if (JS_IsExceptionPending(cx))
|
||||
return false;
|
||||
desc->setter = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Base, typename Policy>
|
||||
bool
|
||||
FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
|
||||
bool set, js::PropertyDescriptor *desc)
|
||||
{
|
||||
if (!Base::getPropertyDescriptor(cx, wrapper, id, set, desc))
|
||||
return false;
|
||||
return FilterSetter<Policy>(cx, wrapper, id, desc);
|
||||
}
|
||||
|
||||
template <typename Base, typename Policy>
|
||||
bool
|
||||
FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
|
||||
bool set, js::PropertyDescriptor *desc)
|
||||
{
|
||||
if (!Base::getOwnPropertyDescriptor(cx, wrapper, id, set, desc))
|
||||
return false;
|
||||
return FilterSetter<Policy>(cx, wrapper, id, desc);
|
||||
}
|
||||
|
||||
template <typename Base, typename Policy>
|
||||
bool
|
||||
FilteringWrapper<Base, Policy>::getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
|
||||
|
@ -76,7 +109,7 @@ FilteringWrapper<Base, Policy>::iterate(JSContext *cx, JSObject *wrapper, unsign
|
|||
// We refuse to trigger the iterator hook across chrome wrappers because
|
||||
// we don't know how to censor custom iterator objects. Instead we trigger
|
||||
// the default proxy iterate trap, which will ask enumerate() for the list
|
||||
// of (consored) ids.
|
||||
// of (censored) ids.
|
||||
return js::BaseProxyHandler::iterate(cx, wrapper, flags, vp);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,12 +19,14 @@ class FilteringWrapper : public Base {
|
|||
FilteringWrapper(unsigned flags);
|
||||
virtual ~FilteringWrapper();
|
||||
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
|
||||
virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
|
||||
virtual bool keys(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
|
||||
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, js::Value *vp);
|
||||
virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool keys(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
|
||||
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, js::Value *vp) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, js::Wrapper::Action act, bool *bp);
|
||||
virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, js::Wrapper::Action act, bool *bp) MOZ_OVERRIDE;
|
||||
|
||||
static FilteringWrapper singleton;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче