diff --git a/services/common/tests/unit/test_utils_stackTrace.js b/services/common/tests/unit/test_utils_stackTrace.js deleted file mode 100644 index 6c71d07535d2..000000000000 --- a/services/common/tests/unit/test_utils_stackTrace.js +++ /dev/null @@ -1,33 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -_("Define some functions in well defined line positions for the test"); -function foo(v) { return bar(v + 1); } // line 2 -function bar(v) { return baz(v + 1); } // line 3 -function baz(v) { throw new Error(v + 1); } // line 4 - -_("Make sure lazy constructor calling/assignment works"); -Cu.import("resource://services-common/utils.js"); - -function run_test() { - _("Make sure functions, arguments, files are pretty printed in the trace"); - let trace = ""; - try { - foo(0); - } - catch(ex) { - trace = CommonUtils.stackTrace(ex); - } - _("Got trace:", trace); - do_check_neq(trace, ""); - - let bazPos = trace.indexOf("baz@test_utils_stackTrace.js:7"); - let barPos = trace.indexOf("bar@test_utils_stackTrace.js:6"); - let fooPos = trace.indexOf("foo@test_utils_stackTrace.js:5"); - _("String positions:", bazPos, barPos, fooPos); - - _("Make sure the desired messages show up"); - do_check_true(bazPos >= 0); - do_check_true(barPos > bazPos); - do_check_true(fooPos > barPos); -} diff --git a/services/common/tests/unit/xpcshell.ini b/services/common/tests/unit/xpcshell.ini index c817e7dd6637..2cdbe79be36c 100644 --- a/services/common/tests/unit/xpcshell.ini +++ b/services/common/tests/unit/xpcshell.ini @@ -23,7 +23,6 @@ support-files = [test_utils_makeURI.js] [test_utils_namedTimer.js] [test_utils_sets.js] -[test_utils_stackTrace.js] [test_utils_utf8.js] [test_utils_uuid.js] diff --git a/services/common/utils.js b/services/common/utils.js index 68418c5f8c4e..f0f57d14afb6 100644 --- a/services/common/utils.js +++ b/services/common/utils.js @@ -69,9 +69,6 @@ this.CommonUtils = { return true; }, - // Import these from Log.jsm for backward compatibility - stackTrace: Log.stackTrace, - /** * Encode byte string as base64URL (RFC 4648). * diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index 5c16e45efa8b..f2604bab62fc 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -35,7 +35,6 @@ this.Utils = { // In the ideal world, references to these would be removed. nextTick: CommonUtils.nextTick, namedTimer: CommonUtils.namedTimer, - stackTrace: CommonUtils.stackTrace, makeURI: CommonUtils.makeURI, encodeUTF8: CommonUtils.encodeUTF8, decodeUTF8: CommonUtils.decodeUTF8, diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index 4644c51ccbe1..02b304b675b4 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -142,7 +142,7 @@ var TPS = { errInfo = Log.exceptionStr(exc); // includes details and stack-trace. } else { // always write a stack even if no error passed. - errInfo = Utils.stackTrace(new Error()); + errInfo = Log.stackTrace(new Error()); } Logger.logError(`[phase ${this._currentPhase}] ${msg} - ${errInfo}`); this.quit(); diff --git a/toolkit/modules/tests/xpcshell/test_Log_stackTrace.js b/toolkit/modules/tests/xpcshell/test_Log_stackTrace.js new file mode 100644 index 000000000000..f6aac6decd23 --- /dev/null +++ b/toolkit/modules/tests/xpcshell/test_Log_stackTrace.js @@ -0,0 +1,30 @@ +print("Define some functions in well defined line positions for the test"); +function foo(v) { return bar(v + 1); } // line 2 +function bar(v) { return baz(v + 1); } // line 3 +function baz(v) { throw new Error(v + 1); } // line 4 + +print("Make sure lazy constructor calling/assignment works"); +Components.utils.import("resource://gre/modules/Log.jsm"); + +function run_test() { + print("Make sure functions, arguments, files are pretty printed in the trace"); + let trace = ""; + try { + foo(0); + } + catch(ex) { + trace = Log.stackTrace(ex); + } + print(`Got trace: ${trace}`); + do_check_neq(trace, ""); + + let bazPos = trace.indexOf("baz@test_Log_stackTrace.js:4"); + let barPos = trace.indexOf("bar@test_Log_stackTrace.js:3"); + let fooPos = trace.indexOf("foo@test_Log_stackTrace.js:2"); + print(`String positions: ${bazPos} ${barPos} ${fooPos}`); + + print("Make sure the desired messages show up"); + do_check_true(bazPos >= 0); + do_check_true(barPos > bazPos); + do_check_true(fooPos > barPos); +} diff --git a/toolkit/modules/tests/xpcshell/xpcshell.ini b/toolkit/modules/tests/xpcshell/xpcshell.ini index f4bf5d872ce3..66832dbbbeb5 100644 --- a/toolkit/modules/tests/xpcshell/xpcshell.ini +++ b/toolkit/modules/tests/xpcshell/xpcshell.ini @@ -61,3 +61,4 @@ skip-if = toolkit == 'android' [test_web_channel_broker.js] [test_ZipUtils.js] skip-if = toolkit == 'android' +[test_Log_stackTrace.js]