Title: [249315] trunk
Revision
249315
Author
drou...@apple.com
Date
2019-08-29 23:56:06 -0700 (Thu, 29 Aug 2019)

Log Message

Web Inspector: Debugger: async event listener stack traces should be available in Workers
https://bugs.webkit.org/show_bug.cgi?id=200903

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

* inspector/agents/InspectorDebuggerAgent.h:
(Inspector::InspectorDebuggerAgent::enabled): Added.
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::willDestroyFrontendAndBackend):
(Inspector::InspectorDebuggerAgent::enable):
(Inspector::InspectorDebuggerAgent::disable):
Allow subclasses to extend what it means for the `InspectorDebuggerAgent` to be `enabled`.

Source/WebCore:

Tests: inspector/worker/dom-debugger-event-interval-breakpoints.html
       inspector/worker/dom-debugger-event-listener-breakpoints.html
       inspector/worker/dom-debugger-event-timeout-breakpoints.html
       inspector/worker/dom-debugger-url-breakpoints.html

* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
(WebCore::WebDebuggerAgent::enabled const): Added.
(WebCore::WebDebuggerAgent::enable):
(WebCore::WebDebuggerAgent::disable):
(WebCore::WebDebuggerAgent::didAddEventListener): Added.
(WebCore::WebDebuggerAgent::willRemoveEventListener): Added.
(WebCore::WebDebuggerAgent::willHandleEvent): Added.
(WebCore::WebDebuggerAgent::didPostMessage): Added.
(WebCore::WebDebuggerAgent::didFailPostMessage): Added.
(WebCore::WebDebuggerAgent::willDispatchPostMessage): Added.
(WebCore::WebDebuggerAgent::didDispatchPostMessage): Added.
(WebCore::WebDebuggerAgent::didClearAsyncStackTraceData): Added.
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::enabled const): Added.
(WebCore::PageDebuggerAgent::enable):
(WebCore::PageDebuggerAgent::disable):
(WebCore::PageDebuggerAgent::didClearAsyncStackTraceData): Deleted.
(WebCore::PageDebuggerAgent::didAddEventListener): Deleted.
(WebCore::PageDebuggerAgent::willRemoveEventListener): Deleted.
(WebCore::PageDebuggerAgent::willHandleEvent): Deleted.
(WebCore::PageDebuggerAgent::didPostMessage): Deleted.
(WebCore::PageDebuggerAgent::didFailPostMessage): Deleted.
(WebCore::PageDebuggerAgent::willDispatchPostMessage): Deleted.
(WebCore::PageDebuggerAgent::didDispatchPostMessage): Deleted.
Move various `InspectorInstrumentation` calls from `PageDebuggerAgent` to `WebDebuggerAgent`
so that `WorkerDebuggerAgent` also inherits them.

* inspector/InstrumentingAgents.h:
(WebCore::InstrumentingAgents::webDebuggerAgent const): Added.
(WebCore::InstrumentingAgents::setWebDebuggerAgent): Added.
(WebCore::InstrumentingAgents::inspectorDebuggerAgent const): Deleted.
(WebCore::InstrumentingAgents::setInspectorDebuggerAgent): Deleted.
* inspector/InstrumentingAgents.cpp:
(WebCore::InstrumentingAgents::reset):
* inspector/agents/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::mainFrameStartedLoading):
(WebCore::InspectorTimelineAgent::startProgrammaticCapture):
(WebCore::InspectorTimelineAgent::stopProgrammaticCapture):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):
(WebCore::InspectorInstrumentation::isDebuggerPausedImpl):
(WebCore::InspectorInstrumentation::didInstallTimerImpl):
(WebCore::InspectorInstrumentation::didRemoveTimerImpl):
(WebCore::InspectorInstrumentation::didAddEventListenerImpl):
(WebCore::InspectorInstrumentation::willRemoveEventListenerImpl):
(WebCore::InspectorInstrumentation::didPostMessageImpl):
(WebCore::InspectorInstrumentation::didFailPostMessageImpl):
(WebCore::InspectorInstrumentation::willDispatchPostMessageImpl):
(WebCore::InspectorInstrumentation::didDispatchPostMessageImpl):
(WebCore::InspectorInstrumentation::willHandleEventImpl):
(WebCore::InspectorInstrumentation::didHandleEventImpl):
(WebCore::InspectorInstrumentation::willFireTimerImpl):
(WebCore::InspectorInstrumentation::didFireTimerImpl):
(WebCore::InspectorInstrumentation::scriptExecutionBlockedByCSPImpl):
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
(WebCore::InspectorInstrumentation::frameStartedLoadingImpl):
(WebCore::InspectorInstrumentation::frameStoppedLoadingImpl):
(WebCore::InspectorInstrumentation::addMessageToConsoleImpl):
(WebCore::InspectorInstrumentation::didRequestAnimationFrameImpl):
(WebCore::InspectorInstrumentation::didCancelAnimationFrameImpl):
(WebCore::InspectorInstrumentation::willFireAnimationFrameImpl):
(WebCore::InspectorInstrumentation::didFireAnimationFrameImpl):
Replace `inspectorDebuggerAgent` with `webDebuggerAgent` so the right instrumentation hooks
are available.

LayoutTests:

* inspector/worker/dom-debugger-event-interval-breakpoints-expected.txt:
* inspector/worker/dom-debugger-event-listener-breakpoints-expected.txt:
* inspector/worker/dom-debugger-event-timeout-breakpoints-expected.txt:
* inspector/worker/dom-debugger-url-breakpoints-expected.txt:
* inspector/worker/resources/worker-dom-debugger.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (249314 => 249315)


