Bug 828462 - Root Proxy/Wrapper in the browser. r=terrence,bz

This commit is contained in:
Tom Schuster 2013-03-21 23:23:48 +01:00
parent 8253ddf60c
commit 045cb0fba7
15 changed files with 284 additions and 224 deletions

View File

@ -533,46 +533,53 @@ public:
return false;
}
virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper) MOZ_OVERRIDE;
virtual JSString *obj_toString(JSContext *cx,
JS::Handle<JSObject*> wrapper) MOZ_OVERRIDE;
virtual void finalize(JSFreeOp *fop, JSObject *proxy) MOZ_OVERRIDE;
// Fundamental traps
virtual bool getPropertyDescriptor(JSContext* cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext* cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool defineProperty(JSContext* cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool delete_(JSContext *cx, JS::Handle<JSObject *> proxy,
virtual bool delete_(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
bool *bp) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *proxy,
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) MOZ_OVERRIDE;
// Derived traps
virtual bool has(JSContext *cx, JSObject *proxy, jsid id,
bool *bp) MOZ_OVERRIDE;
virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id,
bool *bp) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
jsid id, JS::Value *vp) MOZ_OVERRIDE;
virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, bool strict, JS::Value *vp) MOZ_OVERRIDE;
virtual bool keys(JSContext *cx, JS::Handle<JSObject *> proxy,
virtual bool has(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
virtual bool hasOwn(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id,
JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool set(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id,
bool strict,
JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool keys(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags,
JS::Value *vp) MOZ_OVERRIDE;
virtual bool iterate(JSContext *cx, JS::Handle<JSObject*> proxy,
unsigned flags,
JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
static nsOuterWindowProxy singleton;
@ -600,7 +607,7 @@ protected:
JSString *
nsOuterWindowProxy::obj_toString(JSContext *cx, JSObject *proxy)
nsOuterWindowProxy::obj_toString(JSContext *cx, JS::Handle<JSObject*> proxy)
{
MOZ_ASSERT(js::IsProxy(proxy));
@ -618,7 +625,7 @@ nsOuterWindowProxy::finalize(JSFreeOp *fop, JSObject *proxy)
bool
nsOuterWindowProxy::getPropertyDescriptor(JSContext* cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc,
unsigned flags)
@ -640,7 +647,7 @@ nsOuterWindowProxy::getPropertyDescriptor(JSContext* cx,
bool
nsOuterWindowProxy::getOwnPropertyDescriptor(JSContext* cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc,
unsigned flags)
@ -660,7 +667,7 @@ nsOuterWindowProxy::getOwnPropertyDescriptor(JSContext* cx,
bool
nsOuterWindowProxy::defineProperty(JSContext* cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc)
{
@ -677,7 +684,8 @@ nsOuterWindowProxy::defineProperty(JSContext* cx,
}
bool
nsOuterWindowProxy::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> proxy,
nsOuterWindowProxy::getOwnPropertyNames(JSContext *cx,
JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props)
{
// Just our indexed stuff followed by our "normal" own property names.
@ -693,7 +701,7 @@ nsOuterWindowProxy::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> pr
}
bool
nsOuterWindowProxy::delete_(JSContext *cx, JS::Handle<JSObject *> proxy,
nsOuterWindowProxy::delete_(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp)
{
if (nsCOMPtr<nsIDOMWindow> frame = GetSubframeWindow(cx, proxy, id)) {
@ -714,7 +722,7 @@ nsOuterWindowProxy::delete_(JSContext *cx, JS::Handle<JSObject *> proxy,
}
bool
nsOuterWindowProxy::enumerate(JSContext *cx, JSObject *proxy,
nsOuterWindowProxy::enumerate(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props)
{
// Just our indexed stuff followed by our "normal" own property names.
@ -730,7 +738,8 @@ nsOuterWindowProxy::enumerate(JSContext *cx, JSObject *proxy,
}
bool
nsOuterWindowProxy::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
nsOuterWindowProxy::has(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp)
{
if (nsCOMPtr<nsIDOMWindow> frame = GetSubframeWindow(cx, proxy, id)) {
*bp = true;
@ -741,7 +750,8 @@ nsOuterWindowProxy::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
}
bool
nsOuterWindowProxy::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
nsOuterWindowProxy::hasOwn(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp)
{
if (nsCOMPtr<nsIDOMWindow> frame = GetSubframeWindow(cx, proxy, id)) {
*bp = true;
@ -752,17 +762,19 @@ nsOuterWindowProxy::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
}
bool
nsOuterWindowProxy::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
jsid id, JS::Value *vp)
nsOuterWindowProxy::get(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id,
JS::MutableHandle<JS::Value> vp)
{
if (id == nsDOMClassInfo::sWrappedJSObject_id &&
xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) {
*vp = JS::ObjectValue(*wrapper);
vp.set(JS::ObjectValue(*proxy));
return true;
}
bool found;
if (!GetSubframeWindow(cx, wrapper, id, vp, found)) {
if (!GetSubframeWindow(cx, proxy, id, vp.address(), found)) {
return false;
}
if (found) {
@ -770,12 +782,15 @@ nsOuterWindowProxy::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
}
// Else fall through to js::Wrapper
return js::Wrapper::get(cx, wrapper, receiver, id, vp);
return js::Wrapper::get(cx, proxy, receiver, id, vp);
}
bool
nsOuterWindowProxy::set(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, bool strict, JS::Value *vp)
nsOuterWindowProxy::set(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id,
bool strict,
JS::MutableHandle<JS::Value> vp)
{
int32_t index = GetArrayIndexFromId(cx, id);
if (IsArrayIndex(index)) {
@ -790,7 +805,7 @@ nsOuterWindowProxy::set(JSContext *cx, JSObject *proxy, JSObject *receiver,
}
bool
nsOuterWindowProxy::keys(JSContext *cx, JS::Handle<JSObject *> proxy,
nsOuterWindowProxy::keys(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props)
{
// BaseProxyHandler::keys seems to do what we want here: call
@ -799,8 +814,8 @@ nsOuterWindowProxy::keys(JSContext *cx, JS::Handle<JSObject *> proxy,
}
bool
nsOuterWindowProxy::iterate(JSContext *cx, JSObject *proxy, unsigned flags,
JS::Value *vp)
nsOuterWindowProxy::iterate(JSContext *cx, JS::Handle<JSObject*> proxy,
unsigned flags, JS::MutableHandle<JS::Value> vp)
{
// BaseProxyHandler::iterate seems to do what we want here: fall
// back on the property names returned from keys() and enumerate().
@ -870,13 +885,14 @@ class nsChromeOuterWindowProxy : public nsOuterWindowProxy
public:
nsChromeOuterWindowProxy() : nsOuterWindowProxy() {}
virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper);
virtual JSString *obj_toString(JSContext *cx, JS::Handle<JSObject*> wrapper);
static nsChromeOuterWindowProxy singleton;
};
JSString *
nsChromeOuterWindowProxy::obj_toString(JSContext *cx, JSObject *proxy)
nsChromeOuterWindowProxy::obj_toString(JSContext *cx,
JS::Handle<JSObject*> proxy)
{
MOZ_ASSERT(js::IsProxy(proxy));

View File

@ -1328,9 +1328,11 @@ ConcatJSString(JSContext* cx, const char* pre, JSString* str, const char* post)
}
bool
NativeToString(JSContext* cx, JSObject* wrapper, JSObject* obj, const char* pre,
NativeToString(JSContext* cx, JSObject* wrapper, JSObject* object, const char* pre,
const char* post, JS::Value* v)
{
JS::Rooted<JSObject*> obj(cx, object);
JSPropertyDescriptor toStringDesc;
toStringDesc.obj = nullptr;
toStringDesc.attrs = 0;

View File

@ -5819,7 +5819,7 @@ class CGEnumerateOwnProperties(CGAbstractMethod):
def definition_body(self):
return """ // We rely on getOwnPropertyNames not shadowing prototype properties by named
// properties. If that changes we'll need to filter here.
JS::Rooted<JSObject *> wrapper(cx, wrapper_);
JS::Rooted<JSObject*> wrapper(cx, wrapper_);
return js::GetProxyHandler(obj)->getOwnPropertyNames(cx, wrapper, props);
"""
@ -6162,7 +6162,7 @@ return true;"""
class CGDOMJSProxyHandler_defineProperty(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject *>', 'proxy'),
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('JS::Handle<jsid>', 'id'),
Argument('JSPropertyDescriptor*', 'desc')]
ClassMethod.__init__(self, "defineProperty", "bool", args)
@ -6212,7 +6212,7 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod):
class CGDOMJSProxyHandler_delete(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject *>', 'proxy'),
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('JS::Handle<jsid>', 'id'),
Argument('bool*', 'bp')]
ClassMethod.__init__(self, "delete_", "bool", args)
@ -6281,7 +6281,7 @@ class CGDOMJSProxyHandler_delete(ClassMethod):
class CGDOMJSProxyHandler_getOwnPropertyNames(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject *>', 'proxy'),
Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('JS::AutoIdVector&', 'props')]
ClassMethod.__init__(self, "getOwnPropertyNames", "bool", args)
self.descriptor = descriptor
@ -6321,8 +6321,10 @@ return true;"""
class CGDOMJSProxyHandler_hasOwn(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'),
Argument('jsid', 'id'), Argument('bool*', 'bp')]
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('JS::Handle<jsid>', 'id'),
Argument('bool*', 'bp')]
ClassMethod.__init__(self, "hasOwn", "bool", args)
self.descriptor = descriptor
def getBody(self):
@ -6363,9 +6365,11 @@ return true;"""
class CGDOMJSProxyHandler_get(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'),
Argument('JSObject*', 'receiver'), Argument('jsid', 'id'),
Argument('JS::Value*', 'vp')]
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('JS::Handle<JSObject*>', 'receiver'),
Argument('JS::Handle<jsid>', 'id'),
Argument('JS::MutableHandle<JS::Value>', 'vp')]
ClassMethod.__init__(self, "get", "bool", args)
self.descriptor = descriptor
def getBody(self):
@ -6377,11 +6381,11 @@ if (expando) {
}
if (hasProp) {
return JS_GetPropertyById(cx, expando, id, vp);
return JS_GetPropertyById(cx, expando, id, vp.address());
}
}"""
templateValues = {'jsvalRef': '*vp', 'jsvalPtr': 'vp', 'obj': 'proxy'}
templateValues = {'jsvalRef': '*vp.address()', 'jsvalPtr': 'vp.address()', 'obj': 'proxy'}
if self.descriptor.supportsIndexedProperties():
getIndexedOrExpando = ("int32_t index = GetArrayIndexFromId(cx, id);\n" +
@ -6411,7 +6415,7 @@ if (expando) {
%s
{ // Scope for this "found" so it doesn't leak to things below
bool found;
if (!GetPropertyOnPrototype(cx, proxy, id, &found, vp)) {
if (!GetPropertyOnPrototype(cx, proxy, id, &found, vp.address())) {
return false;
}
@ -6420,12 +6424,12 @@ if (expando) {
}
}
%s
vp->setUndefined();
vp.setUndefined();
return true;""" % (getIndexedOrExpando, getNamed)
class CGDOMJSProxyHandler_obj_toString(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy')]
args = [Argument('JSContext*', 'cx'), Argument('JS::Handle<JSObject*>', 'proxy')]
ClassMethod.__init__(self, "obj_toString", "JSString*", args)
self.descriptor = descriptor
def getBody(self):
@ -6450,16 +6454,18 @@ class CGDOMJSProxyHandler_finalize(ClassMethod):
class CGDOMJSProxyHandler_getElementIfPresent(ClassMethod):
def __init__(self, descriptor):
args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'),
Argument('JSObject*', 'receiver'),
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('JS::Handle<JSObject*>', 'receiver'),
Argument('uint32_t', 'index'),
Argument('JS::Value*', 'vp'), Argument('bool*', 'present')]
Argument('JS::MutableHandle<JS::Value>', 'vp'),
Argument('bool*', 'present')]
ClassMethod.__init__(self, "getElementIfPresent", "bool", args)
self.descriptor = descriptor
def getBody(self):
successCode = ("*present = found;\n"
"return true;")
templateValues = {'jsvalRef': '*vp', 'jsvalPtr': 'vp',
templateValues = {'jsvalRef': '*vp.address()', 'jsvalPtr': 'vp.address()',
'obj': 'proxy', 'successCode': successCode}
if self.descriptor.supportsIndexedProperties():
get = (CGProxyIndexedGetter(self.descriptor, templateValues).define() + "\n"
@ -6475,7 +6481,7 @@ class CGDOMJSProxyHandler_getElementIfPresent(ClassMethod):
JSObject* expando = GetExpandoObject(proxy);
if (expando) {
JSBool isPresent;
if (!JS_GetElementIfPresent(cx, expando, index, expando, vp, &isPresent)) {
if (!JS_GetElementIfPresent(cx, expando, index, expando, vp.address(), &isPresent)) {
return false;
}
if (isPresent) {
@ -6495,7 +6501,7 @@ if (!js::GetObjectProto(cx, proxy, &proto)) {
}
if (proto) {
JSBool isPresent;
if (!JS_GetElementIfPresent(cx, proto, index, proxy, vp, &isPresent)) {
if (!JS_GetElementIfPresent(cx, proto, index, proxy, vp.address(), &isPresent)) {
return false;
}
*present = isPresent;

View File

@ -76,7 +76,7 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JSObject* obj)
}
bool
DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject *> proxy, JS::Handle<jsid> id,
DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc, unsigned flags)
{
if (!getOwnPropertyDescriptor(cx, proxy, id, desc, flags)) {
@ -99,7 +99,7 @@ DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject *> pro
}
bool
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject *> proxy, JS::Handle<jsid> id,
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc)
{
if ((desc->attrs & JSPROP_GETTER) && desc->setter == JS_StrictPropertyStub) {
@ -124,7 +124,7 @@ DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject *> proxy, JS:
}
bool
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject *> proxy,
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool* bp)
{
JSBool b = true;
@ -142,10 +142,8 @@ DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject *> proxy,
}
bool
DOMProxyHandler::enumerate(JSContext* cx, JSObject* proxy_, AutoIdVector& props)
DOMProxyHandler::enumerate(JSContext* cx, JS::Handle<JSObject*> proxy, AutoIdVector& props)
{
JS::Rooted<JSObject *> proxy(cx, proxy_);
JSObject* proto;
if (!JS_GetPrototype(cx, proxy, &proto)) {
return false;
@ -155,14 +153,7 @@ DOMProxyHandler::enumerate(JSContext* cx, JSObject* proxy_, AutoIdVector& props)
}
bool
DOMProxyHandler::fix(JSContext* cx, JSObject* proxy, Value* vp)
{
vp->setUndefined();
return true;
}
bool
DOMProxyHandler::has(JSContext* cx, JSObject* proxy, jsid id, bool* bp)
DOMProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp)
{
if (!hasOwn(cx, proxy, id, bp)) {
return false;

View File

@ -36,15 +36,14 @@ public:
{
}
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject *> proxy, JS::Handle<jsid> id, JSPropertyDescriptor* desc,
unsigned flags) MOZ_OVERRIDE;
bool defineProperty(JSContext* cx, JS::Handle<JSObject *> proxy, JS::Handle<jsid> id,
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc, unsigned flags) MOZ_OVERRIDE;
bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc) MOZ_OVERRIDE;
bool delete_(JSContext* cx, JS::Handle<JSObject *> proxy,
bool delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
bool enumerate(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
bool fix(JSContext* cx, JSObject* proxy, JS::Value* vp);
bool has(JSContext* cx, JSObject* proxy, jsid id, bool* bp) MOZ_OVERRIDE;
bool enumerate(JSContext* cx, JS::Handle<JSObject*> proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
bool has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
using js::BaseProxyHandler::obj_toString;
static JSObject* GetExpandoObject(JSObject* obj)
@ -118,7 +117,7 @@ FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, jsval v, bool
FillPropertyDescriptor(desc, obj, readonly);
}
JSObject*
JSObject*
EnsureExpandoObject(JSContext* cx, JSObject* obj);
} // namespace dom

View File

@ -455,8 +455,9 @@ XPCLazyCallContext::AssertContextIsTopOfStack(JSContext* cx)
#endif
XPCWrappedNative*
XPCCallContext::UnwrapThisIfAllowed(JSObject *obj, JSObject *fun, unsigned argc)
XPCCallContext::UnwrapThisIfAllowed(JSObject *object, JSObject *fun, unsigned argc)
{
JS::Rooted<JSObject *> obj(mJSContext, object);
// We should only get here for objects that aren't safe to unwrap.
MOZ_ASSERT(!js::UnwrapObjectChecked(obj));
MOZ_ASSERT(js::IsObjectInContextCompartment(obj, mJSContext));
@ -501,7 +502,8 @@ XPCCallContext::UnwrapThisIfAllowed(JSObject *obj, JSObject *fun, unsigned argc)
js::Wrapper::Action act = set ? js::Wrapper::SET : js::Wrapper::GET;
js::Wrapper *handler = js::Wrapper::wrapperHandler(obj);
bool ignored;
if (!handler->enter(mJSContext, obj, member->GetName(), act, &ignored))
JS::Rooted<jsid> id(mJSContext, member->GetName());
if (!handler->enter(mJSContext, obj, id, act, &ignored))
return nullptr;
// Ok, this call is safe.

View File

@ -3047,7 +3047,7 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponents_utils_Sandbox)
xpc::SandboxProxyHandler xpc::sandboxProxyHandler;
bool
xpc::SandboxCallableProxyHandler::call(JSContext *cx, JSObject *proxy,
xpc::SandboxCallableProxyHandler::call(JSContext *cx, JS::Handle<JSObject*> proxy,
unsigned argc, Value *vp)
{
// We forward the call to our underlying callable. The callable to forward
@ -3160,7 +3160,7 @@ XPC_WN_Helper_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBo
bool
xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
PropertyDescriptor *desc,
unsigned flags)
@ -3208,7 +3208,7 @@ xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
bool
xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
JS::Handle<JSObject *> proxy,
JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id,
PropertyDescriptor *desc,
unsigned flags)
@ -3228,41 +3228,47 @@ xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
*/
bool
xpc::SandboxProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
xpc::SandboxProxyHandler::has(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp)
{
return BaseProxyHandler::has(cx, proxy, id, bp);
}
bool
xpc::SandboxProxyHandler::hasOwn(JSContext *cx, JSObject *proxy, jsid id,
bool *bp)
xpc::SandboxProxyHandler::hasOwn(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, bool *bp)
{
return BaseProxyHandler::hasOwn(cx, proxy, id, bp);
}
bool
xpc::SandboxProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, Value *vp)
xpc::SandboxProxyHandler::get(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id,
JS::MutableHandle<Value> vp)
{
return BaseProxyHandler::get(cx, proxy, receiver, id, vp);
}
bool
xpc::SandboxProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, bool strict, Value *vp)
xpc::SandboxProxyHandler::set(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id,
bool strict,
JS::MutableHandle<Value> vp)
{
return BaseProxyHandler::set(cx, proxy, receiver, id, strict, vp);
}
bool
xpc::SandboxProxyHandler::keys(JSContext *cx, JS::Handle<JSObject *> proxy,
xpc::SandboxProxyHandler::keys(JSContext *cx, JS::Handle<JSObject*> proxy,
AutoIdVector &props)
{
return BaseProxyHandler::keys(cx, proxy, props);
}
bool
xpc::SandboxProxyHandler::iterate(JSContext *cx, JSObject *proxy, unsigned flags,
Value *vp)
xpc::SandboxProxyHandler::iterate(JSContext *cx, JS::Handle<JSObject*> proxy,
unsigned flags, JS::MutableHandle<Value> vp)
{
return BaseProxyHandler::iterate(cx, proxy, flags, vp);
}

View File

@ -17,7 +17,8 @@ ChromeObjectWrapper ChromeObjectWrapper::singleton;
using js::assertEnteredPolicy;
static bool
AllowedByBase(JSContext *cx, JSObject *wrapper, jsid id, js::Wrapper::Action act)
AllowedByBase(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::Wrapper::Action act)
{
MOZ_ASSERT(js::Wrapper::wrapperHandler(wrapper) ==
&ChromeObjectWrapper::singleton);
@ -40,11 +41,9 @@ PropIsFromStandardPrototype(JSContext *cx, JSPropertyDescriptor *desc)
// This lets us determine whether the property we would have found (given a
// transparent wrapper) would have come off a standard prototype.
static bool
PropIsFromStandardPrototype(JSContext *cx, JSObject *wrapperArg, jsid idArg)
PropIsFromStandardPrototype(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id)
{
JS::Rooted<JSObject *> wrapper(cx, wrapperArg);
JS::Rooted<jsid> id(cx, idArg);
MOZ_ASSERT(js::Wrapper::wrapperHandler(wrapper) ==
&ChromeObjectWrapper::singleton);
JSPropertyDescriptor desc;
@ -60,7 +59,7 @@ PropIsFromStandardPrototype(JSContext *cx, JSObject *wrapperArg, jsid idArg)
bool
ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
JS::Handle<JSObject *> wrapper,
JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id,
js::PropertyDescriptor *desc,
unsigned flags)
@ -93,7 +92,8 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
}
bool
ChromeObjectWrapper::has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
ChromeObjectWrapper::has(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, bool *bp)
{
assertEnteredPolicy(cx, wrapper, id);
// Try the lookup on the base wrapper if permitted.
@ -120,11 +120,12 @@ ChromeObjectWrapper::has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
}
bool
ChromeObjectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
jsid id, js::Value *vp)
ChromeObjectWrapper::get(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> receiver, JS::Handle<jsid> id,
JS::MutableHandle<JS::Value> vp)
{
assertEnteredPolicy(cx, wrapper, id);
vp->setUndefined();
vp.setUndefined();
JSPropertyDescriptor desc;
// Only call through to the get trap on the underlying object if we're
// allowed to see the property, and if what we'll find is not on a standard
@ -136,7 +137,7 @@ ChromeObjectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
if (!ChromeObjectWrapperBase::get(cx, wrapper, receiver, id, vp))
return false;
// If we found something, we're done.
if (!vp->isUndefined())
if (!vp.isUndefined())
return true;
}
@ -149,14 +150,14 @@ ChromeObjectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
// Try the prototype.
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
return js::GetGeneric(cx, wrapperProto, receiver, id, vp);
return js::GetGeneric(cx, wrapperProto, receiver, id, vp.address());
}
// SecurityWrapper categorically returns false for objectClassIs, but the
// contacts API depends on Array.isArray returning true for COW-implemented
// contacts. This isn't really ideal, but make it work for now.
bool
ChromeObjectWrapper::objectClassIs(JSObject *obj, js::ESClassValue classValue,
ChromeObjectWrapper::objectClassIs(JS::Handle<JSObject*> obj, js::ESClassValue classValue,
JSContext *cx)
{
return CrossCompartmentWrapper::objectClassIs(obj, classValue, cx);
@ -167,8 +168,8 @@ ChromeObjectWrapper::objectClassIs(JSObject *obj, js::ESClassValue classValue,
// enforcement or COWs isn't cheap. But it results in the cleanest code, and this
// whole proto remapping thing for COWs is going to be phased out anyway.
bool
ChromeObjectWrapper::enter(JSContext *cx, JSObject *wrapper, jsid id,
js::Wrapper::Action act, bool *bp)
ChromeObjectWrapper::enter(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, js::Wrapper::Action act, bool *bp)
{
if (AllowedByBase(cx, wrapper, id, act))
return true;

View File

@ -29,18 +29,18 @@ class ChromeObjectWrapper : public ChromeObjectWrapperBase
ChromeObjectWrapper() : ChromeObjectWrapperBase(0) {}
/* 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::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool has(JSContext *cx, JSObject *wrapper, jsid id,
bool *bp) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
jsid id, js::Value *vp) MOZ_OVERRIDE;
virtual bool has(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool objectClassIs(JSObject *obj, js::ESClassValue classValue,
virtual bool objectClassIs(JS::Handle<JSObject*> obj, js::ESClassValue classValue,
JSContext *cx) MOZ_OVERRIDE;
virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id,
virtual bool enter(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::Wrapper::Action act, bool *bp) MOZ_OVERRIDE;
// NB: One might think we'd need to implement enumerate(), keys(), iterate(),

View File

@ -38,7 +38,7 @@ FilteringWrapper<Base, Policy>::isSafeToUnwrap()
template <typename Policy>
static bool
Filter(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
Filter(JSContext *cx, JS::Handle<JSObject*> wrapper, AutoIdVector &props)
{
size_t w = 0;
for (size_t n = 0; n < props.length(); ++n) {
@ -67,7 +67,7 @@ FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, js::PropertyDescriptor *
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper,
FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags)
{
@ -79,7 +79,7 @@ FilteringWrapper<Base, Policy>::getPropertyDescriptor(JSContext *cx, JS::Handle<
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper,
FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id,
js::PropertyDescriptor *desc,
unsigned flags)
@ -92,7 +92,7 @@ FilteringWrapper<Base, Policy>::getOwnPropertyDescriptor(JSContext *cx, JS::Hand
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> wrapper,
FilteringWrapper<Base, Policy>::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
AutoIdVector &props)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
@ -102,7 +102,8 @@ FilteringWrapper<Base, Policy>::getOwnPropertyNames(JSContext *cx, JS::Handle<JS
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
FilteringWrapper<Base, Policy>::enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper,
AutoIdVector &props)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
return Base::enumerate(cx, wrapper, props) &&
@ -111,7 +112,7 @@ FilteringWrapper<Base, Policy>::enumerate(JSContext *cx, JSObject *wrapper, Auto
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::keys(JSContext *cx, JS::Handle<JSObject *> wrapper,
FilteringWrapper<Base, Policy>::keys(JSContext *cx, JS::Handle<JSObject*> wrapper,
AutoIdVector &props)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
@ -121,7 +122,8 @@ FilteringWrapper<Base, Policy>::keys(JSContext *cx, JS::Handle<JSObject *> wrapp
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::iterate(JSContext *cx, JSObject *wrapper, unsigned flags, Value *vp)
FilteringWrapper<Base, Policy>::iterate(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned flags, JS::MutableHandle<JS::Value> vp)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
// We refuse to trigger the iterator hook across chrome wrappers because
@ -143,8 +145,8 @@ FilteringWrapper<Base, Policy>::nativeCall(JSContext *cx, JS::IsAcceptableThis t
template <typename Base, typename Policy>
bool
FilteringWrapper<Base, Policy>::enter(JSContext *cx, JSObject *wrapper, jsid id,
Wrapper::Action act, bool *bp)
FilteringWrapper<Base, Policy>::enter(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, Wrapper::Action act, bool *bp)
{
// This is a super ugly hacky to get around Xray Resolve wonkiness.
//

View File

@ -22,16 +22,25 @@ class FilteringWrapper : public Base {
// This is potentially dynamic until XBL scopes are no longer behind a pref.
virtual bool isSafeToUnwrap();
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id, js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id, js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool keys(JSContext *cx, JS::Handle<JSObject *> wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, js::Value *vp) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
js::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper,
js::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool keys(JSContext *cx, JS::Handle<JSObject*> wrapper,
js::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool iterate(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned flags,
JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool nativeCall(JSContext *cx, JS::IsAcceptableThis test, JS::NativeImpl impl,
JS::CallArgs args) MOZ_OVERRIDE;
virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, js::Wrapper::Action act, bool *bp) MOZ_OVERRIDE;
virtual bool enter(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::Wrapper::Action act, bool *bp) MOZ_OVERRIDE;
static FilteringWrapper singleton;
};

View File

@ -24,7 +24,7 @@ WaiveXrayWrapper::~WaiveXrayWrapper()
}
bool
WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *>wrapper,
WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*>wrapper,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags)
{
@ -33,7 +33,7 @@ WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *>wra
}
bool
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper,
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags)
{
@ -42,26 +42,28 @@ WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *>
}
bool
WaiveXrayWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
js::Value *vp)
WaiveXrayWrapper::get(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> receiver, JS::Handle<jsid> id,
JS::MutableHandle<JS::Value> vp)
{
return CrossCompartmentWrapper::get(cx, wrapper, receiver, id, vp) &&
WrapperFactory::WaiveXrayAndWrap(cx, vp);
WrapperFactory::WaiveXrayAndWrap(cx, vp.address());
}
bool
WaiveXrayWrapper::call(JSContext *cx, JSObject *wrapper, unsigned argc, js::Value *vp)
WaiveXrayWrapper::call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
js::Value *vp)
{
return CrossCompartmentWrapper::call(cx, wrapper, argc, vp) &&
WrapperFactory::WaiveXrayAndWrap(cx, vp);
}
bool
WaiveXrayWrapper::construct(JSContext *cx, JSObject *wrapper,
unsigned argc, js::Value *argv, js::Value *rval)
WaiveXrayWrapper::construct(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, js::Value *argv, JS::MutableHandle<JS::Value> rval)
{
return CrossCompartmentWrapper::construct(cx, wrapper, argc, argv, rval) &&
WrapperFactory::WaiveXrayAndWrap(cx, rval);
WrapperFactory::WaiveXrayAndWrap(cx, rval.address());
}
}

View File

@ -20,15 +20,21 @@ class WaiveXrayWrapper : public js::CrossCompartmentWrapper {
WaiveXrayWrapper(unsigned flags);
virtual ~WaiveXrayWrapper();
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id, js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
js::Value *vp) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id,
js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool call(JSContext *cx, JSObject *wrapper, unsigned argc, js::Value *vp) MOZ_OVERRIDE;
virtual bool construct(JSContext *cx, JSObject *wrapper,
unsigned argc, js::Value *argv, js::Value *rval) MOZ_OVERRIDE;
virtual bool call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
js::Value *vp) MOZ_OVERRIDE;
virtual bool construct(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, js::Value *argv,
JS::MutableHandle<JS::Value> rval) MOZ_OVERRIDE;
static WaiveXrayWrapper singleton;
};

View File

@ -135,12 +135,12 @@ public:
JSObject *wrapper, JSObject *holder,
jsid id, JSPropertyDescriptor *desc, unsigned flags);
static bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp)
static bool call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc, Value *vp)
{
MOZ_NOT_REACHED("Call trap currently implemented only for XPCWNs");
}
static bool construct(JSContext *cx, JSObject *wrapper, unsigned argc,
Value *argv, Value *rval)
static bool construct(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
Value *argv, JS::MutableHandle<Value> rval)
{
MOZ_NOT_REACHED("Call trap currently implemented only for XPCWNs");
}
@ -182,16 +182,16 @@ public:
virtual bool resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper, JSObject *wrapper,
JSObject *holder, jsid id, JSPropertyDescriptor *desc,
unsigned flags);
static bool defineProperty(JSContext *cx, JS::Handle<JSObject *> wrapper,
static bool defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid>,
PropertyDescriptor *desc,
PropertyDescriptor &existingDesc,
bool *defined);
static bool enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
JS::AutoIdVector &props);
static bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp);
static bool construct(JSContext *cx, JSObject *wrapper, unsigned argc,
Value *argv, Value *rval);
static bool call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc, Value *vp);
static bool construct(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
Value *argv, JS::MutableHandle<JS::Value> rval);
static bool isResolving(JSContext *cx, JSObject *holder, jsid id);
@ -233,9 +233,9 @@ public:
bool *defined);
static bool enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
JS::AutoIdVector &props);
static bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp);
static bool construct(JSContext *cx, JSObject *wrapper, unsigned argc,
Value *argv, Value *rval);
static bool call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc, Value *vp);
static bool construct(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
Value *argv, JS::MutableHandle<JS::Value> rval);
static bool isResolving(JSContext *cx, JSObject *holder, jsid id)
{
@ -1109,7 +1109,7 @@ XPCWrappedNativeXrayTraits::createHolder(JSContext *cx, JSObject *wrapper)
}
bool
XPCWrappedNativeXrayTraits::call(JSContext *cx, JSObject *wrapper,
XPCWrappedNativeXrayTraits::call(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, Value *vp)
{
// Run the resolve hook of the wrapped native.
@ -1134,18 +1134,20 @@ XPCWrappedNativeXrayTraits::call(JSContext *cx, JSObject *wrapper,
}
bool
XPCWrappedNativeXrayTraits::construct(JSContext *cx, JSObject *wrapper,
unsigned argc, Value *argv, Value *rval)
XPCWrappedNativeXrayTraits::construct(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, Value *argv,
JS::MutableHandle<JS::Value> rval)
{
// Run the resolve hook of the wrapped native.
XPCWrappedNative *wn = getWN(wrapper);
if (NATIVE_HAS_FLAG(wn, WantConstruct)) {
XPCCallContext ccx(JS_CALLER, cx, wrapper, nullptr, JSID_VOID, argc, argv, rval);
XPCCallContext ccx(JS_CALLER, cx, wrapper, nullptr, JSID_VOID, argc, argv, rval.address());
if (!ccx.IsValid())
return false;
bool ok = true;
nsresult rv = wn->GetScriptableInfo()->GetCallback()->Construct(wn, cx, wrapper,
argc, argv, rval, &ok);
argc, argv, rval.address(),
&ok);
if (NS_FAILED(rv)) {
if (ok)
XPCThrower::Throw(rv, cx);
@ -1218,7 +1220,7 @@ DOMXrayTraits::enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
}
bool
DOMXrayTraits::call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp)
DOMXrayTraits::call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc, Value *vp)
{
JSObject *obj = getTargetObject(wrapper);
AutoValueRooter rval(cx);
@ -1241,8 +1243,8 @@ DOMXrayTraits::call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp)
}
bool
DOMXrayTraits::construct(JSContext *cx, JSObject *wrapper, unsigned argc,
Value *argv, Value *rval)
DOMXrayTraits::construct(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
Value *argv, JS::MutableHandle<JS::Value> rval)
{
JSObject *obj = getTargetObject(wrapper);
MOZ_ASSERT(mozilla::dom::HasConstructor(obj));
@ -1257,7 +1259,7 @@ DOMXrayTraits::construct(JSContext *cx, JSObject *wrapper, unsigned argc,
}
if (!newObj || !JS_WrapObject(cx, &newObj))
return false;
rval->setObject(*newObj);
rval.setObject(*newObj);
return true;
}
@ -1415,7 +1417,7 @@ DEBUG_CheckXBLLookup(JSContext *cx, JSPropertyDescriptor *desc)
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper,
XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags)
{
@ -1558,7 +1560,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObj
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper,
XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id,
PropertyDescriptor *desc, unsigned flags)
{
@ -1606,8 +1608,8 @@ XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JS
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
js::PropertyDescriptor *desc)
XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper,
HandleId id, js::PropertyDescriptor *desc)
{
assertEnteredPolicy(cx, wrapper, id);
// Redirect access straight to the wrapper if we should be transparent.
@ -1659,7 +1661,7 @@ XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper, H
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> wrapper,
XrayWrapper<Base, Traits>::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::AutoIdVector &props)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
@ -1668,7 +1670,7 @@ XrayWrapper<Base, Traits>::getOwnPropertyNames(JSContext *cx, JS::Handle<JSObjec
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::delete_(JSContext *cx, JS::Handle<JSObject *> wrapper,
XrayWrapper<Base, Traits>::delete_(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, bool *bp)
{
assertEnteredPolicy(cx, wrapper, id);
@ -1705,7 +1707,7 @@ XrayWrapper<Base, Traits>::delete_(JSContext *cx, JS::Handle<JSObject *> wrapper
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::enumerate(JSContext *cx, JSObject *wrapper, unsigned flags,
XrayWrapper<Base, Traits>::enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned flags,
JS::AutoIdVector &props)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
@ -1738,15 +1740,17 @@ XrayWrapper<Base, Traits>::enumerate(JSContext *cx, JSObject *wrapper, unsigned
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::enumerate(JSContext *cx, JSObject *wrapper, JS::AutoIdVector &props)
XrayWrapper<Base, Traits>::enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::AutoIdVector &props)
{
return enumerate(cx, wrapper, 0, props);
}
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
js::Value *vp)
XrayWrapper<Base, Traits>::get(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> receiver, JS::Handle<jsid> id,
JS::MutableHandle<JS::Value> vp)
{
// Skip our Base if it isn't already ProxyHandler.
// NB: None of the functions we call are prepared for the receiver not
@ -1756,8 +1760,9 @@ XrayWrapper<Base, Traits>::get(JSContext *cx, JSObject *wrapper, JSObject *recei
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
bool strict, js::Value *vp)
XrayWrapper<Base, Traits>::set(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> receiver, JS::Handle<jsid> id,
bool strict, JS::MutableHandle<JS::Value> vp)
{
// Skip our Base if it isn't already BaseProxyHandler.
// NB: None of the functions we call are prepared for the receiver not
@ -1767,7 +1772,8 @@ XrayWrapper<Base, Traits>::set(JSContext *cx, JSObject *wrapper, JSObject *recei
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
XrayWrapper<Base, Traits>::has(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, bool *bp)
{
// Skip our Base if it isn't already ProxyHandler.
return BaseProxyHandler::has(cx, wrapper, id, bp);
@ -1775,7 +1781,8 @@ XrayWrapper<Base, Traits>::has(JSContext *cx, JSObject *wrapper, jsid id, bool *
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
XrayWrapper<Base, Traits>::hasOwn(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, bool *bp)
{
// Skip our Base if it isn't already ProxyHandler.
return BaseProxyHandler::hasOwn(cx, wrapper, id, bp);
@ -1783,7 +1790,7 @@ XrayWrapper<Base, Traits>::hasOwn(JSContext *cx, JSObject *wrapper, jsid id, boo
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::keys(JSContext *cx, JS::Handle<JSObject *> wrapper,
XrayWrapper<Base, Traits>::keys(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::AutoIdVector &props)
{
// Skip our Base if it isn't already ProxyHandler.
@ -1792,8 +1799,8 @@ XrayWrapper<Base, Traits>::keys(JSContext *cx, JS::Handle<JSObject *> wrapper,
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::iterate(JSContext *cx, JSObject *wrapper, unsigned flags,
js::Value *vp)
XrayWrapper<Base, Traits>::iterate(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned flags, JS::MutableHandle<JS::Value> vp)
{
// Skip our Base if it isn't already ProxyHandler.
return BaseProxyHandler::iterate(cx, wrapper, flags, vp);
@ -1801,7 +1808,8 @@ XrayWrapper<Base, Traits>::iterate(JSContext *cx, JSObject *wrapper, unsigned fl
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::call(JSContext *cx, JSObject *wrapper, unsigned argc, js::Value *vp)
XrayWrapper<Base, Traits>::call(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, js::Value *vp)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
return Traits::call(cx, wrapper, argc, vp);
@ -1809,8 +1817,9 @@ XrayWrapper<Base, Traits>::call(JSContext *cx, JSObject *wrapper, unsigned argc,
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::construct(JSContext *cx, JSObject *wrapper, unsigned argc,
js::Value *argv, js::Value *rval)
XrayWrapper<Base, Traits>::construct(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, JS::Value *argv,
JS::MutableHandle<JS::Value> rval)
{
assertEnteredPolicy(cx, wrapper, JSID_VOID);
return Traits::construct(cx, wrapper, argc, argv, rval);

View File

@ -66,37 +66,43 @@ class XrayWrapper : public Base {
virtual ~XrayWrapper();
/* Fundamental proxy traps. */
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id,
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags);
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool defineProperty(JSContext *cx, JS::Handle<JSObject *> wrapper, JS::Handle<jsid> id,
unsigned flags);
virtual bool defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::PropertyDescriptor *desc);
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject *> wrapper,
virtual bool getOwnPropertyNames(JSContext *cx, JS::Handle<JSObject*> wrapper,
js::AutoIdVector &props);
virtual bool delete_(JSContext *cx, JS::Handle<JSObject *> wrapper,
virtual bool delete_(JSContext *cx, JS::Handle<JSObject*> wrapper,
JS::Handle<jsid> id, bool *bp);
virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
virtual bool enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper, js::AutoIdVector &props);
/* Derived proxy traps. */
virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
js::Value *vp);
virtual bool set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
bool strict, js::Value *vp);
virtual bool has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
virtual bool hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
virtual bool keys(JSContext *cx, JS::Handle<JSObject *> wrapper, js::AutoIdVector &props);
virtual bool iterate(JSContext *cx, JSObject *wrapper, unsigned flags, js::Value *vp);
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp);
virtual bool set(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id, bool strict, JS::MutableHandle<JS::Value> vp);
virtual bool has(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
bool *bp);
virtual bool hasOwn(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
bool *bp);
virtual bool keys(JSContext *cx, JS::Handle<JSObject*> wrapper,
js::AutoIdVector &props);
virtual bool iterate(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned flags,
JS::MutableHandle<JS::Value> vp);
virtual bool call(JSContext *cx, JSObject *wrapper, unsigned argc, js::Value *vp);
virtual bool construct(JSContext *cx, JSObject *wrapper,
unsigned argc, js::Value *argv, js::Value *rval);
virtual bool call(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned argc,
js::Value *vp);
virtual bool construct(JSContext *cx, JS::Handle<JSObject*> wrapper,
unsigned argc, js::Value *argv,
JS::MutableHandle<JS::Value> rval);
static XrayWrapper singleton;
private:
bool enumerate(JSContext *cx, JSObject *wrapper, unsigned flags,
bool enumerate(JSContext *cx, JS::Handle<JSObject*> wrapper, unsigned flags,
JS::AutoIdVector &props);
};
@ -114,24 +120,27 @@ public:
{
}
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> proxy, JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject *> proxy,
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::Handle<jsid> id, js::PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE;
// We just forward the derived traps to the BaseProxyHandler versions which
// implement them in terms of the fundamental traps.
virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, JS::Value *vp) MOZ_OVERRIDE;
virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver,
jsid id, bool strict, JS::Value *vp) MOZ_OVERRIDE;
virtual bool keys(JSContext *cx, JS::Handle<JSObject *> proxy,
virtual bool has(JSContext *cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
bool *bp) MOZ_OVERRIDE;
virtual bool hasOwn(JSContext *cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
bool *bp) MOZ_OVERRIDE;
virtual bool get(JSContext *cx, JS::Handle<JSObject*> proxy, JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool set(JSContext *cx, JS::Handle<JSObject*> proxy, JS::Handle<JSObject*> receiver,
JS::Handle<jsid> id, bool strict, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
virtual bool keys(JSContext *cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) MOZ_OVERRIDE;
virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags,
JS::Value *vp) MOZ_OVERRIDE;
virtual bool iterate(JSContext *cx, JS::Handle<JSObject*> proxy, unsigned flags,
JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
};
extern SandboxProxyHandler sandboxProxyHandler;
@ -145,7 +154,7 @@ public:
{
}
virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc,
virtual bool call(JSContext *cx, JS::Handle<JSObject*> proxy, unsigned argc,
JS::Value *vp);
};