зеркало из https://github.com/mozilla/gecko-dev.git
Bug 875473 - Add saveFrameChain option to shell evaluate function. r=luke
This commit is contained in:
Родитель
76d53fd572
Коммит
7b8666e7d3
|
@ -0,0 +1,16 @@
|
|||
// Error().stack (ScriptFrameIter) should not see through JS_SaveFrameChain.
|
||||
function h() {
|
||||
stack = Error().stack;
|
||||
}
|
||||
function g() {
|
||||
evaluate("h()", {saveFrameChain: true});
|
||||
}
|
||||
function f() {
|
||||
g();
|
||||
}
|
||||
f();
|
||||
var lines = stack.split("\n");
|
||||
assertEq(lines.length, 3);
|
||||
assertEq(lines[0].startsWith("h@"), true);
|
||||
assertEq(lines[1].startsWith("@@evaluate"), true);
|
||||
assertEq(lines[2], "");
|
|
@ -908,6 +908,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
|||
unsigned lineNumber = 1;
|
||||
RootedObject global(cx, NULL);
|
||||
bool catchTermination = false;
|
||||
bool saveFrameChain = false;
|
||||
RootedObject callerGlobal(cx, cx->global());
|
||||
|
||||
global = JS_GetGlobalForObject(cx, &args.callee());
|
||||
|
@ -999,6 +1000,15 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
|||
return false;
|
||||
catchTermination = b;
|
||||
}
|
||||
|
||||
if (!JS_GetProperty(cx, options, "saveFrameChain", v.address()))
|
||||
return false;
|
||||
if (!JSVAL_IS_VOID(v)) {
|
||||
JSBool b;
|
||||
if (!JS_ValueToBoolean(cx, v, &b))
|
||||
return false;
|
||||
saveFrameChain = b;
|
||||
}
|
||||
}
|
||||
|
||||
RootedString code(cx, args[0].toString());
|
||||
|
@ -1015,6 +1025,9 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
|||
cx = ancx.get();
|
||||
}
|
||||
|
||||
if (saveFrameChain && !JS_SaveFrameChain(cx))
|
||||
return false;
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, global);
|
||||
uint32_t saved = JS_GetOptions(cx);
|
||||
|
@ -1051,6 +1064,9 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
|
|||
}
|
||||
}
|
||||
|
||||
if (saveFrameChain)
|
||||
JS_RestoreFrameChain(cx);
|
||||
|
||||
return JS_WrapValue(cx, vp);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче