diff --git a/packages/snaps-execution-environments/src/common/lockdown/lockdown-events.test.browser.ts b/packages/snaps-execution-environments/src/common/lockdown/lockdown-events.test.browser.ts index 337ff978d1..b94bcbfe5c 100644 --- a/packages/snaps-execution-environments/src/common/lockdown/lockdown-events.test.browser.ts +++ b/packages/snaps-execution-environments/src/common/lockdown/lockdown-events.test.browser.ts @@ -7,19 +7,19 @@ describe('lockdown events security', () => { it('should lockdown events and made event properties inaccessible', async () => { executeLockdownEvents(); - let resolvePromise: (value: unknown) => void; + const eventTarget = new EventTarget(); + const promise = new Promise((resolve) => { - resolvePromise = resolve; + eventTarget.addEventListener('just-test-event', (eventObject) => { + // eslint-disable-next-line @typescript-eslint/unbound-method + resolve(eventObject.composedPath); + }); }); - const eventTarget = new EventTarget(); - eventTarget.addEventListener('just-test-event', (eventObject) => { - // eslint-disable-next-line @typescript-eslint/unbound-method - expect(eventObject.composedPath).toBeUndefined(); - resolvePromise(true); - }); const testEvent = new Event('just-test-event'); eventTarget.dispatchEvent(testEvent); - await promise; + + const result = await promise; + expect(result).toBeUndefined(); }); });