Skip to content

Commit 8f8c99d

Browse files
committed
add another sdk interop test
1 parent bf3a767 commit 8f8c99d

File tree

8 files changed

+53
-3
lines changed

8 files changed

+53
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
/**
4+
* This simulates an relatively new v7 SDK setting acs on the __SENTRY__ carrier.
5+
* see: https://github.com/getsentry/sentry-javascript/issues/12054
6+
*/
7+
window.__SENTRY__ = {
8+
acs: {
9+
getCurrentScope: () => {
10+
return 'scope';
11+
},
12+
},
13+
};
14+
15+
window.Sentry = Sentry;
16+
17+
Sentry.init({
18+
dsn: 'https://[email protected]/1337',
19+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const sentryCarrier = window && window.__SENTRY__;
2+
3+
/**
4+
* Simulate an old pre v8 SDK obtaining the hub from the global sentry carrier
5+
* and checking for the hub version.
6+
*/
7+
const res = sentryCarrier.acs && sentryCarrier.acs.getCurrentScope();
8+
9+
// Write back result into the document
10+
document.getElementById('currentScope').innerText = res && 'scope';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
</head>
6+
<body>
7+
<p id="currentScope"></p>
8+
</body>
9+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
5+
sentryTest(
6+
"doesn't crash if older SDKs access `acs.getCurrentScope` on the global object",
7+
async ({ getLocalTestUrl, page }) => {
8+
const url = await getLocalTestUrl({ testDir: __dirname });
9+
await page.goto(url);
10+
11+
await expect(page.locator('#currentScope')).toHaveText('scope');
12+
},
13+
);

dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/init.js renamed to dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as Sentry from '@sentry/browser';
22

33
/**
44
* This simulates an old, pre-v8 SDK setting itself up on the global __SENTRY__ carrier.
5+
* see: https://github.com/getsentry/sentry-javascript/issues/12155
56
*/
67
window.__SENTRY__ = {
78
hub: {

dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/subject.js renamed to dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/subject.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ const res = sentryCarrier.hub && sentryCarrier.hub.isOlderThan(7);
88

99
// Write back result into the document
1010
document.getElementById('olderThan').innerText = res;
11-
12-
console.log(sentryCarrier);

dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/test.ts renamed to dev-packages/browser-integration-tests/suites/old-sdk-interop/hub/isOlderThan/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from '@playwright/test';
22

3-
import { sentryTest } from '../../../utils/fixtures';
3+
import { sentryTest } from '../../../../utils/fixtures';
44

55
sentryTest(
66
"doesn't crash if older SDKs access `hub.isOlderThan` on the global object",

0 commit comments

Comments
 (0)