Bug 939696 - isProxy for export helpers. r=bholley

This commit is contained in:
Gabor Krizsanits 2013-11-26 14:54:17 +01:00
parent a0942c44d4
commit d7a76fa332

View File

@ -219,6 +219,27 @@ CreateXMLHttpRequest(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
static bool
IsProxy(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() < 1) {
JS_ReportError(cx, "Function requires at least 1 argument");
return false;
}
if (!args[0].isObject()) {
args.rval().setBoolean(false);
return true;
}
RootedObject obj(cx, &args[0].toObject());
obj = js::CheckedUnwrap(obj);
NS_ENSURE_TRUE(obj, false);
args.rval().setBoolean(js::IsScriptedProxy(obj));
return true;
}
namespace xpc {
bool
@ -1090,7 +1111,8 @@ xpc::CreateSandboxObject(JSContext *cx, MutableHandleValue vp, nsISupports *prin
if (options.wantExportHelpers &&
(!JS_DefineFunction(cx, sandbox, "exportFunction", ExportFunction, 3, 0) ||
!JS_DefineFunction(cx, sandbox, "evalInWindow", EvalInWindow, 2, 0) ||
!JS_DefineFunction(cx, sandbox, "createObjectIn", CreateObjectIn, 2, 0)))
!JS_DefineFunction(cx, sandbox, "createObjectIn", CreateObjectIn, 2, 0) ||
!JS_DefineFunction(cx, sandbox, "isProxy", IsProxy, 1, 0)))
return NS_ERROR_XPC_UNEXPECTED;
if (!options.globalProperties.Define(cx, sandbox))