Title: [231248] trunk
- Revision
- 231248
- Author
- [email protected]
- Date
- 2018-05-02 11:39:20 -0700 (Wed, 02 May 2018)
Log Message
document.open() event listener removal is not immediate
https://bugs.webkit.org/show_bug.cgi?id=185191
Reviewed by Darin Adler.
Source/WebCore:
We need to make sure we set the 'wasremoved' flag on RegisteredEventListeners
whenever they get removed from the EventListenerMap. We were doing so correctly
in EventListenerMap:remove() but not EventListenerMap::clear(). This patch
updates clear() accordingly.
The reason we need to set this flag is that RegisteredEventListeners is RefCounted
and EventTarget::fireEventListeners() may be currently running and calling
each listener one by one, holding a reference to all listener of a given event.
Test: fast/dom/Document/document-open-removes-all-listeners.html
* dom/EventListenerMap.cpp:
(WebCore::EventListenerMap::clear):
LayoutTests:
Add layout test coverage.
* fast/dom/Document/document-open-removes-all-listeners-expected.txt: Added.
* fast/dom/Document/document-open-removes-all-listeners.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (231247 => 231248)
--- trunk/LayoutTests/ChangeLog 2018-05-02 18:37:27 UTC (rev 231247)
+++ trunk/LayoutTests/ChangeLog 2018-05-02 18:39:20 UTC (rev 231248)
@@ -1,3 +1,15 @@
+2018-05-02 Chris Dumez <[email protected]>
+
+ document.open() event listener removal is not immediate
+ https://bugs.webkit.org/show_bug.cgi?id=185191
+
+ Reviewed by Darin Adler.
+
+ Add layout test coverage.
+
+ * fast/dom/Document/document-open-removes-all-listeners-expected.txt: Added.
+ * fast/dom/Document/document-open-removes-all-listeners.html: Added.
+
2018-05-01 Brent Fulgham <[email protected]>
Prevent assertion when changing forms
Added: trunk/LayoutTests/fast/dom/Document/document-open-removes-all-listeners-expected.txt (0 => 231248)
--- trunk/LayoutTests/fast/dom/Document/document-open-removes-all-listeners-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/document-open-removes-all-listeners-expected.txt 2018-05-02 18:39:20 UTC (rev 231248)
@@ -0,0 +1,10 @@
+Event listeners are to be removed with immediate effect by document.open()
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS once is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Document/document-open-removes-all-listeners.html (0 => 231248)
--- trunk/LayoutTests/fast/dom/Document/document-open-removes-all-listeners.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/document-open-removes-all-listeners.html 2018-05-02 18:39:20 UTC (rev 231248)
@@ -0,0 +1,21 @@
+<DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Event listeners are to be removed with immediate effect by document.open()");
+
+const frame = document.body.appendChild(document.createElement("iframe"));
+let _once_ = false;
+frame.contentDocument.addEventListener("x", () => {
+ frame.contentDocument.open();
+ _once_ = true;
+});
+frame.contentDocument.addEventListener("x", function() {
+ testFailed("second event listener not removed")
+});
+frame.contentDocument.dispatchEvent(new Event("x"));
+shouldBeTrue("once");
+frame.contentDocument.close();
+</script>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (231247 => 231248)
--- trunk/Source/WebCore/ChangeLog 2018-05-02 18:37:27 UTC (rev 231247)
+++ trunk/Source/WebCore/ChangeLog 2018-05-02 18:39:20 UTC (rev 231248)
@@ -1,3 +1,24 @@
+2018-05-02 Chris Dumez <[email protected]>
+
+ document.open() event listener removal is not immediate
+ https://bugs.webkit.org/show_bug.cgi?id=185191
+
+ Reviewed by Darin Adler.
+
+ We need to make sure we set the 'wasremoved' flag on RegisteredEventListeners
+ whenever they get removed from the EventListenerMap. We were doing so correctly
+ in EventListenerMap:remove() but not EventListenerMap::clear(). This patch
+ updates clear() accordingly.
+
+ The reason we need to set this flag is that RegisteredEventListeners is RefCounted
+ and EventTarget::fireEventListeners() may be currently running and calling
+ each listener one by one, holding a reference to all listener of a given event.
+
+ Test: fast/dom/Document/document-open-removes-all-listeners.html
+
+ * dom/EventListenerMap.cpp:
+ (WebCore::EventListenerMap::clear):
+
2018-05-02 Zalan Bujtas <[email protected]>
Use WeakPtr in GridCell
Modified: trunk/Source/WebCore/dom/EventListenerMap.cpp (231247 => 231248)
--- trunk/Source/WebCore/dom/EventListenerMap.cpp 2018-05-02 18:37:27 UTC (rev 231247)
+++ trunk/Source/WebCore/dom/EventListenerMap.cpp 2018-05-02 18:39:20 UTC (rev 231248)
@@ -86,6 +86,11 @@
assertNoActiveIterators();
+ for (auto& entry : m_entries) {
+ for (auto& listener : *entry.second)
+ listener->markAsRemoved();
+ }
+
m_entries.clear();
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes