-
Notifications
You must be signed in to change notification settings - Fork 277
Expand file tree
/
Copy pathExceptionLab.html
More file actions
121 lines (110 loc) · 3.65 KB
/
Copy pathExceptionLab.html
File metadata and controls
121 lines (110 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Exception Lab</title>
<style>
#info {
height: 25em;
width: 100%;
}
</style>
<script src="../../stacktrace.js"></script>
<script src="ExceptionLab.js"></script>
<script>
var lastException;
function info(text) {
document.getElementById("info").innerHTML = text;
}
function detectMode() {
var p = new printStackTrace.implementation(), mode = p.mode(lastException);
info('Stack tracing mode: ' + mode);
}
function dumpStacktrace(guess) {
var trace = printStackTrace({
e: lastException,
guess: guess
});
info(trace.join("\n\n"));
}
function dumpException(ex) {
var text = "{\n " + ExceptionLab.getExceptionProps(ex).join(",\n ") + "\n}";
info(text);
lastException = ex;
}
function dumpExceptionError() {
dumpException(new Error("Default error"));
}
function dumpExceptionAnonymous() {
dumpException((function(x) {
try {
x.undef();
return null;
} catch (ex) {
return ex;
}
})(null));
}
function dumpExceptionInEval() {
try {
//eval("x.undef()");
eval("getExceptionProps()");
} catch (ex) {
dumpException(ex);
}
}
function dumpExceptionMultiLine() {
var fn = function() {
return {
name: "provide multi-line message in exception"
};
};
try {
fn.nonExistentMethod();
} catch (ex) {
dumpException(ex);
}
}
function dumpDOMException() {
try {
document.body.removeChild(document.createElement('div'));
} catch (ex) {
dumpException(ex);
}
}
function dumpCallChain() {
dumpException({message: 'Error'});
try {
dumpStacktrace();
} catch (ex) {
info('Exception while processing stack trace:\n' + ex);
}
}
function dumpCallChainInStrictMode() {
"use strict";
dumpCallChain();
}
</script>
</head>
<body>
<span id="userAgent">userAgent</span>
<script>
document.getElementById("userAgent").innerHTML = navigator.userAgent;
</script>
<textarea id="info" placeholder="Data extracted from Error object"></textarea>
<br />
<button onclick="dumpExceptionError();" title="new Error()">Exception 1</button>
<button onclick="dumpExceptionAnonymous();" title="Stack with anonymous function">Exception 2</button>
<button onclick="dumpExceptionInEval();" title="Exception in eval()">Exception 3</button>
<button onclick="dumpExceptionMultiLine();" title="Multi-line message in exception">Exception 4</button>
<button onclick="dumpDOMException();" title="DOM exception (without stack in Firefox)">Exception 5</button>
<br />
<button onclick="dumpCallChain();" title="Process call chain">Call chain</button>
<button onclick="dumpCallChainInStrictMode();" title="Process call chain in strict mode">Call chain in strict mode
</button>
<br />
<button onclick="detectMode();">Detect mode</button>
<button onclick="dumpStacktrace();">Process stack trace</button>
<button onclick="dumpStacktrace(true);">Guess anonymous functions</button>
</body>
</html>