Bug 780288 - Fix bugs in js shell Help native (r=billm)

--HG--
extra : rebase_source : 7f9acb83ff14186933b3eaa19e7b577d1d510bc7
This commit is contained in:
Luke Wagner 2012-08-09 16:09:46 -07:00
parent 3b66089d27
commit 074c7ae3d5
3 changed files with 51 additions and 3 deletions

View File

@ -0,0 +1,20 @@
s = newGlobal()
try {
evalcx("\
Object.defineProperty(this,\"i\",{enumerable:true,get:function(){t}});\
for each(y in this)true\
", s)
} catch (e) {}
try {
evalcx("\
for(z=0,(7).watch(\"\",eval);;g){\
if(z=1){({t:function(){}})\
}\
", s)
} catch (e) {}
try {
evalcx("\
Object.defineProperty(this,\"g2\",{get:function(){return this}});\
g2.y()\
", s)
} catch (e) {}

View File

@ -0,0 +1,20 @@
s = newGlobal()
try {
evalcx("\
Object.defineProperty(this,\"i\",{enumerable:true,get:function(){t}});\
for each(y in this)true\
", s)
} catch (e) {}
try {
evalcx("\
for(z=0,(7).watch(\"\",eval);;g){\
if(z=1){({t:function(){}})\
}\
", s)
} catch (e) {}
try {
evalcx("\
Object.defineProperty(this,\"g2\",{get:function(){return this}});\
g2.y(\"\")\
", s)
} catch (e) {}

View File

@ -3880,7 +3880,7 @@ Help(JSContext *cx, unsigned argc, jsval *vp)
RootedObject obj(cx);
if (argc == 0) {
RootedObject global(cx, JS_GetGlobalObject(cx));
RootedObject global(cx, JS_GetGlobalForScopeChain(cx));
AutoIdArray ida(cx, JS_Enumerate(cx, global));
if (!ida)
return false;
@ -3889,15 +3889,23 @@ Help(JSContext *cx, unsigned argc, jsval *vp)
jsval v;
if (!JS_LookupPropertyById(cx, global, ida[i], &v))
return false;
if (JSVAL_IS_PRIMITIVE(v)) {
JS_ReportError(cx, "primitive arg");
return false;
}
obj = JSVAL_TO_OBJECT(v);
if (!JSVAL_IS_PRIMITIVE(v) && !PrintHelp(cx, obj))
if (!PrintHelp(cx, obj))
return false;
}
} else {
jsval *argv = JS_ARGV(cx, vp);
for (unsigned i = 0; i < argc; i++) {
if (JSVAL_IS_PRIMITIVE(argv[i])) {
JS_ReportError(cx, "primitive arg");
return false;
}
obj = JSVAL_TO_OBJECT(argv[i]);
if (!JSVAL_IS_PRIMITIVE(argv[i]) && !PrintHelp(cx, obj))
if (!PrintHelp(cx, obj))
return false;
}
}