Skip to content

Commit 5eb2cf7

Browse files
committed
test: Integration test for preserving wrap context
1 parent 5337ee6 commit 5eb2cf7

File tree

1 file changed

+7
-19
lines changed
  • packages/browser/test/integration

1 file changed

+7
-19
lines changed

packages/browser/test/integration/test.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -400,25 +400,6 @@ describe('integration', function() {
400400
);
401401
});
402402

403-
it('should NOT catch an exception already caught via Sentry.wrap', function(done) {
404-
var iframe = this.iframe;
405-
406-
iframeExecute(
407-
iframe,
408-
done,
409-
function() {
410-
setTimeout(done);
411-
Sentry.wrap(function() {
412-
foo();
413-
})();
414-
},
415-
function() {
416-
var sentryData = iframe.contentWindow.sentryData;
417-
assert.equal(sentryData.length, 1); // one caught error
418-
},
419-
);
420-
});
421-
422403
it('should NOT catch an exception already caught [but rethrown] via Sentry.captureException', function(done) {
423404
var iframe = this.iframe;
424405
iframeExecute(
@@ -456,6 +437,8 @@ describe('integration', function() {
456437
div.addEventListener(
457438
'click',
458439
function() {
440+
window.element = div;
441+
window.context = this;
459442
foo();
460443
},
461444
false,
@@ -465,6 +448,11 @@ describe('integration', function() {
465448
div.dispatchEvent(click);
466449
},
467450
function() {
451+
// Make sure we preserve the correct context
452+
assert.equal(iframe.contentWindow.element, iframe.contentWindow.context);
453+
delete iframe.contentWindow.element;
454+
delete iframe.contentWindow.context;
455+
468456
var sentryData = iframe.contentWindow.sentryData[0];
469457
assert.isAtLeast(sentryData.exception.values[0].stacktrace.frames.length, 3);
470458
assert.isAtMost(sentryData.exception.values[0].stacktrace.frames.length, 5);

0 commit comments

Comments
 (0)