зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset d53726702252 (bug 996060)
This commit is contained in:
Родитель
04ea41e959
Коммит
14189e51f1
|
@ -3495,40 +3495,6 @@ GetModuleEnvironmentValue(JSContext* cx, unsigned argc, Value* vp)
|
|||
return GetProperty(cx, env, env, id, args.rval());
|
||||
}
|
||||
|
||||
static bool
|
||||
CatchAndReturnPendingExceptionStack(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() != 1) {
|
||||
JS_ReportError(cx, "Wrong number of arguments, expected exactly 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!args[0].isObject() || !IsCallable(args[0])) {
|
||||
JS_ReportError(cx, "Argument must be callable");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue thisv(cx, NullValue());
|
||||
RootedObject fun(cx, &args[0].toObject());
|
||||
RootedValue rval(cx);
|
||||
if (JS::Call(cx, UndefinedHandleValue, fun, JS::HandleValueArray::empty(), &rval) ||
|
||||
!cx->isExceptionPending())
|
||||
{
|
||||
JS_ReportError(cx, "Supplied callable did not throw");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject stack(cx);
|
||||
if (!JS::GetPendingExceptionStack(cx, &stack))
|
||||
return false;
|
||||
cx->clearPendingException();
|
||||
|
||||
MOZ_ASSERT_IF(stack, stack->is<SavedFrame>());
|
||||
args.rval().setObjectOrNull(stack);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const JSFunctionSpecWithHelp TestingFunctions[] = {
|
||||
JS_FN_HELP("gc", ::GC, 0, 0,
|
||||
"gc([obj] | 'compartment' [, 'shrinking'])",
|
||||
|
@ -4046,11 +4012,6 @@ gc::ZealModeHelpText),
|
|||
"getModuleEnvironmentValue(module, name)",
|
||||
" Get the value of a bound name in a module environment.\n"),
|
||||
|
||||
JS_FN_HELP("catchAndReturnPendingExceptionStack", CatchAndReturnPendingExceptionStack, 1, 0,
|
||||
"catchAndReturnPendingExceptionStack(func)",
|
||||
" Call `func`, catch its thrown exception, and return the stack captured when\n"
|
||||
" the exception was thrown.\n"),
|
||||
|
||||
JS_FS_HELP_END
|
||||
};
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
let err;
|
||||
const stack = catchAndReturnPendingExceptionStack(function a() {
|
||||
err = new Error();
|
||||
(function b() {
|
||||
(function c() {
|
||||
throw err;
|
||||
}());
|
||||
}());
|
||||
});
|
||||
|
||||
assertEq(!!err, true);
|
||||
|
||||
// Yes, they're different!
|
||||
assertEq(stack.toString() != err.stack, true);
|
||||
|
||||
assertEq(stack.functionDisplayName, "c");
|
||||
assertEq(stack.parent.functionDisplayName, "b");
|
||||
assertEq(stack.parent.parent.functionDisplayName, "a");
|
||||
assertEq(stack.parent.parent.parent.functionDisplayName, null);
|
||||
assertEq(stack.parent.parent.parent.parent, null);
|
|
@ -1,13 +0,0 @@
|
|||
const stack = catchAndReturnPendingExceptionStack(function a() {
|
||||
(function b() {
|
||||
(function c() {
|
||||
throw 42;
|
||||
}());
|
||||
}());
|
||||
});
|
||||
|
||||
assertEq(stack.functionDisplayName, "c");
|
||||
assertEq(stack.parent.functionDisplayName, "b");
|
||||
assertEq(stack.parent.parent.functionDisplayName, "a");
|
||||
assertEq(stack.parent.parent.parent.functionDisplayName, null);
|
||||
assertEq(stack.parent.parent.parent.parent, null);
|
Загрузка…
Ссылка в новой задаче