|
|
|
Lines 2955-2973
ProxyObject::renew(JSContext *cx, BasePr
|
Link Here
|
|---|
|
| 2955 |
|
2955 |
|
| 2956 |
setSlot(HANDLER_SLOT, PrivateValue(handler)); |
2956 |
setSlot(HANDLER_SLOT, PrivateValue(handler)); |
| 2957 |
setCrossCompartmentSlot(PRIVATE_SLOT, priv); |
2957 |
setCrossCompartmentSlot(PRIVATE_SLOT, priv); |
| 2958 |
setSlot(EXTRA_SLOT + 0, UndefinedValue()); |
2958 |
setSlot(EXTRA_SLOT + 0, UndefinedValue()); |
| 2959 |
setSlot(EXTRA_SLOT + 1, UndefinedValue()); |
2959 |
setSlot(EXTRA_SLOT + 1, UndefinedValue()); |
| 2960 |
} |
2960 |
} |
| 2961 |
|
2961 |
|
| 2962 |
static bool |
2962 |
static bool |
| 2963 |
proxy(JSContext *cx, unsigned argc, jsval *vp) |
2963 |
NewScriptedProxy(JSContext *cx, CallArgs &args) |
| 2964 |
{ |
2964 |
{ |
| 2965 |
CallArgs args = CallArgsFromVp(argc, vp); |
|
|
| 2966 |
if (args.length() < 2) { |
2965 |
if (args.length() < 2) { |
| 2967 |
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, |
2966 |
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, |
| 2968 |
"Proxy", "1", "s"); |
2967 |
"Proxy", "1", "s"); |
| 2969 |
return false; |
2968 |
return false; |
| 2970 |
} |
2969 |
} |
| 2971 |
RootedObject target(cx, NonNullObject(cx, args[0])); |
2970 |
RootedObject target(cx, NonNullObject(cx, args[0])); |
| 2972 |
if (!target) |
2971 |
if (!target) |
| 2973 |
return false; |
2972 |
return false; |
|
Lines 2984-2999
proxy(JSContext *cx, unsigned argc, jsva
|
Link Here
|
|---|
|
| 2984 |
if (!proxy) |
2983 |
if (!proxy) |
| 2985 |
return false; |
2984 |
return false; |
| 2986 |
proxy->setExtra(ScriptedDirectProxyHandler::HANDLER_EXTRA, ObjectValue(*handler)); |
2985 |
proxy->setExtra(ScriptedDirectProxyHandler::HANDLER_EXTRA, ObjectValue(*handler)); |
| 2987 |
args.rval().setObject(*proxy); |
2986 |
args.rval().setObject(*proxy); |
| 2988 |
return true; |
2987 |
return true; |
| 2989 |
} |
2988 |
} |
| 2990 |
|
2989 |
|
| 2991 |
static bool |
2990 |
static bool |
|
|
2991 |
proxy(JSContext *cx, unsigned argc, jsval *vp) |
| 2992 |
{ |
| 2993 |
CallArgs args = CallArgsFromVp(argc, vp); |
| 2994 |
|
| 2995 |
if (!args.isConstructing()) { |
| 2996 |
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, "Proxy"); |
| 2997 |
return false; |
| 2998 |
} |
| 2999 |
|
| 3000 |
return NewScriptedProxy(cx, args); |
| 3001 |
} |
| 3002 |
|
| 3003 |
static bool |
| 2992 |
RevokeProxy(JSContext *cx, unsigned argc, Value *vp) |
3004 |
RevokeProxy(JSContext *cx, unsigned argc, Value *vp) |
| 2993 |
{ |
3005 |
{ |
| 2994 |
CallReceiver rec = CallReceiverFromVp(vp); |
3006 |
CallReceiver rec = CallReceiverFromVp(vp); |
| 2995 |
|
3007 |
|
| 2996 |
RootedFunction func(cx, &rec.callee().as<JSFunction>()); |
3008 |
RootedFunction func(cx, &rec.callee().as<JSFunction>()); |
| 2997 |
RootedObject p(cx, func->getExtendedSlot(ScriptedDirectProxyHandler::REVOKE_SLOT).toObjectOrNull()); |
3009 |
RootedObject p(cx, func->getExtendedSlot(ScriptedDirectProxyHandler::REVOKE_SLOT).toObjectOrNull()); |
| 2998 |
|
3010 |
|
| 2999 |
if (p) { |
3011 |
if (p) { |
|
Lines 3007-3025
RevokeProxy(JSContext *cx, unsigned argc
|
Link Here
|
|---|
|
| 3007 |
|
3019 |
|
| 3008 |
rec.rval().setUndefined(); |
3020 |
rec.rval().setUndefined(); |
| 3009 |
return true; |
3021 |
return true; |
| 3010 |
} |
3022 |
} |
| 3011 |
|
3023 |
|
| 3012 |
static bool |
3024 |
static bool |
| 3013 |
proxy_revocable(JSContext *cx, unsigned argc, Value *vp) |
3025 |
proxy_revocable(JSContext *cx, unsigned argc, Value *vp) |
| 3014 |
{ |
3026 |
{ |
| 3015 |
CallReceiver args = CallReceiverFromVp(vp); |
3027 |
CallArgs args = CallArgsFromVp(argc, vp); |
| 3016 |
|
3028 |
|
| 3017 |
if (!proxy(cx, argc, vp)) |
3029 |
if (!NewScriptedProxy(cx, args)) |
| 3018 |
return false; |
3030 |
return false; |
| 3019 |
|
3031 |
|
| 3020 |
RootedValue proxyVal(cx, args.rval()); |
3032 |
RootedValue proxyVal(cx, args.rval()); |
| 3021 |
MOZ_ASSERT(proxyVal.toObject().is<ProxyObject>()); |
3033 |
MOZ_ASSERT(proxyVal.toObject().is<ProxyObject>()); |
| 3022 |
|
3034 |
|
| 3023 |
RootedObject revoker(cx, NewFunctionWithReserved(cx, RevokeProxy, 0, 0, cx->global(), |
3035 |
RootedObject revoker(cx, NewFunctionWithReserved(cx, RevokeProxy, 0, 0, cx->global(), |
| 3024 |
"RevokeProxy")); |
3036 |
"RevokeProxy")); |
| 3025 |
if (!revoker) { |
3037 |
if (!revoker) { |