Jacek Caban (@jacek) commented about dlls/mshtml/nsevents.c:
IHTMLDOMNode_AddRef(&doc->node.IHTMLDOMNode_iface);
- /* Keep a ref to the window as well, some apps navigate during the notifications */
- IHTMLWindow2_AddRef(&doc->window->base.IHTMLWindow2_iface);
The problem is not unique to this event handler. Note that if we'd keep a reference to window instead of document, it would be probably enough. Since those event listeners already operate on the window, maybe it would be better to just store window, instead of document, in nsDocumentEventListener.