- fixed <rdar://problem/
3598589> onunload handler doesn't fire when a window is closed
Test cases added:
* layout-tests/fast/events/onunload-expected.txt: Added.
* layout-tests/fast/events/onunload.html: Added.
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::detach): Don't remove all event handlers from the document here...
* khtml/khtml_part.cpp:
(KHTMLPart::closeURL): ...instead do it here, after firing the unload event, but only
if the document is not in the back/forward cache...
* kwq/KWQPageState.mm:
(-[KWQPageState finalize]): ...and take care of the back/forward cache case here.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9200
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+ALERT: unload
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x34
+ RenderBlock {HTML} at (0,0) size 800x34
+ RenderBody {BODY} at (8,8) size 784x18
+ RenderText {TEXT} at (0,0) size 287x18
+ text run at (0,0) width 287: "You should have seen an unload alert appear."
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x34
+ RenderBlock {HTML} at (0,0) size 800x34
+ RenderBody {BODY} at (8,8) size 784x18
+ RenderText {TEXT} at (0,0) size 287x18
+ text run at (0,0) width 287: "You should have seen an unload alert appear."
--- /dev/null
+<html>
+<body onunload="unload()" onload="load()">
+<script>
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function load()
+{
+ location = "data:text/html,You should have seen an unload alert appear.<script>if (window.layoutTestController) layoutTestController.notifyDone(); </" + "script>";
+}
+
+function unload()
+{
+ alert("unload");
+}
+</script>
+start document
+</body>
+</html>
+2005-05-24 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by John.
+
+ - fixed <rdar://problem/3598589> onunload handler doesn't fire when a window is closed
+
+ Test cases added:
+ * layout-tests/fast/events/onunload-expected.txt: Added.
+ * layout-tests/fast/events/onunload.html: Added.
+
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::detach): Don't remove all event handlers from the document here...
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::closeURL): ...instead do it here, after firing the unload event, but only
+ if the document is not in the back/forward cache...
+ * kwq/KWQPageState.mm:
+ (-[KWQPageState finalize]): ...and take care of the back/forward cache case here.
+
2005-05-24 John Sullivan <sullivan@apple.com>
Reviewed by Kevin.
d->m_bUnloadEventEmitted = true;
}
}
+
+ if (d->m_doc && !d->m_doc->inPageCache())
+ d->m_doc->removeAllEventListenersFromAllNodes();
d->m_bComplete = true; // to avoid emitting completed() in slotFinishedParsing() (David)
d->m_bLoadingMainResource = false;
m_imageLoadEventDispatchSoonList.clear();
m_imageLoadEventDispatchingList.clear();
-
- // FIXME: UNLOAD_EVENT will not dispatch due to deleting event listeners prior to closeURL().
- removeAllEventListenersFromAllNodes();
-
ContainerNodeImpl::detach();
if ( render )
document->setInPageCache(NO);
if (detached) {
document->detach();
+ document->removeAllEventListenersFromAllNodes();
}
document->deref();
document->setInPageCache(NO);
if (detached) {
document->detach();
+ document->removeAllEventListenersFromAllNodes();
}
document->deref();