WebKit Bugzilla
Attachment 347302 Details for
Bug 188672
: Web Inspector: Provide $event in the console when paused on an event listener
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
188672.diff (text/plain), 16.99 KB, created by
Devin Rousso
on 2018-08-16 13:59:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2018-08-16 13:59:52 PDT
Size:
16.99 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 52f54157991..ebd45c854e3 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-16 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Provide $event in the console when paused on an event listener >+ https://bugs.webkit.org/show_bug.cgi?id=188672 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/InjectedScript.h: >+ * inspector/InjectedScript.cpp: >+ (Inspector::InjectedScript::setEventValue): Added. >+ (Inspector::InjectedScript::clearEventValue): Added. >+ >+ * inspector/InjectedScriptManager.h: >+ * inspector/InjectedScriptManager.cpp: >+ (Inspector::InjectedScriptManager::clearEventValue): Added. >+ >+ * inspector/InjectedScriptSource.js: >+ (WI.InjectedScript.prototype.setEventValue): Added. >+ (WI.InjectedScript.prototype.clearEventValue): Added. >+ (BasicCommandLineAPI): >+ > 2018-08-16 Devin Rousso <drousso@apple.com> > > Web Inspector: allow breakpoints to be set for specific event listeners >diff --git a/Source/JavaScriptCore/inspector/InjectedScript.cpp b/Source/JavaScriptCore/inspector/InjectedScript.cpp >index 2c9a4b2f4c3..f4be2f6a264 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScript.cpp >+++ b/Source/JavaScriptCore/inspector/InjectedScript.cpp >@@ -321,6 +321,21 @@ RefPtr<Protocol::Runtime::ObjectPreview> InjectedScript::previewValue(JSC::JSVal > return BindingTraits<Protocol::Runtime::ObjectPreview>::runtimeCast(resultObject); > } > >+void InjectedScript::setEventValue(JSC::JSValue value) >+{ >+ ASSERT(!hasNoValue()); >+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), "setEventValue"_s, inspectorEnvironment()->functionCallHandler()); >+ function.appendArgument(value); >+ makeCall(function); >+} >+ >+void InjectedScript::clearEventValue() >+{ >+ ASSERT(!hasNoValue()); >+ Deprecated::ScriptFunctionCall function(injectedScriptObject(), "clearEventValue"_s, inspectorEnvironment()->functionCallHandler()); >+ makeCall(function); >+} >+ > void InjectedScript::setExceptionValue(JSC::JSValue value) > { > ASSERT(!hasNoValue()); >diff --git a/Source/JavaScriptCore/inspector/InjectedScript.h b/Source/JavaScriptCore/inspector/InjectedScript.h >index 6d32b97cbfe..13dc310df05 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScript.h >+++ b/Source/JavaScriptCore/inspector/InjectedScript.h >@@ -68,6 +68,9 @@ public: > RefPtr<Protocol::Runtime::RemoteObject> wrapTable(JSC::JSValue table, JSC::JSValue columns) const; > RefPtr<Protocol::Runtime::ObjectPreview> previewValue(JSC::JSValue) const; > >+ void setEventValue(JSC::JSValue); >+ void clearEventValue(); >+ > void setExceptionValue(JSC::JSValue); > void clearExceptionValue(); > >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp >index b4c6c18e433..e50f7b42223 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp >+++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp >@@ -122,6 +122,12 @@ void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) > injectedScript.releaseObjectGroup(objectGroup); > } > >+void InjectedScriptManager::clearEventValue() >+{ >+ for (auto& injectedScript : m_idToInjectedScript.values()) >+ injectedScript.clearEventValue(); >+} >+ > void InjectedScriptManager::clearExceptionValue() > { > for (auto& injectedScript : m_idToInjectedScript.values()) >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.h b/Source/JavaScriptCore/inspector/InjectedScriptManager.h >index ceb8c0233fc..ea48fa9301c 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptManager.h >+++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.h >@@ -60,6 +60,7 @@ public: > int injectedScriptIdFor(JSC::ExecState*); > InjectedScript injectedScriptForObjectId(const String& objectId); > void releaseObjectGroup(const String& objectGroup); >+ void clearEventValue(); > void clearExceptionValue(); > > protected: >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptSource.js b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >index d6b75f1fecd..8083e539777 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptSource.js >+++ b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >@@ -306,6 +306,16 @@ let InjectedScript = class InjectedScript > return RemoteObject.createObjectPreviewForValue(value, true); > } > >+ setEventValue(value) >+ { >+ this._eventValue = value; >+ } >+ >+ clearEventValue() >+ { >+ delete this._eventValue; >+ } >+ > setExceptionValue(value) > { > this._exceptionValue = value; >@@ -1383,6 +1393,7 @@ function bind(func, thisObject, ...outerArgs) > function BasicCommandLineAPI(callFrame) > { > this.$_ = injectedScript._lastResult; >+ this.$event = injectedScript._eventValue; > this.$exception = injectedScript._exceptionValue; > > // $1-$99 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 43684c00f5c..d91bbe0ff8d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2018-08-16 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Provide $event in the console when paused on an event listener >+ https://bugs.webkit.org/show_bug.cgi?id=188672 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * inspector/CommandLineAPIModuleSource.js: >+ (CommandLineAPI): >+ >+ * inspector/InspectorInstrumentation.h: >+ (WebCore::InspectorInstrumentation::willHandleEvent): >+ * inspector/InspectorInstrumentation.cpp: >+ (WebCore::InspectorInstrumentation::willHandleEventImpl): >+ (WebCore::InspectorInstrumentation::didHandleEventImpl): >+ >+ * inspector/agents/InspectorDOMDebuggerAgent.cpp: >+ * inspector/agents/InspectorDOMDebuggerAgent.h: >+ (WebCore::InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent): >+ (WebCore::InspectorDOMDebuggerAgent::willHandleEvent): >+ (WebCore::InspectorDOMDebuggerAgent::didHandleEvent): Added. >+ > 2018-08-16 Devin Rousso <drousso@apple.com> > > Web Inspector: allow breakpoints to be set for specific event listeners >diff --git a/Source/WebCore/inspector/CommandLineAPIModuleSource.js b/Source/WebCore/inspector/CommandLineAPIModuleSource.js >index 7cf4fcdaaaa..4d69e132875 100644 >--- a/Source/WebCore/inspector/CommandLineAPIModuleSource.js >+++ b/Source/WebCore/inspector/CommandLineAPIModuleSource.js >@@ -47,6 +47,7 @@ function bind(func, thisObject, ...outerArgs) > function CommandLineAPI(commandLineAPIImpl, callFrame) > { > this.$_ = injectedScript._lastResult; >+ this.$event = injectedScript._eventValue; > this.$exception = injectedScript._exceptionValue; > > // $0 >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp >index 41b7877161f..b6f9f406b00 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp >+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp >@@ -388,7 +388,7 @@ InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(I > return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId); > } > >-void InspectorInstrumentation::willHandleEventImpl(InstrumentingAgents& instrumentingAgents, const Event& event, const RegisteredEventListener& listener) >+void InspectorInstrumentation::willHandleEventImpl(InstrumentingAgents& instrumentingAgents, Event& event, const RegisteredEventListener& listener) > { > if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent()) > pageDebuggerAgent->willHandleEvent(listener); >@@ -401,6 +401,9 @@ void InspectorInstrumentation::didHandleEventImpl(InstrumentingAgents& instrumen > { > if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent()) > debuggerAgent->didDispatchAsyncCall(); >+ >+ if (InspectorDOMDebuggerAgent* domDebuggerAgent = instrumentingAgents.inspectorDOMDebuggerAgent()) >+ domDebuggerAgent->didHandleEvent(); > } > > void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie) >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h >index 622fc560207..9991047828d 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.h >+++ b/Source/WebCore/inspector/InspectorInstrumentation.h >@@ -151,7 +151,7 @@ public: > static bool isEventListenerDisabled(EventTarget&, const AtomicString& eventType, EventListener&, bool capture); > static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners); > static void didDispatchEvent(const InspectorInstrumentationCookie&); >- static void willHandleEvent(ScriptExecutionContext&, const Event&, const RegisteredEventListener&); >+ static void willHandleEvent(ScriptExecutionContext&, Event&, const RegisteredEventListener&); > static void didHandleEvent(ScriptExecutionContext&); > static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&); > static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&); >@@ -334,7 +334,7 @@ private: > static void willRemoveEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomicString& eventType, EventListener&, bool capture); > static bool isEventListenerDisabledImpl(InstrumentingAgents&, EventTarget&, const AtomicString& eventType, EventListener&, bool capture); > static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners); >- static void willHandleEventImpl(InstrumentingAgents&, const Event&, const RegisteredEventListener&); >+ static void willHandleEventImpl(InstrumentingAgents&, Event&, const RegisteredEventListener&); > static void didHandleEventImpl(InstrumentingAgents&); > static void didDispatchEventImpl(const InspectorInstrumentationCookie&); > static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&); >@@ -763,7 +763,7 @@ inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrument > didDispatchEventImpl(cookie); > } > >-inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, const Event& event, const RegisteredEventListener& listener) >+inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, Event& event, const RegisteredEventListener& listener) > { > FAST_RETURN_IF_NO_FRONTENDS(void()); > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) >diff --git a/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp b/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp >index 3792cfdc711..177709524a4 100644 >--- a/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp >@@ -37,8 +37,11 @@ > #include "HTMLElement.h" > #include "InspectorDOMAgent.h" > #include "InstrumentingAgents.h" >+#include "JSEvent.h" > #include "RegisteredEventListener.h" > #include <JavaScriptCore/ContentSearchUtilities.h> >+#include <JavaScriptCore/InjectedScript.h> >+#include <JavaScriptCore/InjectedScriptManager.h> > #include <JavaScriptCore/InspectorFrontendDispatchers.h> > #include <JavaScriptCore/RegularExpression.h> > #include <wtf/JSONValues.h> >@@ -68,6 +71,7 @@ using namespace Inspector; > InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent(WebAgentContext& context, InspectorDOMAgent* domAgent, InspectorDebuggerAgent* debuggerAgent) > : InspectorAgentBase("DOMDebugger"_s, context) > , m_backendDispatcher(Inspector::DOMDebuggerBackendDispatcher::create(context.backendDispatcher, this)) >+ , m_injectedScriptManager(context.injectedScriptManager) > , m_domAgent(domAgent) > , m_debuggerAgent(debuggerAgent) > { >@@ -364,13 +368,23 @@ void InspectorDOMDebuggerAgent::updateSubtreeBreakpoints(Node* node, uint32_t ro > updateSubtreeBreakpoints(child, newRootMask, set); > } > >-void InspectorDOMDebuggerAgent::willHandleEvent(const Event& event, const RegisteredEventListener& registeredEventListener) >+void InspectorDOMDebuggerAgent::willHandleEvent(Event& event, const RegisteredEventListener& registeredEventListener) > { > bool shouldPause = m_debuggerAgent->pauseOnNextStatementEnabled() || m_eventListenerBreakpoints.contains(listenerEventCategoryType + event.type()); > > if (!shouldPause && m_domAgent) > shouldPause = m_domAgent->hasBreakpointForEventListener(*event.currentTarget(), event.type(), registeredEventListener.callback(), registeredEventListener.useCapture()); > >+ auto& state = *event.target()->scriptExecutionContext()->execState(); >+ auto injectedScript = m_injectedScriptManager.injectedScriptFor(&state); >+ ASSERT(!injectedScript.hasNoValue()); >+ >+ { >+ JSC::JSLockHolder lock(&state); >+ >+ injectedScript.setEventValue(toJS(&state, deprecatedGlobalObjectForPrototype(&state), event)); >+ } >+ > if (!shouldPause) > return; > >@@ -385,6 +399,11 @@ void InspectorDOMDebuggerAgent::willHandleEvent(const Event& event, const Regist > m_debuggerAgent->schedulePauseOnNextStatement(Inspector::DebuggerFrontendDispatcher::Reason::EventListener, WTFMove(eventData)); > } > >+void InspectorDOMDebuggerAgent::didHandleEvent() >+{ >+ m_injectedScriptManager.clearEventValue(); >+} >+ > void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(const String& eventName, bool synchronous) > { > bool shouldPause = m_debuggerAgent->pauseOnNextStatementEnabled() || m_eventListenerBreakpoints.contains(instrumentationEventCategoryType + eventName); >diff --git a/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.h b/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.h >index 0b306313a69..8e5d48a9250 100644 >--- a/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.h >+++ b/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.h >@@ -38,6 +38,10 @@ > #include <wtf/JSONValues.h> > #include <wtf/text/WTFString.h> > >+namespace Inspector { >+class InjectedScriptManager; >+} >+ > namespace WebCore { > > class Element; >@@ -75,7 +79,8 @@ public: > void willModifyDOMAttr(Element&); > void willSendXMLHttpRequest(const String& url); > void frameDocumentUpdated(Frame&); >- void willHandleEvent(const Event&, const RegisteredEventListener&); >+ void willHandleEvent(Event&, const RegisteredEventListener&); >+ void didHandleEvent(); > void pauseOnNativeEventIfNeeded(const String& eventName, bool synchronous); > void mainFrameDOMContentLoaded(); > >@@ -97,6 +102,7 @@ private: > void removeBreakpoint(ErrorString&, const String& eventName); > > RefPtr<Inspector::DOMDebuggerBackendDispatcher> m_backendDispatcher; >+ Inspector::InjectedScriptManager& m_injectedScriptManager; > InspectorDOMAgent* m_domAgent { nullptr }; > Inspector::InspectorDebuggerAgent* m_debuggerAgent { nullptr }; > >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 5382f4b3f36..e99b91be5bf 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,13 @@ >+2018-08-16 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: Provide $event in the console when paused on an event listener >+ https://bugs.webkit.org/show_bug.cgi?id=188672 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: >+ (WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.receivedPropertyNames): >+ > 2018-08-16 Devin Rousso <drousso@apple.com> > > Web Inspector: allow breakpoints to be set for specific event listeners >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js b/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >index aebd456ca06..8bc51c33ed6 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >@@ -221,7 +221,9 @@ WI.JavaScriptRuntimeCompletionProvider = class JavaScriptRuntimeCompletionProvid > var commandLineAPI = ["$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventListeners", "$0", "$_"]; > if (WI.debuggerManager.paused) { > let targetData = WI.debuggerManager.dataForTarget(WI.runtimeManager.activeExecutionContext.target); >- if (targetData.pauseReason === WI.DebuggerManager.PauseReason.Exception) >+ if (targetData.pauseReason === WI.DebuggerManager.PauseReason.EventListener) >+ commandLineAPI.push("$event"); >+ else if (targetData.pauseReason === WI.DebuggerManager.PauseReason.Exception) > commandLineAPI.push("$exception"); > } > for (var i = 0; i < commandLineAPI.length; ++i)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188672
:
347302
|
365110