Re: [w3c/IndexedDB] Clarify interaction of IndexedDB lifecycles with relation to document and worker lifecycle mechanics (Issue #416)

> Perhaps related: https://github.com/whatwg/html/issues/10194 - @domfarolino any insights?

The issue you link to is about iframes getting unloaded, and their event firing in the removal path essentially being another instance of legacy mutation events which are bad.

But the first part of your message — about firing events in detached contexts — is generally desired because running script in a detached document has caused security bugs in the past. So we explicitly prevent events from being fired in those contexts as that's a very common way of running script. For example, note that:

```
const iframe = document.createElement('iframe');
document.body.append(iframe);
const iframeWindow = iframe.contentWindow;
iframeWindow.addEventListener('foo', e => console.warn(e));
iframe.remove();
iframeWindow.dispatchEvent(new Event('foo'));
```

Does not lead to the event handler running in all of: Chrome, Safari, and Firefox.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/416#issuecomment-2094371249
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/IndexedDB/issues/416/2094371249@github.com>

Received on Saturday, 4 May 2024 20:30:37 UTC