Ignore:
Timestamp:
Oct 26, 2020, 11:39:08 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: console command line API should be exposed to breakpoint conditions/actions
https://bugs.webkit.org/show_bug.cgi?id=218141
<rdar://problem/70636727>

Reviewed by Brian Burg.

Source/JavaScriptCore:

  • debugger/Debugger.h:

(JSC::Debugger::Client::scopeExtensionObject): Added.

  • debugger/Debugger.cpp:

(JSC::Debugger::setClient): Added.
(JSC::Debugger::evaluateBreakpointCondition):
(JSC::Debugger::evaluateBreakpointActions):
Introduce an optional Debugger::Client virtual class that can be used to adjust behavior
in various situations. Right now it is used when evaluating breakpoint conditions/actions
to get a scope extension object.

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

(Inspector::InspectorDebuggerAgent::internalEnable):
(Inspector::InspectorDebuggerAgent::internalDisable):
(Inspector::InspectorDebuggerAgent::scopeExtensionObject): Added.
Implement Debugger::Client and provide a newly created CommandLineAPI instance.

  • inspector/InjectedScript.h:
  • inspector/InjectedScript.cpp:

(Inspector::InjectedScript::createCommandLineAPIObject const): Added.

  • inspector/InjectedScriptSource.js:

(let.InjectedScript.prototype.createCommandLineAPIObject): Added.
(let.InjectedScript.prototype._evaluateOn):
Expose a way for the C++ to create CommandLineAPI instances.

Source/WebInspectorUI:

  • UserInterface/Controllers/CodeMirrorCompletionController.js:

(WI.CodeMirrorCompletionController):
(WI.CodeMirrorCompletionController.prototype.get mode): Added.
(WI.CodeMirrorCompletionController.prototype.get delegate): Deleted.

  • UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:

(WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded):
(WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.shouldExposeEvent): Added.
(WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.shouldExposeException): Added.
(WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.receivedPropertyNames):
Introduce a Mode enum that can be fetched by completion providers to adjust functionality.

  • UserInterface/Views/BreakpointPopover.js:

(WI.BreakpointPopover.appendContextMenuItems):
(WI.BreakpointPopover.prototype.show):
(WI.BreakpointPopover.prototype.breakpointActionViewCodeMirrorCompletionControllerMode): Added.
(WI.BreakpointPopover.prototype.get codeMirrorCompletionControllerMode): Added.

  • UserInterface/Views/EventBreakpointPopover.js:

(WI.EventBreakpointPopover.prototype.get codeMirrorCompletionControllerMode): Added.

  • UserInterface/Views/BreakpointActionView.js:

(WI.BreakpointActionView.prototype._updateBody):
Use a Mode that always exposes $event/$exception depending on the breakpoint type.

  • UserInterface/Views/ConsolePrompt.js:

(WI.ConsolePrompt):
Use a Mode that only exposes $event/$exception when paused for an event/exeption.

  • UserInterface/Views/ScopeChainDetailsSidebarPanel.js:

(WI.ScopeChainDetailsSidebarPanel.prototype._addWatchExpressionButtonClicked):
Use a Mode that always exposes $event/$exception since watch expressions track values
over time, and may therefore not always have an $event/$exception set.

  • UserInterface/Views/TextEditor.js:

(WI.TextEditor):
Use the default Mode that never exposes $event/$exception.

LayoutTests:

  • inspector/debugger/resources/breakpoint-options-utilities.js:
  • inspector/debugger/break-on-exception-expected.txt:
  • inspector/debugger/break-on-uncaught-exception-expected.txt:
  • inspector/debugger/setPauseOnAssertions-expected.txt:
  • inspector/debugger/setPauseOnDebuggerStatements-expected.txt:
  • inspector/debugger/setPauseOnMicrotasks-expected.txt:
  • inspector/dom-debugger/attribute-modified-style-expected.txt:
  • inspector/dom-debugger/dom-breakpoint-attribute-modified-expected.txt:
  • inspector/dom-debugger/dom-breakpoint-node-removed-ancestor-expected.txt:
  • inspector/dom-debugger/dom-breakpoint-node-removed-direct-expected.txt:
  • inspector/dom-debugger/dom-breakpoint-subtree-modified-add-expected.txt:
  • inspector/dom-debugger/dom-breakpoint-subtree-modified-remove-expected.txt:
  • inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt:
  • inspector/dom-debugger/event-interval-breakpoints-expected.txt:
  • inspector/dom-debugger/event-listener-breakpoints-expected.txt:
  • inspector/dom-debugger/event-timeout-breakpoints-expected.txt:
  • inspector/dom-debugger/url-breakpoints-all-requests-expected.txt:
  • inspector/dom-debugger/url-breakpoints-containing-expected.txt:
  • inspector/dom-debugger/url-breakpoints-matching-expected.txt:
Location:
trunk/Source/JavaScriptCore/debugger
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r266534 r269023  
    238238}
    239239
     240void Debugger::setClient(Client* client)
     241{
     242    ASSERT(!!m_client != !!client);
     243    m_client = client;
     244}
     245
    240246void Debugger::addObserver(Observer& observer)
    241247{
     
    610616    NakedPtr<Exception> exception;
    611617    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
    612     JSObject* scopeExtensionObject = nullptr;
     618    JSObject* scopeExtensionObject = m_client ? m_client->scopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    613619    JSValue result = debuggerCallFrame.evaluateWithScopeExtension(condition, scopeExtensionObject, exception);
    614620
     
    644650        case Breakpoint::Action::Type::Evaluate: {
    645651            NakedPtr<Exception> exception;
    646             JSObject* scopeExtensionObject = nullptr;
     652            JSObject* scopeExtensionObject = m_client ? m_client->scopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    647653            debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
    648654            if (exception)
     
    659665        case Breakpoint::Action::Type::Probe: {
    660666            NakedPtr<Exception> exception;
    661             JSObject* scopeExtensionObject = nullptr;
     667            JSObject* scopeExtensionObject = m_client ? m_client->scopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    662668            JSValue result = debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
    663669            JSC::JSGlobalObject* debuggerGlobalObject = debuggerCallFrame.globalObject();
  • trunk/Source/JavaScriptCore/debugger/Debugger.h

    r266534 r269023  
    141141    void registerCodeBlock(CodeBlock*);
    142142
     143    class Client {
     144    public:
     145        virtual ~Client() = default;
     146
     147        virtual JSObject* scopeExtensionObject(Debugger&, JSGlobalObject*, DebuggerCallFrame&) { return nullptr; }
     148    };
     149
     150    void setClient(Client*);
     151
    143152    // FIXME: <https://webkit.org/b/162773> Web Inspector: Simplify Debugger::Script to use SourceProvider
    144153    struct Script {
     
    326335    bool m_dispatchingFunctionToObservers { false };
    327336
     337    Client* m_client { nullptr };
    328338    ProfilingClient* m_profilingClient { nullptr };
    329339
Note: See TracChangeset for help on using the changeset viewer.