Web Inspector: support breakpoints for timers and animation-frame events
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2018 21:36:40 +0000 (21:36 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2018 21:36:40 +0000 (21:36 +0000)
commit58042fa68d328c050f7c4bc3faf739b2ce3fc1dd
treecfe51be422acb07aa4ffe35760a0de3165bbc5df
parentfb464933554bb53a0e0eeaee81e637c531ed33ec
Web Inspector: support breakpoints for timers and animation-frame events
https://bugs.webkit.org/show_bug.cgi?id=188778

Reviewed by Brian Burg.

Source/JavaScriptCore:

* inspector/protocol/Debugger.json:
Add `AnimationFrame` and `Timer` types to the list of pause reasons.

* inspector/protocol/DOMDebugger.json:
Introduced `setEventBreakpoint` and `removeEventBreakpoint` to replace the more specific:
 - `setEventListenerBreakpoint`
 - `removeEventListenerBreakpoint`
 - `setInstrumentationBreakpoint`
 - `removeInstrumentationBreakpoint`
Also created an `EventBreakpointType` to enumerate the available types of event breakpoints.

* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator.generate_output):
(CppProtocolTypesHeaderGenerator._generate_forward_declarations_for_binding_traits):
(CppProtocolTypesHeaderGenerator._generate_declarations_for_enum_conversion_methods):
(CppProtocolTypesHeaderGenerator._generate_hash_declarations): Added.
Generate `DefaultHash` for all `enum class` used by inspector protocols.

* inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/generic/expected/enum-values.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:

Source/WebCore:

The original implementation of "instrumentation" breakpoints relied upon the frontend
sending somewhat arbitrary strings when enabling breakpoints for specific events. As an
example, setting a breakpoint for `requestAnimationFrame` expects `"animationFrameFired"`
as the string, which doesn't make much sense. This patch removes the usage of these strings
and instead expects the agent to implement a method that matches what is happening.

Tests: inspector/dom-debugger/event-animation-frame-breakpoints.html
       inspector/dom-debugger/event-listener-breakpoints.html
       inspector/dom-debugger/event-timer-breakpoints.html

* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willFireTimer):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didInstallTimerImpl):
(WebCore::InspectorInstrumentation::didRemoveTimerImpl):
(WebCore::InspectorInstrumentation::willFireTimerImpl):
(WebCore::InspectorInstrumentation::didRequestAnimationFrameImpl):
(WebCore::InspectorInstrumentation::didCancelAnimationFrameImpl):
(WebCore::InspectorInstrumentation::willFireAnimationFrameImpl):
(WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded): Deleted.

* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
(WebCore::InspectorDOMDebuggerAgent::setEventBreakpoint): Added.
(WebCore::InspectorDOMDebuggerAgent::removeEventBreakpoint): Added.
(WebCore::InspectorDOMDebuggerAgent::willHandleEvent):
(WebCore::InspectorDOMDebuggerAgent::willFireTimer): Added.
(WebCore::InspectorDOMDebuggerAgent::willFireAnimationFrame): Added.
(WebCore::InspectorDOMDebuggerAgent::setEventListenerBreakpoint): Deleted.
(WebCore::InspectorDOMDebuggerAgent::setInstrumentationBreakpoint): Deleted.
(WebCore::InspectorDOMDebuggerAgent::setBreakpoint): Deleted.
(WebCore::InspectorDOMDebuggerAgent::removeEventListenerBreakpoint): Deleted.
(WebCore::InspectorDOMDebuggerAgent::removeInstrumentationBreakpoint): Deleted.
(WebCore::InspectorDOMDebuggerAgent::removeBreakpoint): Deleted.
(WebCore::InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded): Deleted.
Unify the event listener and instrumentation breakpoint commands into a single method,
`setEventBreakpoint`, that takes in both an `EventBreakpointType` and `eventName`.

* page/DOMTimer.cpp:
(WebCore::DOMTimer::fired):

Source/WebInspectorUI:

Add a `type` to `WI.EventBreakpoint` that matches `DOMDebugger.EventBreakpointType`:
 - `AnimationFrame` for `requestAnimationFrame`
 - `Listener` for any named DOM Event
 - `Timer` for `setTimeout` and `setInterval`

Modified `WI.EventBreakpointPopover` to provide ways for selecting these other types, which
is then passed to `WI.DOMDebuggerManager`, which now calls through to the newly added
`DOMDebugger.removeEventBreakpoint` and `DOMDebugger.setEventBreakpoint` that sets
breakpoints for all event types.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Images/EventBreakpointAnimationFrame.svg: Added.
* UserInterface/Images/EventBreakpointListener.svg: Renamed from Source/WebInspectorUI/UserInterface/Images/EventBreakpoint.svg.
* UserInterface/Images/EventBreakpointTimer.svg: Added.

* UserInterface/Controllers/DOMDebuggerManager.js:
(WI.DOMDebuggerManager.supportsEventBreakpoints): Added.
(WI.DOMDebuggerManager.prototype.eventBreakpointForTypeAndEventName): Added.
(WI.DOMDebuggerManager.prototype.addEventBreakpoint):
(WI.DOMDebuggerManager.prototype.removeEventBreakpoint.breakpointRemoved): Added.
(WI.DOMDebuggerManager.prototype.removeEventBreakpoint):
(WI.DOMDebuggerManager.prototype._updateEventBreakpoint):
(WI.DOMDebuggerManager.prototype.eventBreakpointForEventName): Deleted.

