Skip to content

Commit 7f2f70b

Browse files
author
homyakov
committed
Fixed Opera mode detection with empty message
1 parent fbc6cfb commit 7f2f70b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎stacktrace.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ printStackTrace.implementation.prototype = {
5757
mode: function(e) {
5858
if (e['arguments'] && e.stack) {
5959
return 'chrome';
60-
} else if (e.message && typeof window !== 'undefined' && window.opera) {
60+
} else if (typeof e.message === 'string' && typeof window !== 'undefined' && window.opera) {
6161
// e.message.indexOf("Backtrace:") > -1 -> opera
6262
// !e.stacktrace -> opera
6363
if (!e.stacktrace) {
@@ -139,6 +139,7 @@ printStackTrace.implementation.prototype = {
139139
},
140140

141141
opera11: function(e) {
142+
// "Error thrown at line 42, column 12 in <anonymous function>() in file://localhost/G:/js/stacktrace.js:\n"
142143
// "Error thrown at line 42, column 12 in <anonymous function: createException>() in file://localhost/G:/js/stacktrace.js:\n"
143144
// "called from line 7, column 4 in bar(n) in file://localhost/G:/js/test/functional/testcase1.html:\n"
144145
// "called from line 15, column 3 in file://localhost/G:/js/test/functional/testcase1.html:\n"
@@ -150,7 +151,7 @@ printStackTrace.implementation.prototype = {
150151
if (match) {
151152
var location = match[4] + ':' + match[1] + ':' + match[2];
152153
var fnName = match[3] || "global code";
153-
fnName = fnName.replace(/<anonymous function: (\S+)>/g, "$1");
154+
fnName = fnName.replace(/<anonymous function: (\S+)>/, "$1").replace(/<anonymous function>/, ANON);
154155
result.push(fnName + '@' + location + ' -- ' + lines[i + 1].replace(/^\s+/, ''));
155156
}
156157
}

‎test/TestStacktrace.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
if (UnitTest.prototype.genericError != null) {
3030
return UnitTest.prototype.genericError;
3131
}
32+
//return new Error("Generic error");
3233
return new Error();
3334
},
3435
prepareFakeOperaEnvironment: function() {
@@ -496,7 +497,7 @@
496497
expect(3 * e.length);
497498
for (var i = 0; i < e.length; i++) {
498499
var stack = pst.opera11(e[i]), stack_string = stack.join('\n');
499-
equals(stack_string, '', 'debug');
500+
equals(stack_string, 'debug', 'debug');
500501
equals(stack_string.indexOf('ignored'), -1, 'ignored');
501502
equals(stack[5].indexOf('f1(') >= 0, true, 'f1 function name: ' + stack[5]);
502503
equals(stack[6].indexOf('{anonymous}()') >= 0, true, 'f2 is anonymous: ' + stack[6]);

0 commit comments

Comments
 (0)