From 5715d042632eb45c53dd8e7c25f6289b73f355ab Mon Sep 17 00:00:00 2001 From: Michael Yoshitaka Erlewine Date: Mon, 19 Jul 2010 14:21:09 -0400 Subject: [PATCH] rm stacktrace.js! --HG-- extra : rebase_source : ee145386d3b3836f0c02005c1f4f7ef517377b7e --- .../base/content/tabview/modules/utils.jsm | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/browser/base/content/tabview/modules/utils.jsm b/browser/base/content/tabview/modules/utils.jsm index 5f552bb9b54..373555825dc 100644 --- a/browser/base/content/tabview/modules/utils.jsm +++ b/browser/base/content/tabview/modules/utils.jsm @@ -570,19 +570,22 @@ var Utils = { // Pass as many arguments as you want, it'll print them all. trace: function() { var text = this.expandArgumentsForLog(arguments); - if (typeof(printStackTrace) != 'function') - this.log(text + ' trace: you need to include stacktrace.js'); - else { - var calls = printStackTrace(); - calls.splice(0, 3); // Remove this call and the printStackTrace calls - this.log('trace: ' + text + '\n' + calls.join('\n')); + try { // coerce an error + throw new Error("error"); + } catch (e) { + // cut off the first two lines of the stack trace, because they're just this function. + var stack = e.stack.replace(/^.*?\n.*?\n/,''); + // if the caller was assert, cut out the line for the assert function as well. + if (this.trace.caller.name == 'Utils_assert') + stack = stack.replace(/^.*?\n/,''); + this.log('trace: ' + text + '\n' + stack); } }, // ---------- // Function: assert // Prints a stack trace along with label (as a console message) if condition is false. - assert: function(label, condition) { + assert: function Utils_assert(label, condition) { if (!condition) { var text; if (typeof(label) == 'undefined') @@ -590,11 +593,6 @@ var Utils = { else text = 'tabcandy assert: ' + label; - if (typeof(printStackTrace) == 'function') { - var calls = printStackTrace(); - text += '\n' + calls[3]; - } - this.trace(text); } }, @@ -610,10 +608,11 @@ var Utils = { else text = 'tabcandy assert: ' + label; - if (typeof(printStackTrace) == 'function') { - var calls = printStackTrace(); - calls.splice(0, 3); // Remove this call and the printStackTrace calls - text += '\n' + calls.join('\n'); + try { // coerce an error + throw new Error("error"); + } catch (e) { + // cut off the first two lines of the stack trace, because they're just this function. + text += e.stack.replace(/^.*?\n.*?\n/,''); } throw text;