--- trunk/LayoutTests/ChangeLog	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/LayoutTests/ChangeLog	2019-08-30 06:56:06 UTC (rev 249315)
@@ -1,3 +1,16 @@
+2019-08-29  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: Debugger: async event listener stack traces should be available in Workers
+        https://bugs.webkit.org/show_bug.cgi?id=200903
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/worker/dom-debugger-event-interval-breakpoints-expected.txt:
+        * inspector/worker/dom-debugger-event-listener-breakpoints-expected.txt:
+        * inspector/worker/dom-debugger-event-timeout-breakpoints-expected.txt:
+        * inspector/worker/dom-debugger-url-breakpoints-expected.txt:
+        * inspector/worker/resources/worker-dom-debugger.js:
+
 2019-08-29  Timothy Hatcher  <timo...@apple.com>
 
         Copying and pasting two paragraphs with a newline between them results in stray paragraph with newline inside.

Modified: trunk/LayoutTests/inspector/worker/dom-debugger-event-interval-breakpoints-expected.txt (249314 => 249315)


--- trunk/LayoutTests/inspector/worker/dom-debugger-event-interval-breakpoints-expected.txt	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/LayoutTests/inspector/worker/dom-debugger-event-interval-breakpoints-expected.txt	2019-08-30 06:56:06 UTC (rev 249315)
@@ -10,5 +10,7 @@
 ASYNC CALL STACK:
 1: --- setInterval ---
 2: [F] triggerInterval
-3: [F] onmessage
+3: [F] handleMessage
+4: --- addEventListener ---
+5: [P] Global Code
 

Modified: trunk/LayoutTests/inspector/worker/dom-debugger-event-listener-breakpoints-expected.txt (249314 => 249315)


--- trunk/LayoutTests/inspector/worker/dom-debugger-event-listener-breakpoints-expected.txt	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/LayoutTests/inspector/worker/dom-debugger-event-listener-breakpoints-expected.txt	2019-08-30 06:56:06 UTC (rev 249315)
@@ -9,5 +9,8 @@
 CALL STACK:
 0: [F] handler
 1: [F] triggerListener
-2: [F] onmessage
+2: [F] handleMessage
+ASYNC CALL STACK:
+3: --- addEventListener ---
+4: [P] Global Code
 

Modified: trunk/LayoutTests/inspector/worker/dom-debugger-event-timeout-breakpoints-expected.txt (249314 => 249315)


--- trunk/LayoutTests/inspector/worker/dom-debugger-event-timeout-breakpoints-expected.txt	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/LayoutTests/inspector/worker/dom-debugger-event-timeout-breakpoints-expected.txt	2019-08-30 06:56:06 UTC (rev 249315)
@@ -10,5 +10,7 @@
 ASYNC CALL STACK:
 1: --- setTimeout ---
 2: [F] triggerTimeout
-3: [F] onmessage
+3: [F] handleMessage
+4: --- addEventListener ---
+5: [P] Global Code
 

Modified: trunk/LayoutTests/inspector/worker/dom-debugger-url-breakpoints-expected.txt (249314 => 249315)


--- trunk/LayoutTests/inspector/worker/dom-debugger-url-breakpoints-expected.txt	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/LayoutTests/inspector/worker/dom-debugger-url-breakpoints-expected.txt	2019-08-30 06:56:06 UTC (rev 249315)
@@ -9,7 +9,10 @@
 CALL STACK:
 0: [F] loadResourceFetch
 1: [F] triggerFetch
-2: [F] onmessage
+2: [F] handleMessage
+ASYNC CALL STACK:
+3: --- addEventListener ---
+4: [P] Global Code
 
 -- Running test case: Worker.DOMDebugger.URLBreakpoint.XHR
 PASS: Should have paused.
@@ -18,5 +21,8 @@
 CALL STACK:
 0: [F] loadResourceXHR
 1: [F] triggerXHR
-2: [F] onmessage
+2: [F] handleMessage
+ASYNC CALL STACK:
+3: --- addEventListener ---
+4: [P] Global Code
 

Modified: trunk/LayoutTests/inspector/worker/resources/worker-dom-debugger.js (249314 => 249315)


--- trunk/LayoutTests/inspector/worker/resources/worker-dom-debugger.js	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/LayoutTests/inspector/worker/resources/worker-dom-debugger.js	2019-08-30 06:56:06 UTC (rev 249315)
@@ -27,6 +27,6 @@
     console.log("listener fired");
 });
 
-_onmessage_ = function(event) {
+addEventListener("message", function handleMessage(event) {
     functions[event.data]();
-}
+});

Modified: trunk/Source/_javascript_Core/ChangeLog (249314 => 249315)


--- trunk/Source/_javascript_Core/ChangeLog	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-08-30 06:56:06 UTC (rev 249315)
@@ -1,3 +1,18 @@
+2019-08-29  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: Debugger: async event listener stack traces should be available in Workers
+        https://bugs.webkit.org/show_bug.cgi?id=200903
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/agents/InspectorDebuggerAgent.h:
+        (Inspector::InspectorDebuggerAgent::enabled): Added.
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::willDestroyFrontendAndBackend):
+        (Inspector::InspectorDebuggerAgent::enable):
+        (Inspector::InspectorDebuggerAgent::disable):
+        Allow subclasses to extend what it means for the `InspectorDebuggerAgent` to be `enabled`.
+
 2019-08-29  Keith Rollin  <krol...@apple.com>
 
         Update .xcconfig symbols to reflect the current set of past and future product versions.

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (249314 => 249315)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2019-08-30 06:56:06 UTC (rev 249315)
@@ -79,14 +79,12 @@
 
 void InspectorDebuggerAgent::willDestroyFrontendAndBackend(DisconnectReason reason)
 {
-    disable(reason == DisconnectReason::InspectedTargetDestroyed);
+    if (enabled())
+        disable(reason == DisconnectReason::InspectedTargetDestroyed);
 }
 
 void InspectorDebuggerAgent::enable()
 {
-    if (m_enabled)
-        return;
-
     m_enabled = true;
 
     m_scriptDebugServer.addListener(this);
@@ -97,9 +95,6 @@
 
 void InspectorDebuggerAgent::disable(bool isBeingDestroyed)
 {
-    if (!m_enabled)
-        return;
-
     for (auto* listener : copyToVector(m_listeners))
         listener->debuggerWasDisabled();
 
@@ -120,8 +115,13 @@
     m_enabled = false;
 }
 
-void InspectorDebuggerAgent::enable(ErrorString&)
+void InspectorDebuggerAgent::enable(ErrorString& errorString)
 {
+    if (enabled()) {
+        errorString = "Debugger domain already enabled"_s;
+        return;
+    }
+
     enable();
 }
 

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h (249314 => 249315)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h	2019-08-30 06:56:06 UTC (rev 249315)
@@ -60,6 +60,7 @@
     // InspectorAgentBase
     void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) final;
     void willDestroyFrontendAndBackend(DisconnectReason) final;
