Bug 1234734 - Replace CommonUtils.stackTrace() with Log.stackTrace(). r=markh

--HG--
rename : services/common/tests/unit/test_utils_stackTrace.js => toolkit/modules/tests/xpcshell/test_Log_stackTrace.js
This commit is contained in:
Anup Kumar 2016-01-07 20:44:00 -05:00
Родитель ff3269f2d2
Коммит 64a1cfc0a0
7 изменённых файлов: 32 добавлений и 39 удалений

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

@ -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);
}

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

@ -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]

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

@ -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).
*

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

@ -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,

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

@ -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();

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

@ -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);
}

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

@ -61,3 +61,4 @@ skip-if = toolkit == 'android'
[test_web_channel_broker.js]
[test_ZipUtils.js]
skip-if = toolkit == 'android'
[test_Log_stackTrace.js]