Bug 547140, part 2 - Remove flags argument from JS_GetPropertyDescriptor and friends. r=Waldo.
This commit is contained in:
@@ -5850,7 +5850,7 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
|
|||||||
|
|
||||||
JS::Rooted<JSPropertyDescriptor> descRoot(aCx);
|
JS::Rooted<JSPropertyDescriptor> descRoot(aCx);
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc(&descRoot);
|
JS::MutableHandle<JSPropertyDescriptor> desc(&descRoot);
|
||||||
if(!JS_GetPropertyDescriptor(aCx, protoObject, "constructor", 0, desc)) {
|
if (!JS_GetPropertyDescriptor(aCx, protoObject, "constructor", desc)) {
|
||||||
rv.Throw(NS_ERROR_UNEXPECTED);
|
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ bool
|
|||||||
WindowNamedPropertiesHandler::getOwnPropertyDescriptor(JSContext* aCx,
|
WindowNamedPropertiesHandler::getOwnPropertyDescriptor(JSContext* aCx,
|
||||||
JS::Handle<JSObject*> aProxy,
|
JS::Handle<JSObject*> aProxy,
|
||||||
JS::Handle<jsid> aId,
|
JS::Handle<jsid> aId,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> aDesc,
|
JS::MutableHandle<JSPropertyDescriptor> aDesc)
|
||||||
unsigned aFlags)
|
|
||||||
{
|
{
|
||||||
if (!JSID_IS_STRING(aId)) {
|
if (!JSID_IS_STRING(aId)) {
|
||||||
// Nothing to do if we're resolving a non-string property.
|
// Nothing to do if we're resolving a non-string property.
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ public:
|
|||||||
virtual bool
|
virtual bool
|
||||||
getOwnPropertyDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy,
|
getOwnPropertyDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy,
|
||||||
JS::Handle<jsid> aId,
|
JS::Handle<jsid> aId,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> aDesc,
|
JS::MutableHandle<JSPropertyDescriptor> aDesc) MOZ_OVERRIDE;
|
||||||
unsigned aFlags) MOZ_OVERRIDE;
|
|
||||||
virtual bool
|
virtual bool
|
||||||
defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy,
|
defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy,
|
||||||
JS::Handle<jsid> aId,
|
JS::Handle<jsid> aId,
|
||||||
|
|||||||
@@ -615,13 +615,11 @@ public:
|
|||||||
virtual bool getPropertyDescriptor(JSContext* cx,
|
virtual bool getPropertyDescriptor(JSContext* cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext* cx,
|
virtual bool getOwnPropertyDescriptor(JSContext* cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext* cx,
|
virtual bool defineProperty(JSContext* cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
@@ -748,14 +746,13 @@ bool
|
|||||||
nsOuterWindowProxy::getPropertyDescriptor(JSContext* cx,
|
nsOuterWindowProxy::getPropertyDescriptor(JSContext* cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
// The only thing we can do differently from js::Wrapper is shadow stuff with
|
// The only thing we can do differently from js::Wrapper is shadow stuff with
|
||||||
// our indexed properties, so we can just try getOwnPropertyDescriptor and if
|
// our indexed properties, so we can just try getOwnPropertyDescriptor and if
|
||||||
// that gives us nothing call on through to js::Wrapper.
|
// that gives us nothing call on through to js::Wrapper.
|
||||||
desc.object().set(nullptr);
|
desc.object().set(nullptr);
|
||||||
if (!getOwnPropertyDescriptor(cx, proxy, id, desc, flags)) {
|
if (!getOwnPropertyDescriptor(cx, proxy, id, desc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,15 +760,14 @@ nsOuterWindowProxy::getPropertyDescriptor(JSContext* cx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return js::Wrapper::getPropertyDescriptor(cx, proxy, id, desc, flags);
|
return js::Wrapper::getPropertyDescriptor(cx, proxy, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsOuterWindowProxy::getOwnPropertyDescriptor(JSContext* cx,
|
nsOuterWindowProxy::getOwnPropertyDescriptor(JSContext* cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
bool found;
|
bool found;
|
||||||
if (!GetSubframeWindow(cx, proxy, id, desc.value(), found)) {
|
if (!GetSubframeWindow(cx, proxy, id, desc.value(), found)) {
|
||||||
@@ -783,7 +779,7 @@ nsOuterWindowProxy::getOwnPropertyDescriptor(JSContext* cx,
|
|||||||
}
|
}
|
||||||
// else fall through to js::Wrapper
|
// else fall through to js::Wrapper
|
||||||
|
|
||||||
return js::Wrapper::getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
|
return js::Wrapper::getOwnPropertyDescriptor(cx, proxy, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -8647,7 +8647,7 @@ class CGResolveOwnProperty(CGAbstractStaticMethod):
|
|||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
# BOGUS extra blank line at end of function
|
# BOGUS extra blank line at end of function
|
||||||
return " return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc, flags);\n\n"
|
return " return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);\n\n"
|
||||||
|
|
||||||
|
|
||||||
class CGResolveOwnPropertyViaNewresolve(CGAbstractBindingMethod):
|
class CGResolveOwnPropertyViaNewresolve(CGAbstractBindingMethod):
|
||||||
@@ -8661,8 +8661,7 @@ class CGResolveOwnPropertyViaNewresolve(CGAbstractBindingMethod):
|
|||||||
Argument('JS::Handle<JSObject*>', 'obj'),
|
Argument('JS::Handle<JSObject*>', 'obj'),
|
||||||
Argument('JS::Handle<jsid>', 'id'),
|
Argument('JS::Handle<jsid>', 'id'),
|
||||||
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
||||||
Argument('unsigned', 'flags'),
|
Argument('unsigned', 'flags')]
|
||||||
]
|
|
||||||
CGAbstractBindingMethod.__init__(self, descriptor,
|
CGAbstractBindingMethod.__init__(self, descriptor,
|
||||||
"ResolveOwnPropertyViaNewresolve",
|
"ResolveOwnPropertyViaNewresolve",
|
||||||
args, getThisObj="",
|
args, getThisObj="",
|
||||||
@@ -9067,8 +9066,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
|
|||||||
args = [Argument('JSContext*', 'cx'),
|
args = [Argument('JSContext*', 'cx'),
|
||||||
Argument('JS::Handle<JSObject*>', 'proxy'),
|
Argument('JS::Handle<JSObject*>', 'proxy'),
|
||||||
Argument('JS::Handle<jsid>', 'id'),
|
Argument('JS::Handle<jsid>', 'id'),
|
||||||
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc'),
|
Argument('JS::MutableHandle<JSPropertyDescriptor>', 'desc')]
|
||||||
Argument('unsigned', 'flags')]
|
|
||||||
ClassMethod.__init__(self, "getOwnPropertyDescriptor", "bool", args,
|
ClassMethod.__init__(self, "getOwnPropertyDescriptor", "bool", args,
|
||||||
virtual=True, override=True)
|
virtual=True, override=True)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
@@ -9100,7 +9098,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
|
|||||||
|
|
||||||
if UseHolderForUnforgeable(self.descriptor):
|
if UseHolderForUnforgeable(self.descriptor):
|
||||||
tryHolder = dedent("""
|
tryHolder = dedent("""
|
||||||
if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, flags, desc)) {
|
if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, desc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});
|
MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});
|
||||||
@@ -9155,7 +9153,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
|
|||||||
$*{getUnforgeable}
|
$*{getUnforgeable}
|
||||||
JS::Rooted<JSObject*> expando(cx);
|
JS::Rooted<JSObject*> expando(cx);
|
||||||
if (!isXray && (expando = GetExpandoObject(proxy))) {
|
if (!isXray && (expando = GetExpandoObject(proxy))) {
|
||||||
if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc)) {
|
if (!JS_GetPropertyDescriptorById(cx, expando, id, desc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (desc.object()) {
|
if (desc.object()) {
|
||||||
|
|||||||
@@ -166,10 +166,9 @@ bool
|
|||||||
BaseDOMProxyHandler::getPropertyDescriptor(JSContext* cx,
|
BaseDOMProxyHandler::getPropertyDescriptor(JSContext* cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
if (!getOwnPropertyDescriptor(cx, proxy, id, desc, flags)) {
|
if (!getOwnPropertyDescriptor(cx, proxy, id, desc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (desc.object()) {
|
if (desc.object()) {
|
||||||
@@ -185,7 +184,7 @@ BaseDOMProxyHandler::getPropertyDescriptor(JSContext* cx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc);
|
return JS_GetPropertyDescriptorById(cx, proto, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ public:
|
|||||||
JS::AutoIdVector& props) MOZ_OVERRIDE;
|
JS::AutoIdVector& props) MOZ_OVERRIDE;
|
||||||
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy,
|
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
bool watch(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
bool watch(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
||||||
JS::Handle<JSObject*> callable) MOZ_OVERRIDE;
|
JS::Handle<JSObject*> callable) MOZ_OVERRIDE;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ nsXBLProtoImpl::LookupMember(JSContext* aCx, nsString& aName,
|
|||||||
{
|
{
|
||||||
for (nsXBLProtoImplMember* m = mMembers; m; m = m->GetNext()) {
|
for (nsXBLProtoImplMember* m = mMembers; m; m = m->GetNext()) {
|
||||||
if (aName.Equals(m->GetName())) {
|
if (aName.Equals(m->GetName())) {
|
||||||
return JS_GetPropertyDescriptorById(aCx, aClassObject, aNameAsId, 0, aDesc);
|
return JS_GetPropertyDescriptorById(aCx, aClassObject, aNameAsId, aDesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -174,8 +174,7 @@ EmptyDesc(PPropertyDescriptor *desc)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
JavaScriptChild::AnswerGetPropertyDescriptor(const ObjectId &objId, const nsString &id,
|
JavaScriptChild::AnswerGetPropertyDescriptor(const ObjectId &objId, const nsString &id,
|
||||||
const uint32_t &flags, ReturnStatus *rs,
|
ReturnStatus *rs, PPropertyDescriptor *out)
|
||||||
PPropertyDescriptor *out)
|
|
||||||
{
|
{
|
||||||
AutoSafeJSContext cx;
|
AutoSafeJSContext cx;
|
||||||
JSAutoRequest request(cx);
|
JSAutoRequest request(cx);
|
||||||
@@ -193,7 +192,7 @@ JavaScriptChild::AnswerGetPropertyDescriptor(const ObjectId &objId, const nsStri
|
|||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
|
|
||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, &desc))
|
||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
|
|
||||||
if (!desc.object())
|
if (!desc.object())
|
||||||
@@ -207,8 +206,7 @@ JavaScriptChild::AnswerGetPropertyDescriptor(const ObjectId &objId, const nsStri
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
JavaScriptChild::AnswerGetOwnPropertyDescriptor(const ObjectId &objId, const nsString &id,
|
JavaScriptChild::AnswerGetOwnPropertyDescriptor(const ObjectId &objId, const nsString &id,
|
||||||
const uint32_t &flags, ReturnStatus *rs,
|
ReturnStatus *rs, PPropertyDescriptor *out)
|
||||||
PPropertyDescriptor *out)
|
|
||||||
{
|
{
|
||||||
AutoSafeJSContext cx;
|
AutoSafeJSContext cx;
|
||||||
JSAutoRequest request(cx);
|
JSAutoRequest request(cx);
|
||||||
@@ -226,7 +224,7 @@ JavaScriptChild::AnswerGetOwnPropertyDescriptor(const ObjectId &objId, const nsS
|
|||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
|
|
||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, &desc))
|
||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
|
|
||||||
if (desc.object() != obj)
|
if (desc.object() != obj)
|
||||||
@@ -344,7 +342,7 @@ JavaScriptChild::AnswerHasOwn(const ObjectId &objId, const nsString &id, ReturnS
|
|||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
|
|
||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, 0, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, &desc))
|
||||||
return fail(cx, rs);
|
return fail(cx, rs);
|
||||||
*bp = (desc.object() == obj);
|
*bp = (desc.object() == obj);
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,10 @@ class JavaScriptChild
|
|||||||
|
|
||||||
bool AnswerPreventExtensions(const ObjectId &objId, ReturnStatus *rs) MOZ_OVERRIDE;
|
bool AnswerPreventExtensions(const ObjectId &objId, ReturnStatus *rs) MOZ_OVERRIDE;
|
||||||
bool AnswerGetPropertyDescriptor(const ObjectId &objId, const nsString &id,
|
bool AnswerGetPropertyDescriptor(const ObjectId &objId, const nsString &id,
|
||||||
const uint32_t &flags, ReturnStatus *rs,
|
ReturnStatus *rs,
|
||||||
PPropertyDescriptor *out) MOZ_OVERRIDE;
|
PPropertyDescriptor *out) MOZ_OVERRIDE;
|
||||||
bool AnswerGetOwnPropertyDescriptor(const ObjectId &objId,
|
bool AnswerGetOwnPropertyDescriptor(const ObjectId &objId,
|
||||||
const nsString &id,
|
const nsString &id,
|
||||||
const uint32_t &flags,
|
|
||||||
ReturnStatus *rs,
|
ReturnStatus *rs,
|
||||||
PPropertyDescriptor *out) MOZ_OVERRIDE;
|
PPropertyDescriptor *out) MOZ_OVERRIDE;
|
||||||
bool AnswerDefineProperty(const ObjectId &objId, const nsString &id,
|
bool AnswerDefineProperty(const ObjectId &objId, const nsString &id,
|
||||||
|
|||||||
@@ -64,11 +64,9 @@ class CPOWProxyHandler : public BaseProxyHandler
|
|||||||
|
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
HandleId id, MutableHandle<JSPropertyDescriptor> desc,
|
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||||
@@ -123,14 +121,14 @@ JavaScriptParent::preventExtensions(JSContext *cx, HandleObject proxy)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
CPOWProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
CPOWProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
FORWARD(getPropertyDescriptor, (cx, proxy, id, desc, flags));
|
FORWARD(getPropertyDescriptor, (cx, proxy, id, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JavaScriptParent::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
JavaScriptParent::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
ObjectId objId = idOf(proxy);
|
ObjectId objId = idOf(proxy);
|
||||||
|
|
||||||
@@ -140,7 +138,7 @@ JavaScriptParent::getPropertyDescriptor(JSContext *cx, HandleObject proxy, Handl
|
|||||||
|
|
||||||
ReturnStatus status;
|
ReturnStatus status;
|
||||||
PPropertyDescriptor result;
|
PPropertyDescriptor result;
|
||||||
if (!CallGetPropertyDescriptor(objId, idstr, flags, &status, &result))
|
if (!CallGetPropertyDescriptor(objId, idstr, &status, &result))
|
||||||
return ipcfail(cx);
|
return ipcfail(cx);
|
||||||
if (!ok(cx, status))
|
if (!ok(cx, status))
|
||||||
return false;
|
return false;
|
||||||
@@ -150,15 +148,14 @@ JavaScriptParent::getPropertyDescriptor(JSContext *cx, HandleObject proxy, Handl
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
CPOWProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
CPOWProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||||
HandleId id, MutableHandle<JSPropertyDescriptor> desc,
|
HandleId id, MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
FORWARD(getOwnPropertyDescriptor, (cx, proxy, id, desc, flags));
|
FORWARD(getOwnPropertyDescriptor, (cx, proxy, id, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JavaScriptParent::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
JavaScriptParent::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
ObjectId objId = idOf(proxy);
|
ObjectId objId = idOf(proxy);
|
||||||
|
|
||||||
@@ -168,7 +165,7 @@ JavaScriptParent::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, Ha
|
|||||||
|
|
||||||
ReturnStatus status;
|
ReturnStatus status;
|
||||||
PPropertyDescriptor result;
|
PPropertyDescriptor result;
|
||||||
if (!CallGetOwnPropertyDescriptor(objId, idstr, flags, &status, &result))
|
if (!CallGetOwnPropertyDescriptor(objId, idstr, &status, &result))
|
||||||
return ipcfail(cx);
|
return ipcfail(cx);
|
||||||
if (!ok(cx, status))
|
if (!ok(cx, status))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ class JavaScriptParent
|
|||||||
// (The traps should be in the same order like js/src/jsproxy.h)
|
// (The traps should be in the same order like js/src/jsproxy.h)
|
||||||
bool preventExtensions(JSContext *cx, JS::HandleObject proxy);
|
bool preventExtensions(JSContext *cx, JS::HandleObject proxy);
|
||||||
bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
|
bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ child:
|
|||||||
|
|
||||||
// These roughly map to the ProxyHandler hooks that CPOWs need.
|
// These roughly map to the ProxyHandler hooks that CPOWs need.
|
||||||
rpc PreventExtensions(uint64_t objId) returns (ReturnStatus rs);
|
rpc PreventExtensions(uint64_t objId) returns (ReturnStatus rs);
|
||||||
rpc GetPropertyDescriptor(uint64_t objId, nsString id, uint32_t flags) returns (ReturnStatus rs, PPropertyDescriptor result);
|
rpc GetPropertyDescriptor(uint64_t objId, nsString id) returns (ReturnStatus rs, PPropertyDescriptor result);
|
||||||
rpc GetOwnPropertyDescriptor(uint64_t objId, nsString id, uint32_t flags) returns (ReturnStatus rs, PPropertyDescriptor result);
|
rpc GetOwnPropertyDescriptor(uint64_t objId, nsString id) returns (ReturnStatus rs, PPropertyDescriptor result);
|
||||||
rpc DefineProperty(uint64_t objId, nsString id, PPropertyDescriptor descriptor) returns (ReturnStatus rs);
|
rpc DefineProperty(uint64_t objId, nsString id, PPropertyDescriptor descriptor) returns (ReturnStatus rs);
|
||||||
rpc Delete(uint64_t objId, nsString id) returns (ReturnStatus rs, bool successful);
|
rpc Delete(uint64_t objId, nsString id) returns (ReturnStatus rs, bool successful);
|
||||||
|
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr)
|
|||||||
|
|
||||||
if(!JS_WrapId(cx, &id))
|
if(!JS_WrapId(cx, &id))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if(!JS_GetOwnPropertyDescriptorById(cx, obj, id, 0, &desc))
|
if(!JS_GetOwnPropertyDescriptorById(cx, obj, id, &desc))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if(!desc.object())
|
if(!desc.object())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
|
|||||||
// native. Handle proxies separately.
|
// native. Handle proxies separately.
|
||||||
args.rval().setUndefined();
|
args.rval().setUndefined();
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc, 0))
|
if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object() && desc.hasGetterObject() && desc.getterObject())
|
if (desc.object() && desc.hasGetterObject() && desc.getterObject())
|
||||||
args.rval().setObject(*desc.getterObject());
|
args.rval().setObject(*desc.getterObject());
|
||||||
@@ -478,7 +478,7 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
|
|||||||
// native. Handle proxies separately.
|
// native. Handle proxies separately.
|
||||||
args.rval().setUndefined();
|
args.rval().setUndefined();
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc, 0))
|
if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object() && desc.hasSetterObject() && desc.setterObject())
|
if (desc.object() && desc.hasSetterObject() && desc.setterObject())
|
||||||
args.rval().setObject(*desc.setterObject());
|
args.rval().setObject(*desc.setterObject());
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ GetDataProperty(JSContext *cx, HandleValue objVal, HandlePropertyName field, Mut
|
|||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
RootedObject obj(cx, &objVal.toObject());
|
RootedObject obj(cx, &objVal.toObject());
|
||||||
RootedId id(cx, NameToId(field));
|
RootedId id(cx, NameToId(field));
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, 0, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!desc.object())
|
if (!desc.object())
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ BEGIN_TEST(testDefineGetterSetterNonEnumerable)
|
|||||||
JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, (JSObject*) funSetObj)));
|
JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, (JSObject*) funSetObj)));
|
||||||
|
|
||||||
JS::Rooted<JSPropertyDescriptor> desc(cx);
|
JS::Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
CHECK(JS_GetOwnPropertyDescriptor(cx, vObject, PROPERTY_NAME, 0, &desc));
|
CHECK(JS_GetOwnPropertyDescriptor(cx, vObject, PROPERTY_NAME, &desc));
|
||||||
CHECK(desc.object());
|
CHECK(desc.object());
|
||||||
CHECK(desc.hasGetterObject());
|
CHECK(desc.hasGetterObject());
|
||||||
CHECK(desc.hasSetterObject());
|
CHECK(desc.hasSetterObject());
|
||||||
|
|||||||
@@ -2705,7 +2705,7 @@ LookupResult(JSContext *cx, HandleObject obj, HandleObject obj2, HandleId id,
|
|||||||
if (!obj2->isNative()) {
|
if (!obj2->isNative()) {
|
||||||
if (obj2->is<ProxyObject>()) {
|
if (obj2->is<ProxyObject>()) {
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getPropertyDescriptor(cx, obj2, id, &desc, 0))
|
if (!Proxy::getPropertyDescriptor(cx, obj2, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (!desc.isShared()) {
|
if (!desc.isShared()) {
|
||||||
vp.set(desc.value());
|
vp.set(desc.value());
|
||||||
@@ -3295,17 +3295,17 @@ JS_DefineProperties(JSContext *cx, HandleObject obj, const JSPropertySpec *ps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id,
|
||||||
bool own, MutableHandle<PropertyDescriptor> desc)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
RootedObject obj2(cx);
|
RootedObject obj2(cx);
|
||||||
RootedShape shape(cx);
|
RootedShape shape(cx);
|
||||||
|
|
||||||
if (!LookupPropertyById(cx, obj, id, flags, &obj2, &shape))
|
if (!LookupPropertyById(cx, obj, id, 0, &obj2, &shape))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
desc.clear();
|
desc.clear();
|
||||||
if (!shape || (own && obj != obj2))
|
if (!shape)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
desc.object().set(obj2);
|
desc.object().set(obj2);
|
||||||
@@ -3323,10 +3323,8 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (obj2->is<ProxyObject>()) {
|
if (obj2->is<ProxyObject>()) {
|
||||||
JSAutoResolveFlags rf(cx, flags);
|
JSAutoResolveFlags rf(cx, 0);
|
||||||
return own
|
return Proxy::getPropertyDescriptor(cx, obj2, id, desc);
|
||||||
? Proxy::getOwnPropertyDescriptor(cx, obj2, id, desc, 0)
|
|
||||||
: Proxy::getPropertyDescriptor(cx, obj2, id, desc, 0);
|
|
||||||
}
|
}
|
||||||
if (!JSObject::getGenericAttributes(cx, obj2, id, &desc.attributesRef()))
|
if (!JSObject::getGenericAttributes(cx, obj2, id, &desc.attributesRef()))
|
||||||
return false;
|
return false;
|
||||||
@@ -3338,42 +3336,42 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
JS_PUBLIC_API(bool)
|
||||||
JS_GetOwnPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
JS_GetOwnPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
AssertHeapIsIdle(cx);
|
AssertHeapIsIdle(cx);
|
||||||
CHECK_REQUEST(cx);
|
CHECK_REQUEST(cx);
|
||||||
|
|
||||||
return GetPropertyDescriptorById(cx, obj, id, flags, true, desc);
|
return GetOwnPropertyDescriptor(cx, obj, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
JS_PUBLIC_API(bool)
|
||||||
JS_GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, const char *name, unsigned flags,
|
JS_GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, const char *name,
|
||||||
MutableHandle<JSPropertyDescriptor> desc)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
JSAtom *atom = Atomize(cx, name, strlen(name));
|
JSAtom *atom = Atomize(cx, name, strlen(name));
|
||||||
if (!atom)
|
if (!atom)
|
||||||
return false;
|
return false;
|
||||||
RootedId id(cx, AtomToId(atom));
|
RootedId id(cx, AtomToId(atom));
|
||||||
return JS_GetOwnPropertyDescriptorById(cx, obj, id, flags, desc);
|
return JS_GetOwnPropertyDescriptorById(cx, obj, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
JS_PUBLIC_API(bool)
|
||||||
JS_GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
JS_GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
return GetPropertyDescriptorById(cx, obj, id, flags, false, desc);
|
return GetPropertyDescriptorById(cx, obj, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
JS_PUBLIC_API(bool)
|
||||||
JS_GetPropertyDescriptor(JSContext *cx, HandleObject obj, const char *name, unsigned flags,
|
JS_GetPropertyDescriptor(JSContext *cx, HandleObject obj, const char *name,
|
||||||
MutableHandle<JSPropertyDescriptor> desc)
|
MutableHandle<JSPropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
JSAtom *atom = Atomize(cx, name, strlen(name));
|
JSAtom *atom = Atomize(cx, name, strlen(name));
|
||||||
if (!atom)
|
if (!atom)
|
||||||
return false;
|
return false;
|
||||||
RootedId id(cx, AtomToId(atom));
|
RootedId id(cx, AtomToId(atom));
|
||||||
return atom && JS_GetPropertyDescriptorById(cx, obj, id, flags, desc);
|
return atom && JS_GetPropertyDescriptorById(cx, obj, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(bool)
|
JS_PUBLIC_API(bool)
|
||||||
|
|||||||
@@ -3022,10 +3022,10 @@ class MutableHandleBase<JSPropertyDescriptor>
|
|||||||
|
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
JS_GetOwnPropertyDescriptorById(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
JS_GetOwnPropertyDescriptorById(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
||||||
unsigned flags, JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
JS_GetOwnPropertyDescriptor(JSContext *cx, JS::HandleObject obj, const char *name, unsigned flags,
|
JS_GetOwnPropertyDescriptor(JSContext *cx, JS::HandleObject obj, const char *name,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3034,11 +3034,11 @@ JS_GetOwnPropertyDescriptor(JSContext *cx, JS::HandleObject obj, const char *nam
|
|||||||
* then this property was not found on the prototype chain.
|
* then this property was not found on the prototype chain.
|
||||||
*/
|
*/
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
JS_GetPropertyDescriptorById(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned flags,
|
JS_GetPropertyDescriptorById(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
JS_GetPropertyDescriptor(JSContext *cx, JS::HandleObject obj, const char *name, unsigned flags,
|
JS_GetPropertyDescriptor(JSContext *cx, JS::HandleObject obj, const char *name,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
|
|
||||||
extern JS_PUBLIC_API(bool)
|
extern JS_PUBLIC_API(bool)
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
|
|||||||
{
|
{
|
||||||
// FIXME: Call TrapGetOwnProperty directly once ScriptedIndirectProxies is removed
|
// FIXME: Call TrapGetOwnProperty directly once ScriptedIndirectProxies is removed
|
||||||
if (obj->is<ProxyObject>())
|
if (obj->is<ProxyObject>())
|
||||||
return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc, 0);
|
return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc);
|
||||||
|
|
||||||
RootedObject pobj(cx);
|
RootedObject pobj(cx);
|
||||||
RootedShape shape(cx);
|
RootedShape shape(cx);
|
||||||
@@ -4891,7 +4891,7 @@ baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg
|
|||||||
|
|
||||||
JSContext *cx = cxArg->asJSContext();
|
JSContext *cx = cxArg->asJSContext();
|
||||||
Rooted<PropertyDescriptor> pd(cx);
|
Rooted<PropertyDescriptor> pd(cx);
|
||||||
if (!Proxy::getPropertyDescriptor(cx, pobj, id, &pd, 0))
|
if (!Proxy::getPropertyDescriptor(cx, pobj, id, &pd))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((pd.attributes() & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
|
if ((pd.attributes() & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ BaseProxyHandler::has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp)
|
|||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, proxy, id, GET);
|
assertEnteredPolicy(cx, proxy, id, GET);
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!getPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
*bp = !!desc.object();
|
*bp = !!desc.object();
|
||||||
return true;
|
return true;
|
||||||
@@ -116,7 +116,7 @@ BaseProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool *b
|
|||||||
// lives, so we allow SET operations to invoke us.
|
// lives, so we allow SET operations to invoke us.
|
||||||
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
*bp = !!desc.object();
|
*bp = !!desc.object();
|
||||||
return true;
|
return true;
|
||||||
@@ -129,7 +129,7 @@ BaseProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObject receiver,
|
|||||||
assertEnteredPolicy(cx, proxy, id, GET);
|
assertEnteredPolicy(cx, proxy, id, GET);
|
||||||
|
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!getPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (!desc.object()) {
|
if (!desc.object()) {
|
||||||
vp.setUndefined();
|
vp.setUndefined();
|
||||||
@@ -159,7 +159,7 @@ BaseProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject receiver,
|
|||||||
assertEnteredPolicy(cx, proxy, id, SET);
|
assertEnteredPolicy(cx, proxy, id, SET);
|
||||||
|
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
/* The control-flow here differs from ::get() because of the fall-through case below. */
|
/* The control-flow here differs from ::get() because of the fall-through case below. */
|
||||||
if (desc.object()) {
|
if (desc.object()) {
|
||||||
@@ -187,7 +187,7 @@ BaseProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObject receiver,
|
|||||||
desc.value().set(vp.get());
|
desc.value().set(vp.get());
|
||||||
return defineProperty(cx, receiver, id, &desc);
|
return defineProperty(cx, receiver, id, &desc);
|
||||||
}
|
}
|
||||||
if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!getPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object()) {
|
if (desc.object()) {
|
||||||
// Check for read-only properties.
|
// Check for read-only properties.
|
||||||
@@ -240,7 +240,7 @@ BaseProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props)
|
|||||||
JS_ASSERT(i <= j);
|
JS_ASSERT(i <= j);
|
||||||
id = props[j];
|
id = props[j];
|
||||||
AutoWaivePolicy policy(cx, proxy, id, BaseProxyHandler::GET);
|
AutoWaivePolicy policy(cx, proxy, id, BaseProxyHandler::GET);
|
||||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object() && desc.isEnumerable())
|
if (desc.object() && desc.isEnumerable())
|
||||||
props[i++] = id;
|
props[i++] = id;
|
||||||
@@ -385,38 +385,21 @@ BaseProxyHandler::slice(JSContext *cx, HandleObject proxy, uint32_t begin, uint3
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
DirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
DirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
||||||
JS_ASSERT(!hasPrototype()); // Should never be called if there's a prototype.
|
JS_ASSERT(!hasPrototype()); // Should never be called if there's a prototype.
|
||||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||||
return JS_GetPropertyDescriptorById(cx, target, id, 0, desc);
|
return JS_GetPropertyDescriptorById(cx, target, id, desc);
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
|
||||||
MutableHandle<PropertyDescriptor> desc)
|
|
||||||
{
|
|
||||||
// If obj is a proxy, we can do better than just guessing. This is
|
|
||||||
// important for certain types of wrappers that wrap other wrappers.
|
|
||||||
if (obj->is<ProxyObject>())
|
|
||||||
return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc, flags);
|
|
||||||
|
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc))
|
|
||||||
return false;
|
|
||||||
if (desc.object() != obj)
|
|
||||||
desc.object().set(nullptr);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
DirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
||||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||||
return GetOwnPropertyDescriptor(cx, target, id, 0, desc);
|
return js::GetOwnPropertyDescriptor(cx, target, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -578,7 +561,7 @@ DirectProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool
|
|||||||
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
assertEnteredPolicy(cx, proxy, id, GET | SET);
|
||||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, target, id, 0, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, target, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
*bp = (desc.object() == target);
|
*bp = (desc.object() == target);
|
||||||
return true;
|
return true;
|
||||||
@@ -764,11 +747,9 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler
|
|||||||
/* ES5 Harmony fundamental proxy traps. */
|
/* ES5 Harmony fundamental proxy traps. */
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
||||||
@@ -866,8 +847,7 @@ GetIndirectProxyHandlerObject(JSObject *proxy)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||||
RootedValue fval(cx), value(cx);
|
RootedValue fval(cx), value(cx);
|
||||||
@@ -880,8 +860,7 @@ ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||||
RootedValue fval(cx), value(cx);
|
RootedValue fval(cx), value(cx);
|
||||||
@@ -1086,11 +1065,9 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
|
|||||||
/* ES5 Harmony fundamental proxy traps. */
|
/* ES5 Harmony fundamental proxy traps. */
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
||||||
@@ -1230,7 +1207,7 @@ ValidateProperty(JSContext *cx, HandleObject obj, HandleId id, PropDesc *desc, b
|
|||||||
{
|
{
|
||||||
// step 1
|
// step 1
|
||||||
Rooted<PropertyDescriptor> current(cx);
|
Rooted<PropertyDescriptor> current(cx);
|
||||||
if (!GetOwnPropertyDescriptor(cx, obj, id, 0, ¤t))
|
if (!GetOwnPropertyDescriptor(cx, obj, id, ¤t))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1333,7 +1310,7 @@ IsSealed(JSContext* cx, HandleObject obj, HandleId id, bool *bp)
|
|||||||
{
|
{
|
||||||
// step 1
|
// step 1
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!GetOwnPropertyDescriptor(cx, obj, id, 0, &desc))
|
if (!GetOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// steps 2-3
|
// steps 2-3
|
||||||
@@ -1345,7 +1322,7 @@ static bool
|
|||||||
HasOwn(JSContext *cx, HandleObject obj, HandleId id, bool *bp)
|
HasOwn(JSContext *cx, HandleObject obj, HandleId id, bool *bp)
|
||||||
{
|
{
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, 0, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
*bp = (desc.object() == obj);
|
*bp = (desc.object() == obj);
|
||||||
return true;
|
return true;
|
||||||
@@ -1734,8 +1711,7 @@ ScriptedDirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
|
|||||||
// FIXME: Move to Proxy::getPropertyDescriptor once ScriptedIndirectProxy is removed
|
// FIXME: Move to Proxy::getPropertyDescriptor once ScriptedIndirectProxy is removed
|
||||||
bool
|
bool
|
||||||
ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
JS_CHECK_RECURSION(cx, return false);
|
JS_CHECK_RECURSION(cx, return false);
|
||||||
|
|
||||||
@@ -1750,13 +1726,12 @@ ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject pr
|
|||||||
JS_ASSERT(!desc.object());
|
JS_ASSERT(!desc.object());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc);
|
return JS_GetPropertyDescriptorById(cx, proto, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
// step 1
|
// step 1
|
||||||
RootedValue v(cx);
|
RootedValue v(cx);
|
||||||
@@ -2372,7 +2347,7 @@ ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton;
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
JS_CHECK_RECURSION(cx, return false);
|
JS_CHECK_RECURSION(cx, return false);
|
||||||
BaseProxyHandler *handler = proxy->as<ProxyObject>().handler();
|
BaseProxyHandler *handler = proxy->as<ProxyObject>().handler();
|
||||||
@@ -2381,29 +2356,28 @@ Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
|||||||
if (!policy.allowed())
|
if (!policy.allowed())
|
||||||
return policy.returnValue();
|
return policy.returnValue();
|
||||||
if (!handler->hasPrototype())
|
if (!handler->hasPrototype())
|
||||||
return handler->getPropertyDescriptor(cx, proxy, id, desc, flags);
|
return handler->getPropertyDescriptor(cx, proxy, id, desc);
|
||||||
if (!handler->getOwnPropertyDescriptor(cx, proxy, id, desc, flags))
|
if (!handler->getOwnPropertyDescriptor(cx, proxy, id, desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object())
|
if (desc.object())
|
||||||
return true;
|
return true;
|
||||||
INVOKE_ON_PROTOTYPE(cx, handler, proxy, JS_GetPropertyDescriptorById(cx, proto, id, 0, desc));
|
INVOKE_ON_PROTOTYPE(cx, handler, proxy, JS_GetPropertyDescriptorById(cx, proto, id, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags,
|
Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, MutableHandleValue vp)
|
||||||
HandleId id, MutableHandleValue vp)
|
|
||||||
{
|
{
|
||||||
JS_CHECK_RECURSION(cx, return false);
|
JS_CHECK_RECURSION(cx, return false);
|
||||||
|
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc, flags))
|
if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
return NewPropertyDescriptorObject(cx, desc, vp);
|
return NewPropertyDescriptorObject(cx, desc, vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
JS_CHECK_RECURSION(cx, return false);
|
JS_CHECK_RECURSION(cx, return false);
|
||||||
|
|
||||||
@@ -2412,17 +2386,17 @@ Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
|||||||
AutoEnterPolicy policy(cx, handler, proxy, id, BaseProxyHandler::GET, true);
|
AutoEnterPolicy policy(cx, handler, proxy, id, BaseProxyHandler::GET, true);
|
||||||
if (!policy.allowed())
|
if (!policy.allowed())
|
||||||
return policy.returnValue();
|
return policy.returnValue();
|
||||||
return handler->getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
|
return handler->getOwnPropertyDescriptor(cx, proxy, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id,
|
Proxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandleValue vp)
|
MutableHandleValue vp)
|
||||||
{
|
{
|
||||||
JS_CHECK_RECURSION(cx, return false);
|
JS_CHECK_RECURSION(cx, return false);
|
||||||
|
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getOwnPropertyDescriptor(cx, proxy, id, &desc, flags))
|
if (!Proxy::getOwnPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
return NewPropertyDescriptorObject(cx, desc, vp);
|
return NewPropertyDescriptorObject(cx, desc, vp);
|
||||||
}
|
}
|
||||||
@@ -2601,7 +2575,7 @@ Proxy::set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id
|
|||||||
// If we have an existing (own or non-own) property with a setter, we want
|
// If we have an existing (own or non-own) property with a setter, we want
|
||||||
// to invoke that.
|
// to invoke that.
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc, 0))
|
if (!Proxy::getPropertyDescriptor(cx, proxy, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object() && desc.setter() && desc.setter() != JS_StrictPropertyStub)
|
if (desc.object() && desc.setter() && desc.setter() != JS_StrictPropertyStub)
|
||||||
return CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp);
|
return CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp);
|
||||||
@@ -2958,7 +2932,7 @@ bool
|
|||||||
js::proxy_GetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
|
js::proxy_GetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
|
||||||
{
|
{
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc, 0))
|
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
*attrsp = desc.attributes();
|
*attrsp = desc.attributes();
|
||||||
return true;
|
return true;
|
||||||
@@ -2969,7 +2943,7 @@ js::proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, uns
|
|||||||
{
|
{
|
||||||
/* Lookup the current property descriptor so we have setter/getter/value. */
|
/* Lookup the current property descriptor so we have setter/getter/value. */
|
||||||
Rooted<PropertyDescriptor> desc(cx);
|
Rooted<PropertyDescriptor> desc(cx);
|
||||||
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc, 0))
|
if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
desc.setAttributes(*attrsp);
|
desc.setAttributes(*attrsp);
|
||||||
return Proxy::defineProperty(cx, obj, id, &desc);
|
return Proxy::defineProperty(cx, obj, id, &desc);
|
||||||
|
|||||||
@@ -178,11 +178,9 @@ class JS_FRIEND_API(BaseProxyHandler)
|
|||||||
/* ES5 Harmony fundamental proxy traps. */
|
/* ES5 Harmony fundamental proxy traps. */
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) = 0;
|
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) = 0;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) = 0;
|
||||||
unsigned flags) = 0;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
||||||
HandleId id, MutableHandle<JSPropertyDescriptor> desc,
|
HandleId id, MutableHandle<JSPropertyDescriptor> desc) = 0;
|
||||||
unsigned flags) = 0;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc) = 0;
|
MutableHandle<JSPropertyDescriptor> desc) = 0;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||||
@@ -248,10 +246,9 @@ class JS_PUBLIC_API(DirectProxyHandler) : public BaseProxyHandler
|
|||||||
/* ES5 Harmony fundamental proxy traps. */
|
/* ES5 Harmony fundamental proxy traps. */
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags) MOZ_OVERRIDE;
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
HandleId id, MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||||
@@ -308,12 +305,12 @@ class Proxy
|
|||||||
/* ES5 Harmony fundamental proxy traps. */
|
/* ES5 Harmony fundamental proxy traps. */
|
||||||
static bool preventExtensions(JSContext *cx, HandleObject proxy);
|
static bool preventExtensions(JSContext *cx, HandleObject proxy);
|
||||||
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
MutableHandle<JSPropertyDescriptor> desc);
|
||||||
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id,
|
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandleValue vp);
|
MutableHandleValue vp);
|
||||||
static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
MutableHandle<JSPropertyDescriptor> desc);
|
||||||
static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id,
|
static bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandleValue vp);
|
MutableHandleValue vp);
|
||||||
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
static bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc);
|
MutableHandle<JSPropertyDescriptor> desc);
|
||||||
|
|||||||
@@ -230,24 +230,23 @@ CrossCompartmentWrapper::preventExtensions(JSContext *cx, HandleObject wrapper)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
RootedId idCopy(cx, id);
|
RootedId idCopy(cx, id);
|
||||||
PIERCE(cx, wrapper,
|
PIERCE(cx, wrapper,
|
||||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||||
Wrapper::getPropertyDescriptor(cx, wrapper, idCopy, desc, flags),
|
Wrapper::getPropertyDescriptor(cx, wrapper, idCopy, desc),
|
||||||
cx->compartment()->wrap(cx, desc));
|
cx->compartment()->wrap(cx, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
HandleId id, MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
RootedId idCopy(cx, id);
|
RootedId idCopy(cx, id);
|
||||||
PIERCE(cx, wrapper,
|
PIERCE(cx, wrapper,
|
||||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||||
Wrapper::getOwnPropertyDescriptor(cx, wrapper, idCopy, desc, flags),
|
Wrapper::getOwnPropertyDescriptor(cx, wrapper, idCopy, desc),
|
||||||
cx->compartment()->wrap(cx, desc));
|
cx->compartment()->wrap(cx, desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,7 +755,7 @@ DeadObjectProxy::preventExtensions(JSContext *cx, HandleObject proxy)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT);
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT);
|
||||||
return false;
|
return false;
|
||||||
@@ -764,7 +763,7 @@ DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, Hand
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
DeadObjectProxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
DeadObjectProxy::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc, unsigned flags)
|
MutableHandle<PropertyDescriptor> desc)
|
||||||
{
|
{
|
||||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT);
|
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -110,11 +110,9 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper
|
|||||||
/* ES5 Harmony fundamental wrapper traps. */
|
/* ES5 Harmony fundamental wrapper traps. */
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
|
||||||
@@ -214,11 +212,9 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
|
|||||||
/* ES5 Harmony fundamental wrapper traps. */
|
/* ES5 Harmony fundamental wrapper traps. */
|
||||||
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc,
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
virtual bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
|
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject wrapper,
|
||||||
|
|||||||
@@ -3034,7 +3034,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
|
|||||||
if (!desc.setter() && !desc.hasSetterObject())
|
if (!desc.setter() && !desc.hasSetterObject())
|
||||||
desc.setSetter(JS_StrictPropertyStub);
|
desc.setSetter(JS_StrictPropertyStub);
|
||||||
} else if (referent->is<ProxyObject>()) {
|
} else if (referent->is<ProxyObject>()) {
|
||||||
if (!Proxy::getOwnPropertyDescriptor(cx, referent, id, &desc, 0))
|
if (!Proxy::getOwnPropertyDescriptor(cx, referent, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
if (!desc.object())
|
if (!desc.object())
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1325,15 +1325,13 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE
|
||||||
unsigned flags) MOZ_OVERRIDE
|
|
||||||
{
|
{
|
||||||
return getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
|
return getOwnPropertyDescriptor(cx, proxy, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
|
||||||
MutableHandle<PropertyDescriptor> desc,
|
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE
|
||||||
unsigned flags) MOZ_OVERRIDE
|
|
||||||
{
|
{
|
||||||
Rooted<DebugScopeObject*> debugScope(cx, &proxy->as<DebugScopeObject>());
|
Rooted<DebugScopeObject*> debugScope(cx, &proxy->as<DebugScopeObject>());
|
||||||
Rooted<ScopeObject*> scope(cx, &debugScope->scope());
|
Rooted<ScopeObject*> scope(cx, &debugScope->scope());
|
||||||
@@ -1361,7 +1359,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_GetOwnPropertyDescriptorById(cx, scope, id, flags, desc);
|
return JS_GetOwnPropertyDescriptorById(cx, scope, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,
|
bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,
|
||||||
|
|||||||
@@ -857,14 +857,12 @@ bool
|
|||||||
xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
|
xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
JS::RootedObject obj(cx, wrappedObject(proxy));
|
JS::RootedObject obj(cx, wrappedObject(proxy));
|
||||||
|
|
||||||
MOZ_ASSERT(js::GetObjectCompartment(obj) == js::GetObjectCompartment(proxy));
|
MOZ_ASSERT(js::GetObjectCompartment(obj) == js::GetObjectCompartment(proxy));
|
||||||
if (!JS_GetPropertyDescriptorById(cx, obj, id,
|
if (!JS_GetPropertyDescriptorById(cx, obj, id, desc))
|
||||||
flags, desc))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!desc.object())
|
if (!desc.object())
|
||||||
@@ -905,10 +903,9 @@ bool
|
|||||||
xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
|
xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
|
||||||
JS::Handle<JSObject*> proxy,
|
JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
if (!getPropertyDescriptor(cx, proxy, id, desc, flags))
|
if (!getPropertyDescriptor(cx, proxy, id, desc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (desc.object() != wrappedObject(proxy))
|
if (desc.object() != wrappedObject(proxy))
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapperArg, jsid idArg, Wr
|
|||||||
Access access = NO_ACCESS;
|
Access access = NO_ACCESS;
|
||||||
|
|
||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, hallpass, id, 0, &desc)) {
|
if (!JS_GetPropertyDescriptorById(cx, hallpass, id, &desc)) {
|
||||||
return false; // Error
|
return false; // Error
|
||||||
}
|
}
|
||||||
if (!desc.object() || !desc.isEnumerable())
|
if (!desc.object() || !desc.isEnumerable())
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ PropIsFromStandardPrototype(JSContext *cx, HandleObject wrapper,
|
|||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
ChromeObjectWrapper *handler = &ChromeObjectWrapper::singleton;
|
ChromeObjectWrapper *handler = &ChromeObjectWrapper::singleton;
|
||||||
if (!handler->ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
|
if (!handler->ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
|
||||||
&desc, 0) ||
|
&desc) ||
|
||||||
!desc.object())
|
!desc.object())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -64,15 +64,14 @@ bool
|
|||||||
ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
|
ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
|
||||||
HandleObject wrapper,
|
HandleObject wrapper,
|
||||||
HandleId id,
|
HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, wrapper, id, GET | SET);
|
assertEnteredPolicy(cx, wrapper, id, GET | SET);
|
||||||
// First, try a lookup on the base wrapper if permitted.
|
// First, try a lookup on the base wrapper if permitted.
|
||||||
desc.object().set(nullptr);
|
desc.object().set(nullptr);
|
||||||
if (AllowedByBase(cx, wrapper, id, Wrapper::GET) &&
|
if (AllowedByBase(cx, wrapper, id, Wrapper::GET) &&
|
||||||
!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
|
!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
|
||||||
desc, flags)) {
|
desc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +90,7 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
|
|||||||
|
|
||||||
// If not, try doing the lookup on the prototype.
|
// If not, try doing the lookup on the prototype.
|
||||||
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
|
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
|
||||||
return JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, desc);
|
return JS_GetPropertyDescriptorById(cx, wrapperProto, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -116,7 +115,7 @@ ChromeObjectWrapper::has(JSContext *cx, HandleObject wrapper,
|
|||||||
// Try the prototype if that failed.
|
// Try the prototype if that failed.
|
||||||
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
|
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
|
||||||
Rooted<JSPropertyDescriptor> desc(cx);
|
Rooted<JSPropertyDescriptor> desc(cx);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, &desc))
|
if (!JS_GetPropertyDescriptorById(cx, wrapperProto, id, &desc))
|
||||||
return false;
|
return false;
|
||||||
*bp = !!desc.object();
|
*bp = !!desc.object();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ class ChromeObjectWrapper : public ChromeObjectWrapperBase
|
|||||||
/* Custom traps. */
|
/* Custom traps. */
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool has(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool has(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
|
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
|
||||||
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
|
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
|
||||||
|
|||||||
@@ -60,11 +60,10 @@ template <typename Base, typename Policy>
|
|||||||
bool
|
bool
|
||||||
FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||||
HandleId id,
|
HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
||||||
if (!Base::getPropertyDescriptor(cx, wrapper, id, desc, flags))
|
if (!Base::getPropertyDescriptor(cx, wrapper, id, desc))
|
||||||
return false;
|
return false;
|
||||||
return FilterSetter<Policy>(cx, wrapper, id, desc);
|
return FilterSetter<Policy>(cx, wrapper, id, desc);
|
||||||
}
|
}
|
||||||
@@ -73,11 +72,10 @@ template <typename Base, typename Policy>
|
|||||||
bool
|
bool
|
||||||
FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||||
HandleId id,
|
HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
||||||
if (!Base::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags))
|
if (!Base::getOwnPropertyDescriptor(cx, wrapper, id, desc))
|
||||||
return false;
|
return false;
|
||||||
return FilterSetter<Policy>(cx, wrapper, id, desc);
|
return FilterSetter<Policy>(cx, wrapper, id, desc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,12 +28,10 @@ class FilteringWrapper : public Base {
|
|||||||
|
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::AutoIdVector &props) MOZ_OVERRIDE;
|
JS::AutoIdVector &props) MOZ_OVERRIDE;
|
||||||
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
|
|||||||
@@ -42,19 +42,17 @@ WaiveXrayWrapper::~WaiveXrayWrapper()
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||||
HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc,
|
HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, desc, flags) &&
|
return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, desc) &&
|
||||||
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
|
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper,
|
||||||
HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc,
|
HandleId id, JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags) &&
|
return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc) &&
|
||||||
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
|
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,10 @@ class WaiveXrayWrapper : public js::CrossCompartmentWrapper {
|
|||||||
|
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
|
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
|
||||||
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
|
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ JSXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
|||||||
// muddles through by only checking the holder for non-|own| lookups, but
|
// muddles through by only checking the holder for non-|own| lookups, but
|
||||||
// that doesn't work for us. So we do an explicit holder check here, and hope
|
// that doesn't work for us. So we do an explicit holder check here, and hope
|
||||||
// that this mess gets fixed up soon.
|
// that this mess gets fixed up soon.
|
||||||
if (!JS_GetPropertyDescriptorById(cx, holder, id, 0, desc))
|
if (!JS_GetPropertyDescriptorById(cx, holder, id, desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object()) {
|
if (desc.object()) {
|
||||||
desc.object().set(wrapper);
|
desc.object().set(wrapper);
|
||||||
@@ -482,7 +482,7 @@ JSXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
|||||||
return JS_DefinePropertyById(cx, holder, id,
|
return JS_DefinePropertyById(cx, holder, id,
|
||||||
ObjectValue(*JS_GetFunctionObject(fun)),
|
ObjectValue(*JS_GetFunctionObject(fun)),
|
||||||
nullptr, nullptr, 0) &&
|
nullptr, nullptr, 0) &&
|
||||||
JS_GetPropertyDescriptorById(cx, holder, id, 0, desc);
|
JS_GetPropertyDescriptorById(cx, holder, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -952,7 +952,7 @@ XPCWrappedNativeXrayTraits::resolveDOMCollectionProperty(JSContext *cx, HandleOb
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pobj && !JS_GetPropertyDescriptorById(cx, holder, id, 0, desc))
|
if (pobj && !JS_GetPropertyDescriptorById(cx, holder, id, desc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1138,7 +1138,7 @@ XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
if (expando) {
|
if (expando) {
|
||||||
JSAutoCompartment ac(cx, expando);
|
JSAutoCompartment ac(cx, expando);
|
||||||
if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc))
|
if (!JS_GetPropertyDescriptorById(cx, expando, id, desc))
|
||||||
return false;
|
return false;
|
||||||
found = !!desc.object();
|
found = !!desc.object();
|
||||||
}
|
}
|
||||||
@@ -1184,7 +1184,7 @@ XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
|
|||||||
JSPROP_ENUMERATE | JSPROP_SHARED)) {
|
JSPROP_ENUMERATE | JSPROP_SHARED)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!JS_GetPropertyDescriptorById(cx, holder, id, 0, desc))
|
if (!JS_GetPropertyDescriptorById(cx, holder, id, desc))
|
||||||
return false;
|
return false;
|
||||||
desc.object().set(wrapper);
|
desc.object().set(wrapper);
|
||||||
return true;
|
return true;
|
||||||
@@ -1280,7 +1280,7 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper
|
|||||||
// return non-|own| properties from Object.getOwnPropertyDescriptor if
|
// return non-|own| properties from Object.getOwnPropertyDescriptor if
|
||||||
// lookups are performed in a certain order, but we can probably live with
|
// lookups are performed in a certain order, but we can probably live with
|
||||||
// that until XPCWN Xrays go away with the new DOM bindings.
|
// that until XPCWN Xrays go away with the new DOM bindings.
|
||||||
return JS_GetPropertyDescriptorById(cx, holder, id, 0, desc);
|
return JS_GetPropertyDescriptorById(cx, holder, id, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1778,8 +1778,7 @@ XrayWrapper<Base, Traits>::preventExtensions(JSContext *cx, HandleObject wrapper
|
|||||||
template <typename Base, typename Traits>
|
template <typename Base, typename Traits>
|
||||||
bool
|
bool
|
||||||
XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
||||||
RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper));
|
RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper));
|
||||||
@@ -1813,11 +1812,11 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||||||
// and unconditionally caches what it finds on the holder.
|
// and unconditionally caches what it finds on the holder.
|
||||||
|
|
||||||
// Check resolveOwnProperty.
|
// Check resolveOwnProperty.
|
||||||
if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, flags))
|
if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check the holder.
|
// Check the holder.
|
||||||
if (!desc.object() && !JS_GetPropertyDescriptorById(cx, holder, id, 0, desc))
|
if (!desc.object() && !JS_GetPropertyDescriptorById(cx, holder, id, desc))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object()) {
|
if (desc.object()) {
|
||||||
desc.object().set(wrapper);
|
desc.object().set(wrapper);
|
||||||
@@ -1825,7 +1824,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Nothing in the cache. Call through, and cache the result.
|
// Nothing in the cache. Call through, and cache the result.
|
||||||
if (!Traits::singleton.resolveNativeProperty(cx, wrapper, holder, id, desc, flags))
|
if (!Traits::singleton.resolveNativeProperty(cx, wrapper, holder, id, desc, 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// We need to handle named access on the Window somewhere other than
|
// We need to handle named access on the Window somewhere other than
|
||||||
@@ -1897,7 +1896,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||||||
|
|
||||||
if (!JS_DefinePropertyById(cx, holder, id, desc.value(), desc.getter(),
|
if (!JS_DefinePropertyById(cx, holder, id, desc.value(), desc.getter(),
|
||||||
desc.setter(), desc.attributes()) ||
|
desc.setter(), desc.attributes()) ||
|
||||||
!JS_GetPropertyDescriptorById(cx, holder, id, flags, desc))
|
!JS_GetPropertyDescriptorById(cx, holder, id, desc))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1909,8 +1908,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||||||
template <typename Base, typename Traits>
|
template <typename Base, typename Traits>
|
||||||
bool
|
bool
|
||||||
XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc)
|
||||||
unsigned flags)
|
|
||||||
{
|
{
|
||||||
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::GET | BaseProxyHandler::SET);
|
||||||
RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper));
|
RootedObject holder(cx, Traits::singleton.ensureHolder(cx, wrapper));
|
||||||
@@ -1924,7 +1922,7 @@ XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, HandleObject
|
|||||||
// NB: Nothing we do here acts on the wrapped native itself, so we don't
|
// NB: Nothing we do here acts on the wrapped native itself, so we don't
|
||||||
// enter our policy.
|
// enter our policy.
|
||||||
|
|
||||||
if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, flags))
|
if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, 0))
|
||||||
return false;
|
return false;
|
||||||
if (desc.object())
|
if (desc.object())
|
||||||
desc.object().set(wrapper);
|
desc.object().set(wrapper);
|
||||||
@@ -1996,7 +1994,7 @@ XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper,
|
|||||||
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::SET);
|
assertEnteredPolicy(cx, wrapper, id, BaseProxyHandler::SET);
|
||||||
|
|
||||||
Rooted<JSPropertyDescriptor> existing_desc(cx);
|
Rooted<JSPropertyDescriptor> existing_desc(cx);
|
||||||
if (!getOwnPropertyDescriptor(cx, wrapper, id, &existing_desc, 0))
|
if (!getOwnPropertyDescriptor(cx, wrapper, id, &existing_desc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (existing_desc.object() && existing_desc.isPermanent())
|
if (existing_desc.object() && existing_desc.isPermanent())
|
||||||
|
|||||||
@@ -73,10 +73,9 @@ class XrayWrapper : public Base {
|
|||||||
virtual bool isExtensible(JSContext *cx, JS::Handle<JSObject*> wrapper, bool *extensible) MOZ_OVERRIDE;
|
virtual bool isExtensible(JSContext *cx, JS::Handle<JSObject*> wrapper, bool *extensible) MOZ_OVERRIDE;
|
||||||
virtual bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> wrapper) MOZ_OVERRIDE;
|
virtual bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> wrapper) MOZ_OVERRIDE;
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
unsigned flags);
|
|
||||||
virtual bool defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
virtual bool defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc);
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
||||||
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
||||||
@@ -156,12 +155,10 @@ public:
|
|||||||
|
|
||||||
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
|
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
|
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
|
||||||
JS::Handle<jsid> id,
|
JS::Handle<jsid> id,
|
||||||
JS::MutableHandle<JSPropertyDescriptor> desc,
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||||
unsigned flags) MOZ_OVERRIDE;
|
|
||||||
|
|
||||||
// We just forward the derived traps to the BaseProxyHandler versions which
|
// We just forward the derived traps to the BaseProxyHandler versions which
|
||||||
// implement them in terms of the fundamental traps.
|
// implement them in terms of the fundamental traps.
|
||||||
|
|||||||
Reference in New Issue
Block a user