+    virtual bool enabled() const { return m_enabled; }
 
     // DebuggerBackendDispatcherHandler
     void enable(ErrorString&) final;
@@ -132,6 +133,8 @@
 
 protected:
     InspectorDebuggerAgent(AgentContext&);
+    virtual void enable();
+    virtual void disable(bool isBeingDestroyed);
 
     InjectedScriptManager& injectedScriptManager() const { return m_injectedScriptManager; }
     virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0;
@@ -141,9 +144,6 @@
     virtual void muteConsole() = 0;
     virtual void unmuteConsole() = 0;
 
-    virtual void enable();
-    virtual void disable(bool isBeingDestroyed);
-
     virtual String sourceMapURLForScript(const Script&);
 
     void didClearGlobalObject();

Modified: trunk/Source/WebCore/ChangeLog (249314 => 249315)


--- trunk/Source/WebCore/ChangeLog	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/ChangeLog	2019-08-30 06:56:06 UTC (rev 249315)
@@ -1,3 +1,82 @@
+2019-08-29  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: Debugger: async event listener stack traces should be available in Workers
+        https://bugs.webkit.org/show_bug.cgi?id=200903
+
+        Reviewed by Joseph Pecoraro.
+
+        Tests: inspector/worker/dom-debugger-event-interval-breakpoints.html
+               inspector/worker/dom-debugger-event-listener-breakpoints.html
+               inspector/worker/dom-debugger-event-timeout-breakpoints.html
+               inspector/worker/dom-debugger-url-breakpoints.html
+
+        * inspector/agents/WebDebuggerAgent.h:
+        * inspector/agents/WebDebuggerAgent.cpp:
+        (WebCore::WebDebuggerAgent::enabled const): Added.
+        (WebCore::WebDebuggerAgent::enable):
+        (WebCore::WebDebuggerAgent::disable):
+        (WebCore::WebDebuggerAgent::didAddEventListener): Added.
+        (WebCore::WebDebuggerAgent::willRemoveEventListener): Added.
+        (WebCore::WebDebuggerAgent::willHandleEvent): Added.
+        (WebCore::WebDebuggerAgent::didPostMessage): Added.
+        (WebCore::WebDebuggerAgent::didFailPostMessage): Added.
+        (WebCore::WebDebuggerAgent::willDispatchPostMessage): Added.
+        (WebCore::WebDebuggerAgent::didDispatchPostMessage): Added.
+        (WebCore::WebDebuggerAgent::didClearAsyncStackTraceData): Added.
+        * inspector/agents/page/PageDebuggerAgent.h:
+        * inspector/agents/page/PageDebuggerAgent.cpp:
+        (WebCore::PageDebuggerAgent::enabled const): Added.
+        (WebCore::PageDebuggerAgent::enable):
+        (WebCore::PageDebuggerAgent::disable):
+        (WebCore::PageDebuggerAgent::didClearAsyncStackTraceData): Deleted.
+        (WebCore::PageDebuggerAgent::didAddEventListener): Deleted.
+        (WebCore::PageDebuggerAgent::willRemoveEventListener): Deleted.
+        (WebCore::PageDebuggerAgent::willHandleEvent): Deleted.
+        (WebCore::PageDebuggerAgent::didPostMessage): Deleted.
+        (WebCore::PageDebuggerAgent::didFailPostMessage): Deleted.
+        (WebCore::PageDebuggerAgent::willDispatchPostMessage): Deleted.
+        (WebCore::PageDebuggerAgent::didDispatchPostMessage): Deleted.
+        Move various `InspectorInstrumentation` calls from `PageDebuggerAgent` to `WebDebuggerAgent`
+        so that `WorkerDebuggerAgent` also inherits them.
+
+        * inspector/InstrumentingAgents.h:
+        (WebCore::InstrumentingAgents::webDebuggerAgent const): Added.
+        (WebCore::InstrumentingAgents::setWebDebuggerAgent): Added.
+        (WebCore::InstrumentingAgents::inspectorDebuggerAgent const): Deleted.
+        (WebCore::InstrumentingAgents::setInspectorDebuggerAgent): Deleted.
+        * inspector/InstrumentingAgents.cpp:
+        (WebCore::InstrumentingAgents::reset):
+        * inspector/agents/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::mainFrameStartedLoading):
+        (WebCore::InspectorTimelineAgent::startProgrammaticCapture):
+        (WebCore::InspectorTimelineAgent::stopProgrammaticCapture):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):
+        (WebCore::InspectorInstrumentation::isDebuggerPausedImpl):
+        (WebCore::InspectorInstrumentation::didInstallTimerImpl):
+        (WebCore::InspectorInstrumentation::didRemoveTimerImpl):
+        (WebCore::InspectorInstrumentation::didAddEventListenerImpl):
+        (WebCore::InspectorInstrumentation::willRemoveEventListenerImpl):
+        (WebCore::InspectorInstrumentation::didPostMessageImpl):
+        (WebCore::InspectorInstrumentation::didFailPostMessageImpl):
+        (WebCore::InspectorInstrumentation::willDispatchPostMessageImpl):
+        (WebCore::InspectorInstrumentation::didDispatchPostMessageImpl):
+        (WebCore::InspectorInstrumentation::willHandleEventImpl):
+        (WebCore::InspectorInstrumentation::didHandleEventImpl):
+        (WebCore::InspectorInstrumentation::willFireTimerImpl):
+        (WebCore::InspectorInstrumentation::didFireTimerImpl):
+        (WebCore::InspectorInstrumentation::scriptExecutionBlockedByCSPImpl):
+        (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+        (WebCore::InspectorInstrumentation::frameStartedLoadingImpl):
+        (WebCore::InspectorInstrumentation::frameStoppedLoadingImpl):
+        (WebCore::InspectorInstrumentation::addMessageToConsoleImpl):
+        (WebCore::InspectorInstrumentation::didRequestAnimationFrameImpl):
+        (WebCore::InspectorInstrumentation::didCancelAnimationFrameImpl):
+        (WebCore::InspectorInstrumentation::willFireAnimationFrameImpl):
+        (WebCore::InspectorInstrumentation::didFireAnimationFrameImpl):
+        Replace `inspectorDebuggerAgent` with `webDebuggerAgent` so the right instrumentation hooks
+        are available.
+
 2019-08-29  Chris Dumez  <cdu...@apple.com>
 
         Add "IsolatedCopy" in the name of String getters that call isolatedCopy() on the string

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (249314 => 249315)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2019-08-30 06:56:06 UTC (rev 249315)
@@ -63,6 +63,7 @@
 #include "ScriptController.h"
 #include "ScriptExecutionContext.h"
 #include "WebConsoleAgent.h"
+#include "WebDebuggerAgent.h"
 #include "WebGLRenderingContextBase.h"
 #include "WebSocketFrame.h"
 #include <_javascript_Core/ConsoleMessage.h>
@@ -110,9 +111,9 @@
 
 void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world)
 {
-    if (PageDebuggerAgent* debuggerAgent = instrumentingAgents.pageDebuggerAgent()) {
+    if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent()) {
         if (&world == &mainThreadNormalWorld() && frame.isMainFrame())
-            debuggerAgent->didClearMainFrameWindowObject();
+            pageDebuggerAgent->didClearMainFrameWindowObject();
     }
 
     if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent()) {
@@ -123,8 +124,8 @@
 
 bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents& instrumentingAgents)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
