Title: [223826] trunk
Revision
223826
Author
[email protected]
Date
2017-10-22 17:43:38 -0700 (Sun, 22 Oct 2017)

Log Message

REGRESSION(r219675): Web Inspector: CommandLineAPI getEventListeners does not work
https://bugs.webkit.org/show_bug.cgi?id=178650
<rdar://problem/35116347>

Patch by Joseph Pecoraro <[email protected]> on 2017-10-22
Reviewed by Sam Weinig.

Source/WebCore:

Test: inspector/console/command-line-api-getEventListeners.html

* inspector/CommandLineAPIHost.cpp:
(WebCore::listenerEntriesFromListenerInfo):
Fix typo.

(WebCore::CommandLineAPIHost::getEventListeners):
Fix incorrect early return.

* inspector/CommandLineAPIHost.h:
* inspector/CommandLineAPIHost.idl:
Add more attributes about the listener. These new attributes match output from Chrome.

LayoutTests:

* inspector/console/command-line-api-getEventListeners-expected.txt: Added.
* inspector/console/command-line-api-getEventListeners.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (223825 => 223826)


--- trunk/LayoutTests/ChangeLog	2017-10-22 21:31:24 UTC (rev 223825)
+++ trunk/LayoutTests/ChangeLog	2017-10-23 00:43:38 UTC (rev 223826)
@@ -1,3 +1,14 @@
+2017-10-22  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION(r219675): Web Inspector: CommandLineAPI getEventListeners does not work
+        https://bugs.webkit.org/show_bug.cgi?id=178650
+        <rdar://problem/35116347>
+
+        Reviewed by Sam Weinig.
+
+        * inspector/console/command-line-api-getEventListeners-expected.txt: Added.
+        * inspector/console/command-line-api-getEventListeners.html: Added.
+
 2017-10-22  Antoine Quint  <[email protected]>
 
         [Web Animations] Add animations to the timeline

Added: trunk/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt (0 => 223826)


--- trunk/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/command-line-api-getEventListeners-expected.txt	2017-10-23 00:43:38 UTC (rev 223826)
@@ -0,0 +1,51 @@
+Test for CommandLineAPI getEventListeners.
+
+
+== Running test suite: Console.CommandLineAPI.getEventListeners
+-- Running test case: Console.CommandLineAPI.getEventListeners.Undefined
+{}
+
+-- Running test case: Console.CommandLineAPI.getEventListeners.Null
+{}
+
+-- Running test case: Console.CommandLineAPI.getEventListeners.String
+TypeError: Argument 1 ('node') to CommandLineAPIHost.getEventListeners must be an instance of Node
+
+-- Running test case: Console.CommandLineAPI.getEventListeners.NodeNoListeners
+{}
+
+-- Running test case: Console.CommandLineAPI.getEventListeners.NodeWithListeners
+{
+  "click": [
+    {
+      "listener": "<function onclickHandler>",
+      "once": false,
+      "passive": false,
+      "useCapture": false
+    },
+    {
+      "listener": "<function clickHandler>",
+      "once": false,
+      "passive": false,
+      "useCapture": true
+    }
+  ],
+  "hover": [
+    {
+      "listener": "<function hoverHandler>",
+      "once": true,
+      "passive": true,
+      "useCapture": false
+    }
+  ],
+  "fake": [
+    {
+      "listener": "<function fakeHandler>",
+      "once": false,
+      "passive": false,
+      "useCapture": false
+    }
+  ]
+}
+
+

Added: trunk/LayoutTests/inspector/console/command-line-api-getEventListeners.html (0 => 223826)


