Title: [191615] trunk/Source/WebInspectorUI
Revision
191615
Author
[email protected]
Date
2015-10-26 17:25:49 -0700 (Mon, 26 Oct 2015)

Log Message

Web Inspector: WebInspector.Object can dispatch constructor-level events multiple times
https://bugs.webkit.org/show_bug.cgi?id=150579

Reviewed by Timothy Hatcher.

Use `hasOwnProperty` when checking for constructor event listeners when walking the
prototype chain. This prevents listeners registered with a base class constructor
from being dispatched multiple times by getting picked up higher in the prototype chain.

* UserInterface/Base/Object.js:
(WebInspector.Object.prototype.dispatchEventToListeners.dispatch):
(WebInspector.Object.prototype.dispatchEventToListeners):
(WebInspector.Object):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (191614 => 191615)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-10-27 00:11:45 UTC (rev 191614)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-10-27 00:25:49 UTC (rev 191615)
@@ -1,5 +1,21 @@
 2015-10-26  Matt Baker  <[email protected]>
 
+        Web Inspector: WebInspector.Object can dispatch constructor-level events multiple times
+        https://bugs.webkit.org/show_bug.cgi?id=150579
+
+        Reviewed by Timothy Hatcher.
+
+        Use `hasOwnProperty` when checking for constructor event listeners when walking the
+        prototype chain. This prevents listeners registered with a base class constructor
+        from being dispatched multiple times by getting picked up higher in the prototype chain.
+
+        * UserInterface/Base/Object.js:
+        (WebInspector.Object.prototype.dispatchEventToListeners.dispatch):
+        (WebInspector.Object.prototype.dispatchEventToListeners):
+        (WebInspector.Object):
+
+2015-10-26  Matt Baker  <[email protected]>
+
         Web Inspector: Hundreds of failed assertions after switching to Rendering Frames after recording complete
         https://bugs.webkit.org/show_bug.cgi?id=150568
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Object.js (191614 => 191615)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Object.js	2015-10-27 00:11:45 UTC (rev 191614)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Object.js	2015-10-27 00:25:49 UTC (rev 191615)
@@ -140,11 +140,15 @@
 
         function dispatch(object)
         {
-            if (!object || !object._listeners || !object._listeners[eventType] || event._stoppedPropagation)
+            if (!object || !object.hasOwnProperty("_listeners") || event._stoppedPropagation)
                 return;
 
+            let listenersForThisEvent = object._listeners[eventType];
+            if (!listenersForThisEvent)
+                return;
+
             // Make a copy with slice so mutations during the loop doesn't affect us.
-            var listenersForThisEvent = object._listeners[eventType].slice(0);
+            listenersForThisEvent = listenersForThisEvent.slice(0);
 
             // Iterate over the listeners and call them. Stop if stopPropagation is called.
             for (var i = 0; i < listenersForThisEvent.length; ++i) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to