-        return debuggerAgent->isPaused();
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        return webDebuggerAgent->isPaused();
     return false;
 }
 
@@ -313,8 +314,8 @@
 
 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext& context)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
-        debuggerAgent->didScheduleAsyncCall(context.execState(), InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId, singleShot);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didScheduleAsyncCall(context.execState(), InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId, singleShot);
 
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent())
         timelineAgent->didInstallTimer(timerId, timeout, singleShot, frameForScriptExecutionContext(context));
@@ -322,8 +323,8 @@
 
 void InspectorInstrumentation::didRemoveTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, ScriptExecutionContext& context)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
-        debuggerAgent->didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId);
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent())
         timelineAgent->didRemoveTimer(timerId, frameForScriptExecutionContext(context));
 }
@@ -330,8 +331,8 @@
 
 void InspectorInstrumentation::didAddEventListenerImpl(InstrumentingAgents& instrumentingAgents, EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->didAddEventListener(target, eventType, listener, capture);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didAddEventListener(target, eventType, listener, capture);
     if (InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent())
         domAgent->didAddEventListener(target);
 }
@@ -338,8 +339,8 @@
 
 void InspectorInstrumentation::willRemoveEventListenerImpl(InstrumentingAgents& instrumentingAgents, EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->willRemoveEventListener(target, eventType, listener, capture);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->willRemoveEventListener(target, eventType, listener, capture);
     if (InspectorDOMAgent* domAgent = instrumentingAgents.inspectorDOMAgent())
         domAgent->willRemoveEventListener(target, eventType, listener, capture);
 }
@@ -353,26 +354,26 @@
 
 void InspectorInstrumentation::didPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer, JSC::ExecState& state)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->didPostMessage(timer, state);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didPostMessage(timer, state);
 }
 
 void InspectorInstrumentation::didFailPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->didFailPostMessage(timer);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didFailPostMessage(timer);
 }
 
 void InspectorInstrumentation::willDispatchPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->willDispatchPostMessage(timer);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->willDispatchPostMessage(timer);
 }
 
 void InspectorInstrumentation::didDispatchPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->didDispatchPostMessage(timer);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didDispatchPostMessage(timer);
 }
 
 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InstrumentingAgents& instrumentingAgents, const String& scriptName, int scriptLine, int scriptColumn, ScriptExecutionContext* context)
@@ -405,8 +406,8 @@
 
 void InspectorInstrumentation::willHandleEventImpl(InstrumentingAgents& instrumentingAgents, Event& event, const RegisteredEventListener& listener)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
-        pageDebuggerAgent->willHandleEvent(listener);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->willHandleEvent(listener);
 
     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents.inspectorDOMDebuggerAgent())
         domDebuggerAgent->willHandleEvent(event, listener);
@@ -414,8 +415,8 @@
 
 void InspectorInstrumentation::didHandleEventImpl(InstrumentingAgents& instrumentingAgents)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
-        debuggerAgent->didDispatchAsyncCall();
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->didDispatchAsyncCall();
 
     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents.inspectorDOMDebuggerAgent())
         domDebuggerAgent->didHandleEvent();
@@ -469,8 +470,8 @@
 
 InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, bool oneShot, ScriptExecutionContext& context)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
-        debuggerAgent->willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId);
 
     if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents.inspectorDOMDebuggerAgent())
         domDebuggerAgent->willFireTimer(oneShot);