* UserInterface/Controllers/DOMTreeManager.js:
(WI.DOMTreeManager.prototype.setBreakpointForEventListener):

* UserInterface/Controllers/DebuggerManager.js:
(WI.DebuggerManager.prototype._pauseReasonFromPayload):

* UserInterface/Models/EventBreakpoint.js:
(WI.EventBreakpoint):
(WI.EventBreakpoint.fromPayload):
(WI.EventBreakpoint.prototype.get type): Added.
(WI.EventBreakpoint.prototype.get serializableInfo):
(WI.EventBreakpoint.prototype.saveIdentityToCookie):

* UserInterface/Views/DebuggerSidebarPanel.js:
(WI.DebuggerSidebarPanel.prototype._updatePauseReasonSection):
(WI.DebuggerSidebarPanel.prototype.willDismissPopover):

* UserInterface/Views/EventBreakpointPopover.js:
(WI.EventBreakpointPopover):
(WI.EventBreakpointPopover.prototype.get breakpoint): Added.
(WI.EventBreakpointPopover.prototype.show):
(WI.EventBreakpointPopover.prototype.show.createOption): Added.
(WI.EventBreakpointPopover.prototype.dismiss): Added.
(WI.EventBreakpointPopover.prototype._presentOverTargetElement):
(WI.EventBreakpointPopover.prototype._handleTypeSelectChange): Added.
(WI.EventBreakpointPopover.prototype.get result): Deleted.
(WI.EventBreakpointPopover.prototype.get value): Deleted.
* UserInterface/Views/EventBreakpointPopover.css:
(.popover .event-breakpoint-content > .event-type): Added.
(.popover .event-breakpoint-content > input): Deleted.

* UserInterface/Views/EventBreakpointTreeElement.js:
(WI.EventBreakpointTreeElement):
* UserInterface/Views/EventBreakpointTreeElement.css:
(.breakpoint.event.animation-frame:not(.breakpoint-paused-icon) .icon): Added.
(.breakpoint.event.listener:not(.breakpoint-paused-icon) .icon): Added.
(.breakpoint.event.timer:not(.breakpoint-paused-icon) .icon): Added.
(.breakpoint.event:not(.breakpoint-paused-icon) .icon): Deleted.

LayoutTests:

* inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt: Added.
* inspector/dom-debugger/event-animation-frame-breakpoints.html: Added.

* inspector/dom-debugger/event-breakpoint-with-navigation.html:

* inspector/dom-debugger/event-timer-breakpoints-expected.txt: Added.
* inspector/dom-debugger/event-timer-breakpoints.html: Added.

* inspector/dom-debugger/event-listener-breakpoints-expected.txt: Renamed from LayoutTests/inspector/dom-debugger/event-breakpoints-expected.txt.
* inspector/dom-debugger/event-listener-breakpoints.html: Renamed from LayoutTests/inspector/dom-debugger/event-breakpoints.html.

* inspector/dom-debugger/resources/event-breakpoint-utilities.js: Added.
(TestPage.registerInitializer.window.teardown):
(TestPage.registerInitializer.window.failOnPause):
(TestPage.registerInitializer.window.addBreakpoint):
(TestPage.registerInitializer.window.removeBreakpoint):
(TestPage.registerInitializer.window.disableBreakpoint):
(TestPage.registerInitializer.window.awaitEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt [new file with mode: 0644]
LayoutTests/inspector/dom-debugger/event-animation-frame-breakpoints.html [new file with mode: 0644]
LayoutTests/inspector/dom-debugger/event-breakpoint-with-navigation.html
LayoutTests/inspector/dom-debugger/event-breakpoints.html [deleted file]
LayoutTests/inspector/dom-debugger/event-listener-breakpoints-expected.txt [moved from LayoutTests/inspector/dom-debugger/event-breakpoints-expected.txt with 69% similarity]
LayoutTests/inspector/dom-debugger/event-listener-breakpoints.html [new file with mode: 0644]
LayoutTests/inspector/dom-debugger/event-timer-breakpoints-expected.txt [new file with mode: 0644]
LayoutTests/inspector/dom-debugger/event-timer-breakpoints.html [new file with mode: 0644]
LayoutTests/inspector/dom-debugger/resources/event-breakpoint-utilities.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/DOMDebugger.json
Source/JavaScriptCore/inspector/protocol/Debugger.json
Source/JavaScriptCore/inspector/scripts/codegen/generate_cpp_protocol_types_header.py
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/enum-values.json-result
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-array-type.json-result
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-enum-type.json-result
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-declaration-object-type.json-result
Source/JavaScriptCore/inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp
Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.h
Source/WebCore/page/DOMTimer.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Controllers/DOMDebuggerManager.js
Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js
Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
Source/WebInspectorUI/UserInterface/Images/EventBreakpointAnimationFrame.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Images/EventBreakpointListener.svg [moved from Source/WebInspectorUI/UserInterface/Images/EventBreakpoint.svg with 100% similarity]
Source/WebInspectorUI/UserInterface/Images/EventBreakpointTimer.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Models/EventBreakpoint.js
Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.css
Source/WebInspectorUI/UserInterface/Views/EventBreakpointPopover.js
Source/WebInspectorUI/UserInterface/Views/EventBreakpointTreeElement.css
Source/WebInspectorUI/UserInterface/Views/EventBreakpointTreeElement.js