Bug 1109608 - Log.stackTrace should use human-readable task stack traces if available. r=Yoric

This commit is contained in:
Ravi Shankar 2015-03-11 03:21:00 -04:00
Родитель 6640ced2a6
Коммит fc99a1c828
2 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -194,8 +194,8 @@ this.Log = {
}
// Standard JS exception
if (e.stack) {
return "JS Stack trace: " + e.stack.trim().replace(/\n/g, " < ").
replace(/@[^@]*?([^\/\.]+\.\w+:)/g, "@$1");
return "JS Stack trace: " + Task.Debugging.generateReadableStack(e.stack).trim()
.replace(/\n/g, " < ").replace(/@[^@]*?([^\/\.]+\.\w+:)/g, "@$1");
}
return "No traceback available";

Просмотреть файл

@ -6,6 +6,7 @@ const {utils: Cu} = Components;
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Promise.jsm")
Cu.import("resource://gre/modules/Log.jsm");
let testFormatter = {
@ -573,6 +574,7 @@ add_task(function format_errors() {
// Test that JS-generated Errors are recognized and formatted.
try {
yield Promise.resolve(); // Scrambles the stack
eval("javascript syntax error");
}
catch (e) {
@ -581,5 +583,10 @@ add_task(function format_errors() {
// Make sure we identified it as an Error and formatted the error location as
// lineNumber:columnNumber.
do_check_true(str.contains(":1:11)"));
// Make sure that we use human-readable stack traces
// Check that the error doesn't contain any reference to "Promise.jsm" or "Task.jsm"
do_check_false(str.contains("Promise.jsm"));
do_check_false(str.contains("Task.jsm"));
do_check_true(str.contains("format_errors"));
}
});