Skip to content

Commit 8dbdf50

Browse files
committed
fix: use global var instead of html for the check
1 parent 4be0cb9 commit 8dbdf50

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1+
window.__CSPVIOLATION__ = false;
12
document.addEventListener('securitypolicyviolation', () => {
2-
const container = document.querySelector('#csp-violation');
3-
if (container) {
4-
container.innerText = 'CSP Violation';
5-
}
3+
window.__CSPVIOLATION__ = true;
64
});

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/template.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
content="style-src 'nonce-foo1234'; script-src sentry-test.io 'nonce-foo1234';"
88
/>
99
</head>
10-
<body>
11-
<div id="csp-violation" />
12-
</body>
10+
<body></body>
1311
</html>

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackCsp/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
7979
},
8080
platform: 'javascript',
8181
});
82-
const cspContainer = await page.locator('#csp-violation');
83-
expect(cspContainer).not.toContainText('CSP Violation');
82+
const cspViolation = await page.evaluate<boolean>('window.__CSPVIOLATION__');
83+
expect(cspViolation).toBe(false);
8484
});

0 commit comments

Comments
 (0)