services/common/tests/unit/test_utils_stackTrace.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial