michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: _("Define some functions in well defined line positions for the test"); michael@0: function foo(v) bar(v + 1); // line 2 michael@0: function bar(v) baz(v + 1); // line 3 michael@0: function baz(v) { throw new Error(v + 1); } // line 4 michael@0: michael@0: _("Make sure lazy constructor calling/assignment works"); michael@0: Cu.import("resource://services-common/utils.js"); michael@0: michael@0: function run_test() { michael@0: _("Make sure functions, arguments, files are pretty printed in the trace"); michael@0: let trace = ""; michael@0: try { michael@0: foo(0); michael@0: } michael@0: catch(ex) { michael@0: trace = CommonUtils.stackTrace(ex); michael@0: } michael@0: _("Got trace:", trace); michael@0: do_check_neq(trace, ""); michael@0: michael@0: let bazPos = trace.indexOf("baz@test_utils_stackTrace.js:7"); michael@0: let barPos = trace.indexOf("bar@test_utils_stackTrace.js:6"); michael@0: let fooPos = trace.indexOf("foo@test_utils_stackTrace.js:5"); michael@0: _("String positions:", bazPos, barPos, fooPos); michael@0: michael@0: _("Make sure the desired messages show up"); michael@0: do_check_true(bazPos >= 0); michael@0: do_check_true(barPos > bazPos); michael@0: do_check_true(fooPos > barPos); michael@0: }