@@ -485,8 +486,8 @@
 
 void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCookie& cookie)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = cookie.instrumentingAgents()->inspectorDebuggerAgent())
-        debuggerAgent->didDispatchAsyncCall();
+    if (auto* webDebuggerAgent = cookie.instrumentingAgents()->webDebuggerAgent())
+        webDebuggerAgent->didDispatchAsyncCall();
     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
         timelineAgent->didFireTimer();
 }
@@ -671,8 +672,8 @@
 
 void InspectorInstrumentation::scriptExecutionBlockedByCSPImpl(InstrumentingAgents& instrumentingAgents, const String& directiveText)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
-        debuggerAgent->scriptExecutionBlockedByCSP(directiveText);
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent())
+        webDebuggerAgent->scriptExecutionBlockedByCSP(directiveText);
 }
 
 void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier)
@@ -737,7 +738,7 @@
         if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents.inspectorLayerTreeAgent())
             layerTreeAgent->reset();
 
-        if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+        if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
             pageDebuggerAgent->mainFrameNavigated();
 
         if (PageHeapAgent* pageHeapAgent = instrumentingAgents.pageHeapAgent())
@@ -777,7 +778,7 @@
 void InspectorInstrumentation::frameStartedLoadingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 {
     if (frame.isMainFrame()) {
-        if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+        if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
             pageDebuggerAgent->mainFrameStartedLoading();
         if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
             timelineAgent->mainFrameStartedLoading();
@@ -790,7 +791,7 @@
 void InspectorInstrumentation::frameStoppedLoadingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
 {
     if (frame.isMainFrame()) {
-        if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+        if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
             pageDebuggerAgent->mainFrameStoppedLoading();
     }
 
@@ -845,9 +846,9 @@
     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
         consoleAgent->addMessageToConsole(WTFMove(message));
     // FIXME: This should just pass the message on to the debugger agent. _javascript_Core InspectorDebuggerAgent should know Console MessageTypes.
-    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent()) {
+    if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) {
         if (isConsoleAssertMessage(source, type))
-            debuggerAgent->handleConsoleAssert(messageText);
+            webDebuggerAgent->handleConsoleAssert(messageText);
     }
 }
 
@@ -1122,7 +1123,7 @@
 
 void InspectorInstrumentation::didRequestAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Document& document)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+    if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
         pageDebuggerAgent->didRequestAnimationFrame(callbackId, document);
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent())
         timelineAgent->didRequestAnimationFrame(callbackId, document.frame());
@@ -1130,7 +1131,7 @@
 
 void InspectorInstrumentation::didCancelAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Document& document)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+    if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
         pageDebuggerAgent->didCancelAnimationFrame(callbackId);
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.trackingInspectorTimelineAgent())
         timelineAgent->didCancelAnimationFrame(callbackId, document.frame());
