Title: [195442] trunk
Revision
195442
Author
nvasil...@apple.com
Date
2016-01-21 21:54:31 -0800 (Thu, 21 Jan 2016)

Log Message

REGRESSION (r195305): Web Inspector: WebInspector.Object can dispatch constructor-level events multiple times
https://bugs.webkit.org/show_bug.cgi?id=153269
<rdar://problem/24253106>

Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

Bring back object.hasOwnProperty("_listeners") check.

* UserInterface/Base/Object.js:
(WebInspector.Object.prototype.dispatchEventToListeners.dispatch):
(WebInspector.Object.prototype.dispatchEventToListeners):
(WebInspector.Object):
Check !object._listeners before !object.hasOwnProperty("_listeners")
because !object._listeners is more common case thus we can exit earlier
most of the time.

LayoutTests:

* inspector/unit-tests/object-expected.txt: Added.
* inspector/unit-tests/object.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195441 => 195442)


--- trunk/LayoutTests/ChangeLog	2016-01-22 05:49:26 UTC (rev 195441)
+++ trunk/LayoutTests/ChangeLog	2016-01-22 05:54:31 UTC (rev 195442)
@@ -1,3 +1,14 @@
+2016-01-21  Nikita Vasilyev  <nvasil...@apple.com>
+
+        REGRESSION (r195305): Web Inspector: WebInspector.Object can dispatch constructor-level events multiple times
+        https://bugs.webkit.org/show_bug.cgi?id=153269
+        <rdar://problem/24253106>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/unit-tests/object-expected.txt: Added.
+        * inspector/unit-tests/object.html: Added.
+
 2016-01-21  Yusuke Suzuki  <utatane....@gmail.com>
 
         [ES6] Catch parameter should accept BindingPattern

Added: trunk/LayoutTests/inspector/unit-tests/object-expected.txt (0 => 195442)


--- trunk/LayoutTests/inspector/unit-tests/object-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/object-expected.txt	2016-01-22 05:54:31 UTC (rev 195442)
@@ -0,0 +1,7 @@
+Testing WebInspector.Object.
+
+
+== Running test suite: Object
+-- Running test case: Events propagation
+Dispatch count: 1
+

Added: trunk/LayoutTests/inspector/unit-tests/object.html (0 => 195442)


--- trunk/LayoutTests/inspector/unit-tests/object.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/object.html	2016-01-22 05:54:31 UTC (rev 195442)
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    let suite = InspectorTest.createSyncSuite("Object");
+
+    suite.addTestCase({
+        name: "Events propagation",
+        description: "WebInspector.Object shouldn't dispatch constructor-level events multiple times",
+        test: function() {
+            class Parent extends WebInspector.Object {}
+            class Child extends Parent {}
+
+            const eventName = "clicked";
+            let dispatchCount = 0;
+
+            Parent.addEventListener(eventName, () => dispatchCount++);
+
+            let child = new Child;
+            child.dispatchEventToListeners(eventName);
+
+            InspectorTest.log("Dispatch count: " + dispatchCount);
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Testing WebInspector.Object.</p>
+</body>
+</html>

Modified: trunk/Source/WebInspectorUI/ChangeLog (195441 => 195442)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-01-22 05:49:26 UTC (rev 195441)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-01-22 05:54:31 UTC (rev 195442)
@@ -1,3 +1,21 @@
+2016-01-21  Nikita Vasilyev  <nvasil...@apple.com>
+
+        REGRESSION (r195305): Web Inspector: WebInspector.Object can dispatch constructor-level events multiple times
+        https://bugs.webkit.org/show_bug.cgi?id=153269
+        <rdar://problem/24253106>
+
+        Reviewed by Timothy Hatcher.
+
+        Bring back object.hasOwnProperty("_listeners") check.
+
+        * UserInterface/Base/Object.js:
+        (WebInspector.Object.prototype.dispatchEventToListeners.dispatch):
+        (WebInspector.Object.prototype.dispatchEventToListeners):
+        (WebInspector.Object):
+        Check !object._listeners before !object.hasOwnProperty("_listeners")
+        because !object._listeners is more common case thus we can exit earlier
+        most of the time.
+
 2016-01-21  Devin Rousso  <dcrousso+web...@gmail.com>
 
         Web Inspector: Add toggle-able list of classes for each element

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Object.js (195441 => 195442)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Object.js	2016-01-22 05:49:26 UTC (rev 195441)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Object.js	2016-01-22 05:54:31 UTC (rev 195442)
@@ -139,12 +139,16 @@
 
         function dispatch(object)
         {
-            if (!object || !object._listeners || event._stoppedPropagation)
+            if (!object || event._stoppedPropagation)
                 return;
 
-            console.assert(object._listeners instanceof Map);
+            let listenerTypesMap = object._listeners;
+            if (!listenerTypesMap || !object.hasOwnProperty("_listeners"))
+                return;
 
-            let listenersTable = object._listeners.get(eventType);
+            console.assert(listenerTypesMap instanceof Map);
+
+            let listenersTable = listenerTypesMap.get(eventType);
             if (!listenersTable)
                 return;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to