4 https://bugzilla.mozilla.org/show_bug.cgi?id=390488
7 <title>Test for Bug
390488</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=390488">Mozilla Bug
390488</a>
14 <div id=
"testdiv" onclick=
"checkForStacks();" style=
"visibility:hidden">
17 <div id=
"content" style=
"display: none">
21 <script class=
"testbody" type=
"text/javascript">
23 /** Test for Bug
390488 **/
24 function getStack1() {
25 var func = arguments.callee.caller;
27 for (var i =
1; func && i <
8; i++) {
28 stack +=
" " + i +
". " + func.name;
34 function getStack2() {
35 var stack = new Error().stack;
36 // Remove the two lines due to calling this
37 return stack.substring(stack.indexOf(
"\n", stack.indexOf(
"\n")+
1)+
1);
40 function simulateClick() {
41 var evt = document.createEvent(
"MouseEvents");
42 evt.initMouseEvent(
"click", true, true, window,
43 0,
0,
0,
0,
0, false, false, false, false,
0, null);
44 $(
"testdiv").dispatchEvent(evt);
47 function matches(s, p, name) {
48 ok(s.match(p) != null,
49 name +
" - got " + s +
", expected a string matching " + p);
52 function checkForStacks() {
53 matches(getStack1(), /checkForStacks .* onclick .* simulateClick/,
54 "Stack from walking caller chain should be correct");
55 isnot(getStack2().indexOf(
"simulateClick@"), -
1,
56 "Stack from |new Error().stack| should include simulateClick");