@@ -1138,7 +1139,7 @@
 
 InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Document& document)
 {
-    if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+    if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
         pageDebuggerAgent->willFireAnimationFrame(callbackId);
 
     if (auto* pageDOMDebuggerAgent = instrumentingAgents.pageDOMDebuggerAgent())
@@ -1154,8 +1155,8 @@
 
 void InspectorInstrumentation::didFireAnimationFrameImpl(const InspectorInstrumentationCookie& cookie)
 {
-    if (InspectorDebuggerAgent* debuggerAgent = cookie.instrumentingAgents()->inspectorDebuggerAgent())
-        debuggerAgent->didDispatchAsyncCall();
+    if (auto* webDebuggerAgent = cookie.instrumentingAgents()->webDebuggerAgent())
+        webDebuggerAgent->didDispatchAsyncCall();
     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
         timelineAgent->didFireAnimationFrame();
 }

Modified: trunk/Source/WebCore/inspector/InstrumentingAgents.cpp (249314 => 249315)


--- trunk/Source/WebCore/inspector/InstrumentingAgents.cpp	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/InstrumentingAgents.cpp	2019-08-30 06:56:06 UTC (rev 249315)
@@ -63,7 +63,7 @@
 #endif
     m_inspectorDatabaseAgent = nullptr;
     m_inspectorApplicationCacheAgent = nullptr;
-    m_inspectorDebuggerAgent = nullptr;
+    m_webDebuggerAgent = nullptr;
     m_pageDebuggerAgent = nullptr;
     m_pageHeapAgent = nullptr;
     m_inspectorDOMDebuggerAgent = nullptr;

Modified: trunk/Source/WebCore/inspector/InstrumentingAgents.h (249314 => 249315)


--- trunk/Source/WebCore/inspector/InstrumentingAgents.h	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/InstrumentingAgents.h	2019-08-30 06:56:06 UTC (rev 249315)
@@ -64,6 +64,7 @@
 class PageHeapAgent;
 class PageRuntimeAgent;
 class WebConsoleAgent;
+class WebDebuggerAgent;
 
 class InstrumentingAgents : public RefCounted<InstrumentingAgents> {
     WTF_MAKE_NONCOPYABLE(InstrumentingAgents);
@@ -130,8 +131,8 @@
     InspectorApplicationCacheAgent* inspectorApplicationCacheAgent() const { return m_inspectorApplicationCacheAgent; }
     void setInspectorApplicationCacheAgent(InspectorApplicationCacheAgent* agent) { m_inspectorApplicationCacheAgent = agent; }
 
-    Inspector::InspectorDebuggerAgent* inspectorDebuggerAgent() const { return m_inspectorDebuggerAgent; }
-    void setInspectorDebuggerAgent(Inspector::InspectorDebuggerAgent* agent) { m_inspectorDebuggerAgent = agent; }
+    WebDebuggerAgent* webDebuggerAgent() const { return m_webDebuggerAgent; }
+    void setWebDebuggerAgent(WebDebuggerAgent* agent) { m_webDebuggerAgent = agent; }
 
     PageDebuggerAgent* pageDebuggerAgent() const { return m_pageDebuggerAgent; }
     void setPageDebuggerAgent(PageDebuggerAgent* agent) { m_pageDebuggerAgent = agent; }
@@ -175,7 +176,7 @@
 #endif
     InspectorDatabaseAgent* m_inspectorDatabaseAgent { nullptr };
     InspectorApplicationCacheAgent* m_inspectorApplicationCacheAgent { nullptr };
-    Inspector::InspectorDebuggerAgent* m_inspectorDebuggerAgent { nullptr };
+    WebDebuggerAgent* m_webDebuggerAgent { nullptr };
     PageDebuggerAgent* m_pageDebuggerAgent { nullptr };
     PageHeapAgent* m_pageHeapAgent { nullptr };
     InspectorDOMDebuggerAgent* m_inspectorDOMDebuggerAgent { nullptr };

Modified: trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp (249314 => 249315)


--- trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp	2019-08-30 06:56:06 UTC (rev 249315)
@@ -49,8 +49,8 @@
 #include "ScriptState.h"
 #include "TimelineRecordFactory.h"
 #include "WebConsoleAgent.h"
+#include "WebDebuggerAgent.h"
 #include <_javascript_Core/ConsoleMessage.h>
-#include <_javascript_Core/InspectorDebuggerAgent.h>
 #include <_javascript_Core/InspectorScriptProfilerAgent.h>
 #include <_javascript_Core/ScriptBreakpoint.h>
 #include <wtf/Stopwatch.h>
@@ -472,9 +472,9 @@
     m_autoCapturePhase = AutoCapturePhase::BeforeLoad;
 
     // Pre-emptively disable breakpoints. The frontend must re-enable them.
-    if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents.inspectorDebuggerAgent()) {
+    if (auto* webDebuggerAgent = m_instrumentingAgents.webDebuggerAgent()) {
         ErrorString ignored;
-        debuggerAgent->setBreakpointsActive(ignored, false);
+        webDebuggerAgent->setBreakpointsActive(ignored, false);
     }
 
     // Inform the frontend we started an auto capture. The frontend must stop capture.
@@ -497,11 +497,11 @@
     ASSERT(!m_tracking);
 
     // Disable breakpoints during programmatic capture.
-    if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents.inspectorDebuggerAgent()) {
-        m_programmaticCaptureRestoreBreakpointActiveValue = debuggerAgent->breakpointsActive();
+    if (auto* webDebuggerAgent = m_instrumentingAgents.webDebuggerAgent()) {
+        m_programmaticCaptureRestoreBreakpointActiveValue = webDebuggerAgent->breakpointsActive();
         if (m_programmaticCaptureRestoreBreakpointActiveValue) {
             ErrorString ignored;
-            debuggerAgent->setBreakpointsActive(ignored, false);
+            webDebuggerAgent->setBreakpointsActive(ignored, false);
         }
     } else
         m_programmaticCaptureRestoreBreakpointActiveValue = false;
@@ -522,9 +522,9 @@
 
     // Re-enable breakpoints if they were enabled.
     if (m_programmaticCaptureRestoreBreakpointActiveValue) {
-        if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents.inspectorDebuggerAgent()) {
+        if (auto* webDebuggerAgent = m_instrumentingAgents.webDebuggerAgent()) {
             ErrorString ignored;
-            debuggerAgent->setBreakpointsActive(ignored, true);
+            webDebuggerAgent->setBreakpointsActive(ignored, true);
         }
     }
 }

Modified: trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp (249314 => 249315)


--- trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp	2019-08-30 06:56:06 UTC (rev 249315)
@@ -26,9 +26,11 @@
 #include "config.h"
 #include "WebDebuggerAgent.h"
 
+#include "EventListener.h"
+#include "EventTarget.h"
 #include "InstrumentingAgents.h"
+#include "Timer.h"
 
-
 namespace WebCore {
 
 using namespace Inspector;
@@ -41,16 +43,125 @@
 
 WebDebuggerAgent::~WebDebuggerAgent() = default;
 
+bool WebDebuggerAgent::enabled() const
+{
+    return m_instrumentingAgents.webDebuggerAgent() == this && InspectorDebuggerAgent::enabled();
+}
+
 void WebDebuggerAgent::enable()
 {
+    m_instrumentingAgents.setWebDebuggerAgent(this);
+
     InspectorDebuggerAgent::enable();
-    m_instrumentingAgents.setInspectorDebuggerAgent(this);
 }
 
 void WebDebuggerAgent::disable(bool isBeingDestroyed)
 {
-    m_instrumentingAgents.setInspectorDebuggerAgent(nullptr);
+    m_instrumentingAgents.setWebDebuggerAgent(nullptr);
+
     InspectorDebuggerAgent::disable(isBeingDestroyed);
 }
 
+void WebDebuggerAgent::didAddEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
+{
+    if (!breakpointsActive())
+        return;
+
+    auto& eventListeners = target.eventListeners(eventType);
+    auto position = eventListeners.findMatching([&](auto& registeredListener) {
+        return &registeredListener->callback() == &listener && registeredListener->useCapture() == capture;
+    });
+    if (position == notFound)
+        return;
+
+    auto& registeredListener = eventListeners.at(position);
+    if (m_registeredEventListeners.contains(registeredListener.get()))
+        return;
+
+    JSC::ExecState* scriptState = target.scriptExecutionContext()->execState();
+    if (!scriptState)
+        return;
+
+    int identifier = m_nextEventListenerIdentifier++;
+    m_registeredEventListeners.set(registeredListener.get(), identifier);
+
+    didScheduleAsyncCall(scriptState, InspectorDebuggerAgent::AsyncCallType::EventListener, identifier, registeredListener->isOnce());
+}
+
+void WebDebuggerAgent::willRemoveEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
+{
+    auto& eventListeners = target.eventListeners(eventType);
+    size_t listenerIndex = eventListeners.findMatching([&](auto& registeredListener) {
+        return &registeredListener->callback() == &listener && registeredListener->useCapture() == capture;
+    });
+
+    if (listenerIndex == notFound)
+        return;
+
+    int identifier = m_registeredEventListeners.take(eventListeners[listenerIndex].get());
+    didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::EventListener, identifier);
+}
+
+void WebDebuggerAgent::willHandleEvent(const RegisteredEventListener& listener)
+{
+    auto it = m_registeredEventListeners.find(&listener);
+    if (it == m_registeredEventListeners.end())
+        return;
+
+    willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::EventListener, it->value);
+}
+
+void WebDebuggerAgent::didPostMessage(const TimerBase& timer, JSC::ExecState& state)
+{
+    if (!breakpointsActive())
+        return;
+
+    if (m_postMessageTimers.contains(&timer))
+        return;
+
+    int postMessageIdentifier = m_nextPostMessageIdentifier++;
+    m_postMessageTimers.set(&timer, postMessageIdentifier);
+
+    didScheduleAsyncCall(&state, InspectorDebuggerAgent::AsyncCallType::PostMessage, postMessageIdentifier, true);
+}
+
+void WebDebuggerAgent::didFailPostMessage(const TimerBase& timer)
+{
+    auto it = m_postMessageTimers.find(&timer);
+    if (it == m_postMessageTimers.end())
+        return;
+
+    didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, it->value);
+
+    m_postMessageTimers.remove(it);
+}
+
+void WebDebuggerAgent::willDispatchPostMessage(const TimerBase& timer)
+{
+    auto it = m_postMessageTimers.find(&timer);
+    if (it == m_postMessageTimers.end())
+        return;
+
+    willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, it->value);
+}
+
+void WebDebuggerAgent::didDispatchPostMessage(const TimerBase& timer)
+{
+    auto it = m_postMessageTimers.find(&timer);
+    if (it == m_postMessageTimers.end())
+        return;
+
+    didDispatchAsyncCall();
+
+    m_postMessageTimers.remove(it);
+}
+
+void WebDebuggerAgent::didClearAsyncStackTraceData()
+{
+    m_registeredEventListeners.clear();
+    m_postMessageTimers.clear();
+    m_nextEventListenerIdentifier = 1;
+    m_nextPostMessageIdentifier = 1;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.h (249314 => 249315)


--- trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.h	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.h	2019-08-30 06:56:06 UTC (rev 249315)
@@ -30,7 +30,11 @@
 
 namespace WebCore {
 
+class EventListener;
+class EventTarget;
 class InstrumentingAgents;
+class RegisteredEventListener;
+class TimerBase;
 typedef String ErrorString;
 
 class WebDebuggerAgent : public Inspector::InspectorDebuggerAgent {
@@ -38,14 +42,31 @@
     WTF_MAKE_FAST_ALLOCATED;
 public:
     virtual ~WebDebuggerAgent();
+    bool enabled() const override;
 
+    // InspectorInstrumentation
+    void didAddEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
+    void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
+    void willHandleEvent(const RegisteredEventListener&);
+    void didPostMessage(const TimerBase&, JSC::ExecState&);
+    void didFailPostMessage(const TimerBase&);
+    void willDispatchPostMessage(const TimerBase&);
+    void didDispatchPostMessage(const TimerBase&);
+
 protected:
     WebDebuggerAgent(WebAgentContext&);
-
     void enable() override;
     void disable(bool isBeingDestroyed) override;
 
+    void didClearAsyncStackTraceData() final;
+
     InstrumentingAgents& m_instrumentingAgents;
+
+private:
+    HashMap<const RegisteredEventListener*, int> m_registeredEventListeners;
+    HashMap<const TimerBase*, int> m_postMessageTimers;
+    int m_nextEventListenerIdentifier { 1 };
+    int m_nextPostMessageIdentifier { 1 };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp (249314 => 249315)


--- trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp	2019-08-30 06:56:06 UTC (rev 249315)
@@ -36,8 +36,6 @@
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "Document.h"
-#include "EventListener.h"
-#include "EventTarget.h"
 #include "Frame.h"
 #include "InspectorPageAgent.h"
 #include "InstrumentingAgents.h"
@@ -46,7 +44,6 @@
 #include "PageScriptDebugServer.h"
 #include "ScriptExecutionContext.h"
 #include "ScriptState.h"
-#include "Timer.h"
 #include "UserGestureIndicator.h"
 #include <_javascript_Core/InjectedScript.h>
 #include <_javascript_Core/InjectedScriptManager.h>
@@ -67,6 +64,11 @@
 
 PageDebuggerAgent::~PageDebuggerAgent() = default;
 
+bool PageDebuggerAgent::enabled() const
+{
+    return m_instrumentingAgents.pageDebuggerAgent() == this && WebDebuggerAgent::enabled();
+}
+
 void PageDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& _expression_, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
 {
     auto& pageChromeClient = m_inspectedPage.chrome().client();
@@ -91,14 +93,16 @@
 
 void PageDebuggerAgent::enable()
 {
+    m_instrumentingAgents.setPageDebuggerAgent(this);
+
     WebDebuggerAgent::enable();
-    m_instrumentingAgents.setPageDebuggerAgent(this);
 }
 
 void PageDebuggerAgent::disable(bool isBeingDestroyed)
 {
+    m_instrumentingAgents.setPageDebuggerAgent(nullptr);
+
     WebDebuggerAgent::disable(isBeingDestroyed);
-    m_instrumentingAgents.setPageDebuggerAgent(nullptr);
 }
 
 String PageDebuggerAgent::sourceMapURLForScript(const Script& script)
@@ -122,14 +126,6 @@
     return InspectorDebuggerAgent::sourceMapURLForScript(script);
 }
 
-void PageDebuggerAgent::didClearAsyncStackTraceData()
-{
-    m_registeredEventListeners.clear();
-    m_postMessageTimers.clear();
-    m_nextEventListenerIdentifier = 1;
-    m_nextPostMessageIdentifier = 1;
-}
-
 void PageDebuggerAgent::muteConsole()
 {
     PageConsoleClient::mute();
@@ -184,55 +180,6 @@
     setSuppressAllPauses(false);
 }
 
-void PageDebuggerAgent::didAddEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
-{
-    if (!breakpointsActive())
-        return;
-
-    auto& eventListeners = target.eventListeners(eventType);
-    auto position = eventListeners.findMatching([&](auto& registeredListener) {
-        return &registeredListener->callback() == &listener && registeredListener->useCapture() == capture;
-    });
-    if (position == notFound)
-        return;
-
-    auto& registeredListener = eventListeners.at(position);
-    if (m_registeredEventListeners.contains(registeredListener.get()))
-        return;
-
-    JSC::ExecState* scriptState = target.scriptExecutionContext()->execState();
-    if (!scriptState)
-        return;
-
-    int identifier = m_nextEventListenerIdentifier++;
-    m_registeredEventListeners.set(registeredListener.get(), identifier);
-
-    didScheduleAsyncCall(scriptState, InspectorDebuggerAgent::AsyncCallType::EventListener, identifier, registeredListener->isOnce());
-}
-
-void PageDebuggerAgent::willRemoveEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
-{
-    auto& eventListeners = target.eventListeners(eventType);
-    size_t listenerIndex = eventListeners.findMatching([&](auto& registeredListener) {
-        return &registeredListener->callback() == &listener && registeredListener->useCapture() == capture;
-    });
-
-    if (listenerIndex == notFound)
-        return;
-
-    int identifier = m_registeredEventListeners.take(eventListeners[listenerIndex].get());
-    didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::EventListener, identifier);
-}
-
-void PageDebuggerAgent::willHandleEvent(const RegisteredEventListener& listener)
-{
-    auto it = m_registeredEventListeners.find(&listener);
-    if (it == m_registeredEventListeners.end())
-        return;
-
-    willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::EventListener, it->value);
-}
-
 void PageDebuggerAgent::didRequestAnimationFrame(int callbackId, Document& document)
 {
     if (!breakpointsActive())
@@ -255,49 +202,4 @@
     didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::RequestAnimationFrame, callbackId);
 }
 
