3 <title>Test for
814497</title>
4 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 SimpleTest
.waitForExplicitFinish();
10 SimpleTest
.expectUncaughtException();
12 // /!\ Line number is important in this test,
13 // we are asserting the following functions line #
14 function failingStack() {
17 function nestedFunction() {
18 // eslint-disable-next-line no-undef
19 doesntExistsAndThrow();
23 QueryInterface
: ChromeUtils
.generateQI(["nsIObserver"]),
25 observe
: function test_observe(aSubject
)
27 if (!(aSubject
instanceof Ci
.nsIScriptError
)) {
30 dump("stack: "+aSubject
.stack
+"\n");
33 var s
= aSubject
.stack
;
34 ok(!!s
, "has first frame");
35 ok(s
.source
.includes("test_nsScriptErrorWithStack.html"), "source is correct");
36 is(s
.line
, 19, "line is correct");
37 is(s
.column
, 5, "column is correct");
38 is(s
.functionDisplayName
, "nestedFunction");
40 ok(!!s
, "has second frame");
41 ok(s
.source
.includes("test_nsScriptErrorWithStack.html"), "source is correct");
42 is(s
.line
, 15, "line is correct");
43 is(s
.column
, 5, "column is correct");
44 is(s
.functionDisplayName
, "failingStack");
45 // We shouldn't have any more frame as we used setTimeout
46 ok(!s
.parent
, "has no more frames");
49 Services
.console
.unregisterListener(TestObserver
);
54 Services
.console
.registerListener(TestObserver
);
56 // use setTimeout in order to prevent throwing from test frame
57 // and so have a clean stack frame with just our method calls
58 setTimeout(failingStack
, 0);