--- trunk/LayoutTests/inspector/console/command-line-api-getEventListeners.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/command-line-api-getEventListeners.html	2017-10-23 00:43:38 UTC (rev 223826)
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function eventListenerJSONFilter(key, value) {
+    if (typeof value === "function")
+        return `<function ${value.name}>`;
+    return value;
+}
+
+function stringify(object) {
+    return JSON.stringify(object, eventListenerJSONFilter, 2);
+}
+
+function test()
+{
+    function evaluateWithCommandLineAPI(_expression_) {
+        return new Promise((resolve, reject) => {
+            WI.runtimeManager.evaluateInInspectedWindow(_expression_, {objectGroup: "test", includeCommandLineAPI: true}, (object, wasThrown) => {
+                resolve(object);
+            });
+        });
+    }
+
+    InspectorTest.debug();
+    let suite = InspectorTest.createAsyncSuite("Console.CommandLineAPI.getEventListeners");
+
+    function addTestCase({name, _expression_}) {
+        suite.addTestCase({
+            name,
+            async test() {
+                await evaluateWithCommandLineAPI(`
+                    try {
+                        TestPage.addResult(stringify(getEventListeners(${_expression_})));
+                    } catch (e) {
+                        TestPage.addResult(e);
+                    }
+                    TestPage.log("");
+                `);
+            }
+        });
+    }
+
+    addTestCase({
+        name: "Console.CommandLineAPI.getEventListeners.Undefined",
+        _expression_: `undefined`,
+    });
+
+    addTestCase({
+        name: "Console.CommandLineAPI.getEventListeners.Null",
+        _expression_: `null`,
+    });
+
+    addTestCase({
+        name: "Console.CommandLineAPI.getEventListeners.String",
+        _expression_: `"test"`,
+    });
+
+    addTestCase({
+        name: "Console.CommandLineAPI.getEventListeners.NodeNoListeners",
+        _expression_: `document.createElement("p")`,
+    });
+
+    addTestCase({
+        name: "Console.CommandLineAPI.getEventListeners.NodeWithListeners",
+        _expression_: `document.getElementById("target")`,
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for CommandLineAPI getEventListeners.</p>
+<div id="target"></div>
+<script>
+let target = document.getElementById("target");
+target._onclick_ = function onclickHandler() { console.log("click"); };
+target.addEventListener("hover", function hoverHandler() { console.log("hover"); }, {once: true, passive: true});
+target.addEventListener("click", function clickHandler() { console.log("click 2"); }, true);
+target.addEventListener("fake", function fakeHandler() { console.log("fake"); });
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (223825 => 223826)


--- trunk/Source/WebCore/ChangeLog	2017-10-22 21:31:24 UTC (rev 223825)
+++ trunk/Source/WebCore/ChangeLog	2017-10-23 00:43:38 UTC (rev 223826)
@@ -1,3 +1,24 @@
+2017-10-22  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION(r219675): Web Inspector: CommandLineAPI getEventListeners does not work
+        https://bugs.webkit.org/show_bug.cgi?id=178650
+        <rdar://problem/35116347>
+
+        Reviewed by Sam Weinig.
+
+        Test: inspector/console/command-line-api-getEventListeners.html
+
+        * inspector/CommandLineAPIHost.cpp:
+        (WebCore::listenerEntriesFromListenerInfo):
+        Fix typo.
+
+        (WebCore::CommandLineAPIHost::getEventListeners):
+        Fix incorrect early return.
+
+        * inspector/CommandLineAPIHost.h:
+        * inspector/CommandLineAPIHost.idl:
+        Add more attributes about the listener. These new attributes match output from Chrome.
+
 2017-10-22  Antoine Quint  <[email protected]>
 
         [Web Animations] Add animations to the timeline

Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (223825 => 223826)


--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp	2017-10-22 21:31:24 UTC (rev 223825)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp	2017-10-23 00:43:38 UTC (rev 223826)
@@ -93,7 +93,7 @@
 {
     VM& vm = state.vm();
 
-    Vector<CommandLineAPIHost::ListenerEntry> entires;
+    Vector<CommandLineAPIHost::ListenerEntry> entries;
     for (auto& eventListener : listenerInfo.eventListenerVector) {
         auto jsListener = JSEventListener::cast(&eventListener->callback());
         if (!jsListener) {
@@ -109,15 +109,15 @@
         if (!function)
             continue;
 
-        entires.append({ JSC::Strong<JSC::JSObject>(vm, function), eventListener->useCapture() });
+        entries.append({ JSC::Strong<JSC::JSObject>(vm, function), eventListener->useCapture(), eventListener->isPassive(), eventListener->isOnce() });
     }
 
-    return entires;
+    return entries;
 }
 
 auto CommandLineAPIHost::getEventListeners(JSC::ExecState& state, Node* node) -> EventListenersRecord
 {
-    if (m_domAgent)
+    if (!m_domAgent)
         return { };
 
     if (!node)

Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.h (223825 => 223826)


--- trunk/Source/WebCore/inspector/CommandLineAPIHost.h	2017-10-22 21:31:24 UTC (rev 223825)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.h	2017-10-23 00:43:38 UTC (rev 223826)
@@ -92,8 +92,10 @@
     void inspect(JSC::ExecState&, JSC::JSValue objectToInspect, JSC::JSValue hints);
 
     struct ListenerEntry {
-        JSC::Strong<JSC::JSObject> function;
+        JSC::Strong<JSC::JSObject> listener;
         bool useCapture;
+        bool passive;
+        bool once;
     };
 
     using EventListenersRecord = Vector<WTF::KeyValuePair<String, Vector<ListenerEntry>>>;

Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.idl (223825 => 223826)


--- trunk/Source/WebCore/inspector/CommandLineAPIHost.idl	2017-10-22 21:31:24 UTC (rev 223825)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.idl	2017-10-23 00:43:38 UTC (rev 223826)
@@ -49,6 +49,8 @@
 [
     JSGenerateToJSObject
 ] dictionary ListenerEntry {
-    required object function;
+    required object listener;
     required boolean useCapture;
+    required boolean passive;
+    required boolean once;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to