-void PageDebuggerAgent::didPostMessage(const TimerBase& timer, JSC::ExecState& state)
-{
-    if (!breakpointsActive())
-        return;
-
-    if (m_postMessageTimers.contains(&timer))
-        return;
-
-    int postMessageIdentifier = m_nextPostMessageIdentifier++;
-    m_postMessageTimers.set(&timer, postMessageIdentifier);
-
-    didScheduleAsyncCall(&state, InspectorDebuggerAgent::AsyncCallType::PostMessage, postMessageIdentifier, true);
-}
-
-void PageDebuggerAgent::didFailPostMessage(const TimerBase& timer)
-{
-    auto it = m_postMessageTimers.find(&timer);
-    if (it == m_postMessageTimers.end())
-        return;
-
-    didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, it->value);
-
-    m_postMessageTimers.remove(it);
-}
-
-void PageDebuggerAgent::willDispatchPostMessage(const TimerBase& timer)
-{
-    auto it = m_postMessageTimers.find(&timer);
-    if (it == m_postMessageTimers.end())
-        return;
-
-    willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, it->value);
-}
-
-void PageDebuggerAgent::didDispatchPostMessage(const TimerBase& timer)
-{
-    auto it = m_postMessageTimers.find(&timer);
-    if (it == m_postMessageTimers.end())
-        return;
-
-    didDispatchAsyncCall();
-
-    m_postMessageTimers.remove(it);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h (249314 => 249315)


--- trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h	2019-08-30 05:00:15 UTC (rev 249314)
+++ trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h	2019-08-30 06:56:06 UTC (rev 249315)
@@ -36,11 +36,7 @@
 namespace WebCore {
 
 class Document;
-class EventListener;
-class EventTarget;
 class Page;
-class RegisteredEventListener;
-class TimerBase;
 
 class PageDebuggerAgent final : public WebDebuggerAgent {
     WTF_MAKE_NONCOPYABLE(PageDebuggerAgent);
@@ -48,6 +44,7 @@
 public:
     PageDebuggerAgent(PageAgentContext&);
     virtual ~PageDebuggerAgent();
+    bool enabled() const final;
 
     // DebuggerBackendDispatcherHandler
     void evaluateOnCallFrame(ErrorString&, const String& callFrameId, const String& _expression_, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex);
@@ -63,13 +60,6 @@
     void didRequestAnimationFrame(int callbackId, Document&);
     void willFireAnimationFrame(int callbackId);
     void didCancelAnimationFrame(int callbackId);
-    void didAddEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
-    void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
-    void willHandleEvent(const RegisteredEventListener&);
-    void didPostMessage(const TimerBase&, JSC::ExecState&);
-    void didFailPostMessage(const TimerBase&);
-    void willDispatchPostMessage(const TimerBase&);
-    void didDispatchPostMessage(const TimerBase&);
 
 private:
     void enable();
@@ -77,8 +67,6 @@
 
     String sourceMapURLForScript(const Script&);
 
-    void didClearAsyncStackTraceData();
-
     void muteConsole();
     void unmuteConsole();
 
@@ -85,11 +73,6 @@
     Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId);
 
     Page& m_inspectedPage;
-
-    HashMap<const RegisteredEventListener*, int> m_registeredEventListeners;
-    HashMap<const TimerBase*, int> m_postMessageTimers;
-    int m_nextEventListenerIdentifier { 1 };
-    int m_nextPostMessageIdentifier { 1 };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to