Skip to content

Commit b6a6e48

Browse files
authored
test: Fix mechanism tests on IE10/11 (#1368)
1 parent b95bee2 commit b6a6e48

File tree

1 file changed

+41
-7
lines changed
  • packages/raven-js/test/integration

1 file changed

+41
-7
lines changed

packages/raven-js/test/integration/test.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ function isEdge14() {
4343
return window.navigator.userAgent.indexOf('Edge/14') !== -1;
4444
}
4545

46+
// Thanks for nothing IE!
47+
// (╯°□°)╯︵ ┻━┻
48+
function canReadFunctionName() {
49+
function foo() {}
50+
if (foo.name === 'foo') return true;
51+
return false;
52+
}
53+
4654
describe('integration', function() {
4755
this.timeout(30000);
4856

@@ -619,10 +627,19 @@ describe('integration', function() {
619627
},
620628
function() {
621629
var ravenData = iframe.contentWindow.ravenData[0];
630+
631+
var fn = ravenData.exception.mechanism.data.function;
632+
delete ravenData.exception.mechanism.data;
633+
634+
if (canReadFunctionName()) {
635+
assert.equal(fn, 'setTimeout');
636+
} else {
637+
assert.equal(fn, '<anonymous>');
638+
}
639+
622640
assert.deepEqual(ravenData.exception.mechanism, {
623641
type: 'instrument',
624-
handled: true,
625-
data: {function: 'setTimeout'}
642+
handled: true
626643
});
627644
}
628645
);
@@ -652,13 +669,25 @@ describe('integration', function() {
652669
},
653670
function() {
654671
var ravenData = iframe.contentWindow.ravenData[0];
672+
673+
var handler = ravenData.exception.mechanism.data.handler;
674+
delete ravenData.exception.mechanism.data.handler;
675+
var target = ravenData.exception.mechanism.data.target;
676+
delete ravenData.exception.mechanism.data.target;
677+
678+
if (canReadFunctionName()) {
679+
assert.equal(handler, 'namedFunction');
680+
} else {
681+
assert.equal(handler, '<anonymous>');
682+
}
683+
684+
// IE vs. Rest of the world
685+
assert.oneOf(target, ['Node', 'EventTarget']);
655686
assert.deepEqual(ravenData.exception.mechanism, {
656687
type: 'instrument',
657688
handled: true,
658689
data: {
659-
function: 'addEventListener',
660-
handler: 'namedFunction',
661-
target: 'EventTarget'
690+
function: 'addEventListener'
662691
}
663692
});
664693
}
@@ -689,13 +718,18 @@ describe('integration', function() {
689718
},
690719
function() {
691720
var ravenData = iframe.contentWindow.ravenData[0];
721+
722+
var target = ravenData.exception.mechanism.data.target;
723+
delete ravenData.exception.mechanism.data.target;
724+
725+
// IE vs. Rest of the world
726+
assert.oneOf(target, ['Node', 'EventTarget']);
692727
assert.deepEqual(ravenData.exception.mechanism, {
693728
type: 'instrument',
694729
handled: true,
695730
data: {
696731
function: 'addEventListener',
697-
handler: '<anonymous>',
698-
target: 'EventTarget'
732+
handler: '<anonymous>'
699733
}
700734
});
701735
}

0 commit comments

Comments
 (0)