Bug 741041 - Implement isProxy testing command for JS shell

--HG--
extra : rebase_source : 0beb5a22050916b5100d03314c257a48b19378ae
This commit is contained in:
Steve Fink 2012-03-28 14:43:02 -07:00
parent 85f10272fb
commit 5c44072f7d

View File

@ -10,6 +10,7 @@
#include "jsfriendapi.h"
#include "jsgc.h"
#include "jsobj.h"
#include "jsobjinlines.h"
#include "jsprf.h"
#include "jswrapper.h"
@ -142,6 +143,22 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
static JSBool
IsProxy(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (argc != 1) {
JS_ReportError(cx, "the function takes exactly one argument");
return false;
}
if (!args[0].isObject()) {
args.rval().setBoolean(false);
return true;
}
args.rval().setBoolean(args[0].toObject().isProxy());
return true;
}
static JSBool
InternalConst(JSContext *cx, unsigned argc, jsval *vp)
{
@ -583,6 +600,10 @@ static JSFunctionSpecWithHelp TestingFunctions[] = {
" Query an internal constant for the engine. See InternalConst source for\n"
" the list of constant names."),
JS_FN_HELP("isProxy", IsProxy, 1, 0,
"isProxy(obj)",
" If true, obj is a proxy of some sort"),
JS_FN_HELP("mjitChunkLimit", MJitChunkLimit, 1, 0,
"mjitChunkLimit(N)",
" Specify limit on compiled chunk size during mjit compilation."),