Skip to content

Commit 8536aaa

Browse files
author
homyakov
committed
Test files for issue stacktracejs#27
1 parent cce8165 commit 8536aaa

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

‎test/issues/27-1.html‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<html>
2+
<head>
3+
<title>Issue #27</title>
4+
<script src="../../stacktrace.js"></script>
5+
<script>
6+
window.onerror = function(errorMsg, url, lineNumber) {
7+
alert(errorMsg + "\nURL: " + url + "\nLine number: " + lineNumber);
8+
// Previous line gets executed
9+
var trace;
10+
try {
11+
// Firefox enters printStackTrace. Leaves silently somewhere in there
12+
trace = printStackTrace().join('\n\n');
13+
// Execution does not arrive here (as evidenced in debugger)
14+
} catch (e) {
15+
// nothing gets thrown/caught in Firefox
16+
// error console empty (the original uncaught exception is logged)
17+
}
18+
// Execution does not arrive here
19+
// (as evidenced in debugger and actual browser window)
20+
alert(trace);
21+
return true;
22+
};
23+
24+
// Somewhere error gets thrown
25+
throw 'An error occurred';
26+
</script>
27+
</head>
28+
<body></body>
29+
</html>

‎test/issues/27-2.html‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
<head>
3+
<title>Issue #27</title>
4+
<script src="../../stacktrace.js"></script>
5+
<script>
6+
/*function printStackTraceOnError(msg, file, line) {
7+
alert(printStackTrace().join('\n\n'));
8+
}
9+
if (window.addEventListener) {
10+
window.addEventListener('error', printStackTraceOnError, false);
11+
} else if (window.attachEvent) {
12+
window.attachEvent('onerror', printStackTraceOnError);
13+
} else {
14+
window.onerror = printStackTraceOnError;
15+
}*/
16+
window.onerror = function(msg, file, line) {
17+
alert(printStackTrace().join('\n\n'));
18+
};
19+
20+
function test() {
21+
x += 1;
22+
}
23+
</script>
24+
</head>
25+
<body onload="test();"></body>
26+
</html>

0 commit comments

Comments
 (0)