Skip to content

Commit c06aaef

Browse files
committed
add integration test
1 parent 32e5860 commit c06aaef

File tree

2 files changed

+47
-0
lines changed
  • dev-packages/browser-integration-tests/suites/integrations/globalHandlers/dataUrls

2 files changed

+47
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const workerCode = `
2+
self.addEventListener('message', (event) => {
3+
if (event.data.type === 'error') {
4+
throw new Error('Error thrown in worker');
5+
}
6+
});
7+
`;
8+
9+
const worker = new Worker(`data:text/javascript;base64,${btoa(workerCode)}`);
10+
11+
worker.postMessage({ type: 'error' });
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { expect } from '@playwright/test';
2+
import { sentryTest } from '../../../../utils/fixtures';
3+
import { envelopeRequestParser, waitForErrorRequest } from '../../../../utils/helpers';
4+
5+
sentryTest('detects and handles data urls on first stack frame', async ({ getLocalTestUrl, page }) => {
6+
const url = await getLocalTestUrl({ testDir: __dirname });
7+
8+
const errorEventPromise = waitForErrorRequest(page, e => {
9+
return !!e.exception?.values;
10+
});
11+
12+
await page.goto(url);
13+
14+
const errorEvent = envelopeRequestParser(await errorEventPromise);
15+
16+
expect(errorEvent?.exception?.values?.[0]).toEqual({
17+
mechanism: {
18+
handled: false,
19+
synthetic: true,
20+
type: 'auto.browser.global_handlers.onerror',
21+
},
22+
stacktrace: {
23+
frames: [
24+
{
25+
colno: 13,
26+
filename: '<data:text/javascript,base64>',
27+
function: '?',
28+
in_app: true,
29+
lineno: 4,
30+
},
31+
],
32+
},
33+
type: 'Error',
34+
value: 'Uncaught Error: Error thrown in worker',
35+
});
36+
});

0 commit comments

Comments
 (0)