Skip to content

Commit 34fe4c3

Browse files
author
homyakov
committed
Captured Opera exceptions for tests
1 parent d17d9ae commit 34fe4c3

2 files changed

Lines changed: 133 additions & 6 deletions

File tree

‎stacktrace.js‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,20 @@ printStackTrace.implementation.prototype = {
207207
sourceCache: {},
208208

209209
/**
210-
* @return the text from a given URL.
210+
* @return the text from a given URL
211211
*/
212212
ajax: function(url) {
213213
var req = this.createXMLHTTPObject();
214-
if (!req) {
215-
return;
214+
if (req) {
215+
try {
216+
// FIXME why Firefox 3.6-7.0 raises error for file:///
217+
req.open('GET', url, false);
218+
req.send('');
219+
return req.responseText;
220+
} catch (e) {
221+
}
216222
}
217-
req.open('GET', url, false);
218-
req.send('');
219-
return req.responseText;
223+
return '';
220224
},
221225

222226
/**

‎test/CapturedExceptions.js‎

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
var CapturedExceptions = {};
2+
3+
CapturedExceptions.opera_964 = {
4+
message: "Statement on line 42: Type mismatch (usually non-object value supplied where object required)\n" +
5+
"Backtrace:\n" +
6+
" Line 42 of linked script file://localhost/G:/js/stacktrace.js\n" +
7+
" this.undef();\n" +
8+
" Line 27 of linked script file://localhost/G:/js/stacktrace.js\n" +
9+
" ex = ex || this.createException();\n" +
10+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js: In function printStackTrace\n" +
11+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
12+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
13+
" printTrace(printStackTrace());\n" +
14+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
15+
" bar(n - 1);\n" +
16+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n" +
17+
" bar(2);\n" +
18+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
19+
" foo();\n" +
20+
"",
21+
'opera#sourceloc': 42,
22+
stacktrace: " ... Line 27 of linked script file://localhost/G:/js/stacktrace.js\n" +
23+
" ex = ex || this.createException();\n" +
24+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js: In function printStackTrace\n" +
25+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
26+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
27+
" printTrace(printStackTrace());\n" +
28+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
29+
" bar(n - 1);\n" +
30+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n" +
31+
" bar(2);\n" +
32+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
33+
" foo();\n" +
34+
""
35+
};
36+
37+
CapturedExceptions.opera_1010 = {
38+
message: "Statement on line 42: Type mismatch (usually non-object value supplied where object required)",
39+
'opera#sourceloc': 42,
40+
stacktrace: " Line 42 of linked script file://localhost/G:/js/stacktrace.js\n" +
41+
" this.undef();\n" +
42+
" Line 27 of linked script file://localhost/G:/js/stacktrace.js\n" +
43+
" ex = ex || this.createException();\n" +
44+
" Line 18 of linked script file://localhost/G:/js/stacktrace.js: In function printStackTrace\n" +
45+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
46+
" Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
47+
" printTrace(printStackTrace());\n" +
48+
" Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function bar\n" +
49+
" bar(n - 1);\n" +
50+
" Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html: In function foo\n" +
51+
" bar(2);\n" +
52+
" Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html\n" +
53+
" foo();\n" +
54+
""
55+
};
56+
57+
CapturedExceptions.opera_1063 = {
58+
message: "'this.undef' is not a function",
59+
stack: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
60+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
61+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
62+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
63+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
64+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
65+
"@file://localhost/G:/js/test/functional/testcase1.html:15",
66+
stacktrace: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
67+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
68+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
69+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
70+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
71+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
72+
"@file://localhost/G:/js/test/functional/testcase1.html:15"
73+
};
74+
75+
CapturedExceptions.opera_1111 = {
76+
message: "'this.undef' is not a function",
77+
stack: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
78+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
79+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
80+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
81+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
82+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
83+
"@file://localhost/G:/js/test/functional/testcase1.html:15",
84+
stacktrace: "Error thrown at line 42, column 12 in <anonymous function: createException>() in file://localhost/G:/js/stacktrace.js:\n" +
85+
" this.undef();\n" +
86+
"called from line 27, column 8 in <anonymous function: run>(ex) in file://localhost/G:/js/stacktrace.js:\n" +
87+
" ex = ex || this.createException();\n" +
88+
"called from line 18, column 4 in printStackTrace(options) in file://localhost/G:/js/stacktrace.js:\n" +
89+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
90+
"called from line 4, column 5 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
91+
" printTrace(printStackTrace());\n" +
92+
"called from line 7, column 4 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
93+
" bar(n - 1);\n" +
94+
"called from line 11, column 4 in foo() in file://localhost/G:/js/test/functional/testcase1.html:\n" +
95+
" bar(2);\n" +
96+
"called from line 15, column 3 in file://localhost/G:/js/test/functional/testcase1.html:\n" +
97+
" foo();"
98+
};
99+
100+
CapturedExceptions.opera_1151 = {
101+
message: "'this.undef' is not a function",
102+
stack: "<anonymous function: createException>([arguments not available])@file://localhost/G:/js/stacktrace.js:42\n" +
103+
"<anonymous function: run>([arguments not available])@file://localhost/G:/js/stacktrace.js:27\n" +
104+
"printStackTrace([arguments not available])@file://localhost/G:/js/stacktrace.js:18\n" +
105+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:4\n" +
106+
"bar([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:7\n" +
107+
"foo([arguments not available])@file://localhost/G:/js/test/functional/testcase1.html:11\n" +
108+
"@file://localhost/G:/js/test/functional/testcase1.html:15",
109+
stacktrace: "Error thrown at line 42, column 12 in <anonymous function: createException>() in file://localhost/G:/js/stacktrace.js:\n" +
110+
" this.undef();\n" +
111+
"called from line 27, column 8 in <anonymous function: run>(ex) in file://localhost/G:/js/stacktrace.js:\n" +
112+
" ex = ex || this.createException();\n" +
113+
"called from line 18, column 4 in printStackTrace(options) in file://localhost/G:/js/stacktrace.js:\n" +
114+
" var p = new printStackTrace.implementation(), result = p.run(ex);\n" +
115+
"called from line 4, column 5 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
116+
" printTrace(printStackTrace());\n" +
117+
"called from line 7, column 4 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n" +
118+
" bar(n - 1);\n" +
119+
"called from line 11, column 4 in foo() in file://localhost/G:/js/test/functional/testcase1.html:\n" +
120+
" bar(2);\n" +
121+
"called from line 15, column 3 in file://localhost/G:/js/test/functional/testcase1.html:\n" +
122+
" foo();"
123+
};

0 commit comments

Comments
 (0)