Allow emulation of user gestures from Web Inspector console
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Feb 2019 00:52:56 +0000 (00:52 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Feb 2019 00:52:56 +0000 (00:52 +0000)
commit92ab40e21a37fa113de1a22ae9cb5079d321b1ae
tree282966495dac835d5d0be8a4d0e76915e0cbbbd5
parent5c2cbbb498e6316560a72e887d72daa8a45ff577
Allow emulation of user gestures from Web Inspector console
https://bugs.webkit.org/show_bug.cgi?id=194725
<rdar://problem/48126604>

Reviewed by Joseph Pecoraro and Devin Rousso.

Source/JavaScriptCore:

* inspector/agents/InspectorRuntimeAgent.cpp: Add a new optional parameter, emulateUserGesture,
to the evaluate function, and mark the function as override so that PageRuntimeAgent
can change the behaviour.
(Inspector::InspectorRuntimeAgent::evaluate):
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/protocol/Runtime.json:

Source/WebCore:

Test: inspector/runtime/evaluate-userGestureEmulation.html

* inspector/agents/page/PageRuntimeAgent.cpp: Override the emulate method and create
a UserGestureIndicator based on the emulateUserGesture option.
(WebCore::PageRuntimeAgent::evaluate):
* inspector/agents/page/PageRuntimeAgent.h:

Source/WebInspectorUI:

Add some UI for emulating a User Gesture when evaluating in the console. This
allows the developer to do things that would otherwise require actual interaction
with the page, such as start playback of media on iOS.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Base/Setting.js: Add a new setting for this option.
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.consolePromptTextCommitted):
* UserInterface/Controllers/RuntimeManager.js: Call evaluate with this new option.
(WI.RuntimeManager.prototype.evaluateInInspectedWindow):
* UserInterface/Views/LogContentView.js: Add a new checkbox in the upper bar
that allows the user to toggle the setting.
(WI.LogContentView):
(WI.LogContentView.prototype.get navigationItems):
(WI.LogContentView.prototype._handleEmulateInUserGestureSettingChanged):

* UserInterface/Views/NetworkTableContentView.js: Two drive-by typo fixes :)
(WI.NetworkTableContentView): perserve -> preserve
(WI.NetworkTableContentView.prototype.get navigationItems): checkboxs -> checkboxes

LayoutTests:

* inspector/runtime/evaluate-userGestureEmulation-expected.txt: Added.
* inspector/runtime/evaluate-userGestureEmulation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/runtime/evaluate-userGestureEmulation-expected.txt [new file with mode: 0644]
LayoutTests/inspector/runtime/evaluate-userGestureEmulation.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h
Source/JavaScriptCore/inspector/protocol/Runtime.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Setting.js
Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js
Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js
Source/WebInspectorUI/UserInterface/Views/LogContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js