Ignore:
Timestamp:
Jan 11, 2021, 12:13:30 PM (4 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Debugger: allow breakpoint actions to be evaluated as a user gesture
https://bugs.webkit.org/show_bug.cgi?id=200275

Reviewed by Brian Burg.

Source/JavaScriptCore:

  • inspector/protocol/Debugger.json:
  • debugger/Breakpoint.h:

Add an optional emulateUserGesture property to Debugger.BreakpointAction.

  • debugger/Debugger.h:

(JSC::Debugger::Client::debuggerScopeExtensionObject): Renamed from scopeExtensionObject.
(JSC::Debugger::Client::debuggerWillEvaluate): Added.
(JSC::Debugger::Client::debuggerDidEvaluate): Added.

  • debugger/Debugger.cpp:

(JSC::Debugger::evaluateBreakpointCondition):
(JSC::Debugger::evaluateBreakpointActions):
Consult the Debugger::Client before and after evaluating each Breakpoint::Action.
Currently this is used by WebCore::PageDebuggerAgent to push onto or pop from a stack of
WebCore::UserGestureEmulationScope, each corresponding to a Breakpoint::Action that
has been set with emulateUserGesture.

  • inspector/agents/InspectorDebuggerAgent.h:
  • inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::parseBreakpointOptions):
(Inspector::InspectorDebuggerAgent::debuggerScopeExtensionObject): Renamed from scopeExtensionObject.

Source/WebCore:

Tests: inspector/debugger/breakpoint-action-emulateUserGesture.html

inspector/debugger/breakpoint-action-emulateUserGesture-userIsInteracting.html

  • inspector/agents/page/PageDebuggerAgent.cpp:
  • inspector/agents/page/PageDebuggerAgent.h:

(WebCore::PageDebuggerAgent::debuggerWillEvaluate): Added.
(WebCore::PageDebuggerAgent::debuggerDidEvaluate): Added.
Maintain a stack of UserGestureEmulationScope whenever evaluating breakpoint actions (but
only add/remove items if the current action is set to emulateUserGesture).

  • inspector/agents/page/UserGestureEmulationScope.h:

Make it fast allocated so it can be used with UniqueRef.

Source/WebInspectorUI:

  • UserInterface/Models/BreakpointAction.js:

(WI.BreakpointAction.supportsEmulateUserAction): Added.
(WI.BreakpointAction.fromJSON):
(WI.BreakpointAction.prototype.toJSON):
(WI.BreakpointAction.prototype.set type):
(WI.BreakpointAction.prototype.set data):
(WI.BreakpointAction.prototype.get emulateUserGesture): Added.
(WI.BreakpointAction.prototype.set emulateUserGesture): Added.
Add an _emulateUserGesture property to match Debugger.BreakpointAction.

  • UserInterface/Views/BreakpointActionView.js:

(WI.BreakpointActionView):
(WI.BreakpointActionView.prototype._updateBody):
(WI.BreakpointActionView.prototype._handleEmulateUserGestureCheckboxChange): Added.

  • UserInterface/Views/BreakpointActionView.css:

(.breakpoint-action-block-body .description): Added.
(.breakpoint-action-block-body > .flex):
(.breakpoint-action-block-body > .description): Deleted.
Add a "[ ] Emulate User Gesture" under the log/evaluate/probe input.

  • UserInterface/Models/Breakpoint.js:

(WI.Breakpoint):
(WI.Breakpoint.prototype.addAction):
(WI.Breakpoint.prototype.removeAction):
(WI.Breakpoint.prototype._handleBreakpointActionModified): Renamed from _handleBreakpointActionChanged.
Drive-by: combine TypeChanged and DataChanged into a single Modified event since all
the listeners currently have the same callback.

  • UserInterface/Views/LogContentView.js:

(WI.LogContentView):
(WI.LogContentView.prototype._handleEmulateInUserGestureSettingChanged):
Drive-by: only show the "Emulate User Gesture" checkbox when it's supported.

  • Localizations/en.lproj/localizedStrings.js:

LayoutTests:

  • inspector/debugger/breakpoint-action-emulateUserGesture.html: Added.
  • inspector/debugger/breakpoint-action-emulateUserGesture-expected.txt: Added.
  • inspector/debugger/breakpoint-action-emulateUserGesture-userIsInteracting.html: Added.
  • inspector/debugger/breakpoint-action-emulateUserGesture-userIsInteracting-expected.txt: Added.
Location:
trunk/Source/JavaScriptCore/debugger
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/debugger/Breakpoint.h

    r266534 r271373  
    5656        String data;
    5757        BreakpointActionID id { noBreakpointActionID };
     58        bool emulateUserGesture { false };
    5859    };
    5960
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r269023 r271373  
    616616    NakedPtr<Exception> exception;
    617617    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
    618     JSObject* scopeExtensionObject = m_client ? m_client->scopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
     618    JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    619619    JSValue result = debuggerCallFrame.evaluateWithScopeExtension(condition, scopeExtensionObject, exception);
    620620
     
    638638    m_currentProbeBatchId++;
    639639
    640     for (auto& action : breakpoint.actions()) {
     640    for (const auto& action : breakpoint.actions()) {
     641        if (m_client)
     642            m_client->debuggerWillEvaluate(*this, action);
     643
    641644        auto& debuggerCallFrame = currentDebuggerCallFrame();
    642645
     
    650653        case Breakpoint::Action::Type::Evaluate: {
    651654            NakedPtr<Exception> exception;
    652             JSObject* scopeExtensionObject = m_client ? m_client->scopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
     655            JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    653656            debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
    654657            if (exception)
     
    665668        case Breakpoint::Action::Type::Probe: {
    666669            NakedPtr<Exception> exception;
    667             JSObject* scopeExtensionObject = m_client ? m_client->scopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
     670            JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    668671            JSValue result = debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
    669672            JSC::JSGlobalObject* debuggerGlobalObject = debuggerCallFrame.globalObject();
     
    677680        }
    678681        }
     682
     683        if (m_client)
     684            m_client->debuggerDidEvaluate(*this, action);
    679685
    680686        if (!isAttached(globalObject))
  • trunk/Source/JavaScriptCore/debugger/Debugger.h

    r269023 r271373  
    145145        virtual ~Client() = default;
    146146
    147         virtual JSObject* scopeExtensionObject(Debugger&, JSGlobalObject*, DebuggerCallFrame&) { return nullptr; }
     147        virtual JSObject* debuggerScopeExtensionObject(Debugger&, JSGlobalObject*, DebuggerCallFrame&) { return nullptr; }
     148        virtual void debuggerWillEvaluate(Debugger&, const Breakpoint::Action&) { }
     149        virtual void debuggerDidEvaluate(Debugger&, const Breakpoint::Action&) { }
    148150    };
    149151
Note: See TracChangeset for help on using the changeset viewer.