Changeset 207444 in webkit


Ignore:
Timestamp:
Oct 17, 2016 5:36:12 PM (8 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Add toggles for debugger pauses at console.assert failures
https://bugs.webkit.org/show_bug.cgi?id=139542
<rdar://problem/19281600>

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

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

(Inspector::InspectorDebuggerAgent::disable):
(Inspector::InspectorDebuggerAgent::setPauseOnAssertions):
Toggle pause on assertions state. Default is disabled,
and disable it when frontends disconnect.

(Inspector::InspectorDebuggerAgent::handleConsoleAssert):
Instead of using the PauseOnAllExceptions state, use this
new state specific to assertions.

  • inspector/protocol/Debugger.json:

New protocol method to toggle pausing on assertions.

Source/WebInspectorUI:

  • UserInterface/Controllers/DebuggerManager.js:

(WebInspector.DebuggerManager.prototype.get assertionsBreakpoint):
(WebInspector.DebuggerManager.prototype.isBreakpointRemovable):
(WebInspector.DebuggerManager.prototype._breakpointDisabledStateDidChange):
New breakpoint and toggling behavior.

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Views/DebuggerSidebarPanel.js:

(WebInspector.DebuggerSidebarPanel):
(WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineDeleteTreeElement):
(WebInspector.DebuggerSidebarPanel.prototype._compareTopLevelTreeElements.isSpecialBreakpoint):
(WebInspector.DebuggerSidebarPanel.prototype._compareTopLevelTreeElements):
New breakpoint tree element behavior.

(WebInspector.DebuggerSidebarPanel.prototype.saveStateToCookie):
(WebInspector.DebuggerSidebarPanel.prototype.restoreStateFromCookie):
Sidebar restoration if it was selected.

  • UserInterface/Images/Assertion.svg: Added.
  • UserInterface/Images/gtk/Assertion.svg: Added.
  • UserInterface/Views/BreakpointTreeElement.css:

(.breakpoint-assertion-icon .icon):
New sidebar icon for the global breakpoint.

LayoutTests:

  • inspector/debugger/pause-on-assert.html:
  • inspector/debugger/pause-reason.html:

These tests need to enable pause on assertions.

  • inspector/debugger/setPauseOnAssertions-expected.txt: Added.
  • inspector/debugger/setPauseOnAssertions.html: Added.

Specific tests for the new protocol method.

Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207440 r207444  
     12016-10-17  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Add toggles for debugger pauses at console.assert failures
     4        https://bugs.webkit.org/show_bug.cgi?id=139542
     5        <rdar://problem/19281600>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/debugger/pause-on-assert.html:
     10        * inspector/debugger/pause-reason.html:
     11        These tests need to enable pause on assertions.
     12
     13        * inspector/debugger/setPauseOnAssertions-expected.txt: Added.
     14        * inspector/debugger/setPauseOnAssertions.html: Added.
     15        Specific tests for the new protocol method.
     16
    1172016-10-17  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/LayoutTests/inspector/debugger/pause-on-assert.html

    r199592 r207444  
    99    InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true});
    1010    InspectorProtocol.sendCommand("Debugger.setPauseOnExceptions", {state: "all"}, InspectorProtocol.checkForError);
     11    InspectorProtocol.sendCommand("Debugger.setPauseOnAssertions", {enabled: true}, InspectorProtocol.checkForError);
    1112
    1213    var step = null;
  • trunk/LayoutTests/inspector/debugger/pause-reason.html

    r202783 r207444  
    4848
    4949    WebInspector.debuggerManager.allExceptionsBreakpoint.disabled = false;
     50    WebInspector.debuggerManager.assertionsBreakpoint.disabled = false;
    5051
    5152    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, function(event) {
  • trunk/Source/JavaScriptCore/ChangeLog

    r207437 r207444  
     12016-10-17  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Add toggles for debugger pauses at console.assert failures
     4        https://bugs.webkit.org/show_bug.cgi?id=139542
     5        <rdar://problem/19281600>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/agents/InspectorDebuggerAgent.h:
     10        * inspector/agents/InspectorDebuggerAgent.cpp:
     11        (Inspector::InspectorDebuggerAgent::disable):
     12        (Inspector::InspectorDebuggerAgent::setPauseOnAssertions):
     13        Toggle pause on assertions state. Default is disabled,
     14        and disable it when frontends disconnect.
     15
     16        (Inspector::InspectorDebuggerAgent::handleConsoleAssert):
     17        Instead of using the PauseOnAllExceptions state, use this
     18        new state specific to assertions.
     19
     20        * inspector/protocol/Debugger.json:
     21        New protocol method to toggle pausing on assertions.
     22
    1232016-10-17  Yusuke Suzuki  <utatane.tea@gmail.com>
    224
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp

    r207267 r207444  
    114114        m_listener->debuggerWasDisabled();
    115115
     116    m_pauseOnAssertionFailures = false;
     117
    116118    m_enabled = false;
    117119}
     
    194196void InspectorDebuggerAgent::handleConsoleAssert(const String& message)
    195197{
    196     if (m_scriptDebugServer.pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions)
     198    if (m_pauseOnAssertionFailures)
    197199        breakProgram(DebuggerFrontendDispatcher::Reason::Assert, buildAssertPauseReason(message));
    198200}
     
    627629    if (m_scriptDebugServer.pauseOnExceptionsState() != pauseState)
    628630        errorString = ASCIILiteral("Internal error. Could not change pause on exceptions state");
     631}
     632
     633void InspectorDebuggerAgent::setPauseOnAssertions(ErrorString&, bool enabled)
     634{
     635    m_pauseOnAssertionFailures = enabled;
    629636}
    630637
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h

    r206653 r207444  
    7878    void stepOut(ErrorString&) final;
    7979    void setPauseOnExceptions(ErrorString&, const String& pauseState) final;
     80    void setPauseOnAssertions(ErrorString&, bool enabled) final;
    8081    void evaluateOnCallFrame(ErrorString&, const String& callFrameId, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex) final;
    8182    void setOverlayMessage(ErrorString&, const String*) override;
     
    169170    bool m_hasExceptionValue { false };
    170171    bool m_didPauseStopwatch { false };
     172    bool m_pauseOnAssertionFailures { false };
    171173};
    172174
  • trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json

    r202717 r207444  
    238238        {
    239239            "name": "setPauseOnExceptions",
     240            "description": "Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is <code>none</code>.",
    240241            "parameters": [
    241242                { "name": "state", "type": "string", "enum": ["none", "uncaught", "all"], "description": "Pause on exceptions mode." }
    242             ],
    243             "description": "Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is <code>none</code>."
     243            ]
     244        },
     245        {
     246            "name": "setPauseOnAssertions",
     247            "description": "Set pause on assertions state. Assertions are console.assert assertions.",
     248            "parameters": [
     249                { "name": "enabled", "type": "boolean" }
     250            ]
    244251        },
    245252        {
  • trunk/Source/WebInspectorUI/ChangeLog

    r207371 r207444  
     12016-10-17  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Add toggles for debugger pauses at console.assert failures
     4        https://bugs.webkit.org/show_bug.cgi?id=139542
     5        <rdar://problem/19281600>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * UserInterface/Controllers/DebuggerManager.js:
     10        (WebInspector.DebuggerManager.prototype.get assertionsBreakpoint):
     11        (WebInspector.DebuggerManager.prototype.isBreakpointRemovable):
     12        (WebInspector.DebuggerManager.prototype._breakpointDisabledStateDidChange):
     13        New breakpoint and toggling behavior.
     14
     15        * Localizations/en.lproj/localizedStrings.js:
     16        * UserInterface/Views/DebuggerSidebarPanel.js:
     17        (WebInspector.DebuggerSidebarPanel):
     18        (WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineDeleteTreeElement):
     19        (WebInspector.DebuggerSidebarPanel.prototype._compareTopLevelTreeElements.isSpecialBreakpoint):
     20        (WebInspector.DebuggerSidebarPanel.prototype._compareTopLevelTreeElements):
     21        New breakpoint tree element behavior.
     22
     23        (WebInspector.DebuggerSidebarPanel.prototype.saveStateToCookie):
     24        (WebInspector.DebuggerSidebarPanel.prototype.restoreStateFromCookie):
     25        Sidebar restoration if it was selected.
     26
     27        * UserInterface/Images/Assertion.svg: Added.
     28        * UserInterface/Images/gtk/Assertion.svg: Added.
     29        * UserInterface/Views/BreakpointTreeElement.css:
     30        (.breakpoint-assertion-icon .icon):
     31        New sidebar icon for the global breakpoint.
     32
    1332016-10-15  Joseph Pecoraro  <pecoraro@apple.com>
    234
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r206059 r207444  
    7070localizedStrings["All Resources"] = "All Resources";
    7171localizedStrings["All Storage"] = "All Storage";
    72 localizedStrings["All Uncaught Exceptions"] = "All Uncaught Exceptions";
    7372localizedStrings["Alternates"] = "Alternates";
    7473localizedStrings["An error occurred trying to load the resource."] = "An error occurred trying to load the resource.";
     
    9291localizedStrings["Assertion Failed"] = "Assertion Failed";
    9392localizedStrings["Assertion Failed: %s"] = "Assertion Failed: %s";
     93localizedStrings["Assertion Failures"] = "Assertion Failures";
    9494localizedStrings["Assertion with message: %s"] = "Assertion with message: %s";
    9595localizedStrings["Assertive"] = "Assertive";
     
    785785localizedStrings["Type information for variable: %s"] = "Type information for variable: %s";
    786786localizedStrings["Unable to determine path to property from root"] = "Unable to determine path to property from root";
     787localizedStrings["Uncaught Exceptions"] = "Uncaught Exceptions";
    787788localizedStrings["Unchanged"] = "Unchanged";
    788789localizedStrings["Uncomment All Properties"] = "Uncomment All Properties";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js

    r207371 r207444  
    4848        this._allExceptionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-all-exceptions", false);
    4949        this._allUncaughtExceptionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-all-uncaught-exceptions", false);
     50        this._assertionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-assertions", false);
    5051
    5152        let specialBreakpointLocation = new WebInspector.SourceCodeLocation(null, Infinity, Infinity);
     
    5556
    5657        this._allUncaughtExceptionsBreakpoint = new WebInspector.Breakpoint(specialBreakpointLocation, !this._allUncaughtExceptionsBreakpointEnabledSetting.value);
     58       
     59        this._assertionsBreakpoint = new WebInspector.Breakpoint(specialBreakpointLocation, !this._assertionsBreakpointEnabledSetting.value);
     60        this._assertionsBreakpoint.resolved = true;
    5761
    5862        this._breakpoints = [];
     
    8690        this._updateBreakOnExceptionsState();
    8791
     92        // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
     93        if (DebuggerAgent.setPauseOnAssertions)
     94            DebuggerAgent.setPauseOnAssertions(this._assertionsBreakpointEnabledSetting.value);
     95
    8896        this._ignoreBreakpointDisplayLocationDidChangeEvent = false;
    8997
     
    145153    {
    146154        return this._allUncaughtExceptionsBreakpoint;
     155    }
     156
     157    get assertionsBreakpoint()
     158    {
     159        return this._assertionsBreakpoint;
    147160    }
    148161
     
    187200    isBreakpointRemovable(breakpoint)
    188201    {
    189         return breakpoint !== this._allExceptionsBreakpoint && breakpoint !== this._allUncaughtExceptionsBreakpoint;
     202        return breakpoint !== this._allExceptionsBreakpoint
     203            && breakpoint !== this._allUncaughtExceptionsBreakpoint
     204            && breakpoint !== this._assertionsBreakpoint;
    190205    }
    191206
     
    850865        }
    851866
     867        if (breakpoint === this._assertionsBreakpoint) {
     868            if (!breakpoint.disabled && !this.breakpointsDisabledTemporarily)
     869                this.breakpointsEnabled = true;
     870            this._assertionsBreakpointEnabledSetting.value = !breakpoint.disabled;
     871            DebuggerAgent.setPauseOnAssertions(this._assertionsBreakpointEnabledSetting.value);
     872            return;
     873        }
     874
    852875        if (breakpoint.disabled)
    853876            this._removeBreakpoint(breakpoint);
  • trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.css

    r188837 r207444  
    5151}
    5252
     53.breakpoint-assertion-icon .icon {
     54    content: url(../Images/Assertion.svg);
     55}
     56
    5357.breakpoint-paused-icon .icon {
    5458    content: url(../Images/PausedBreakpoint.svg);
  • trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js

    r207359 r207444  
    108108
    109109        this._allExceptionsBreakpointTreeElement = new WebInspector.BreakpointTreeElement(WebInspector.debuggerManager.allExceptionsBreakpoint, WebInspector.DebuggerSidebarPanel.ExceptionIconStyleClassName, WebInspector.UIString("All Exceptions"));
    110         this._allUncaughtExceptionsBreakpointTreeElement = new WebInspector.BreakpointTreeElement(WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint, WebInspector.DebuggerSidebarPanel.ExceptionIconStyleClassName, WebInspector.UIString("All Uncaught Exceptions"));
    111         this.suppressFilteringOnTreeElements([this._allExceptionsBreakpointTreeElement, this._allUncaughtExceptionsBreakpointTreeElement]);
     110        this._allUncaughtExceptionsBreakpointTreeElement = new WebInspector.BreakpointTreeElement(WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint, WebInspector.DebuggerSidebarPanel.ExceptionIconStyleClassName, WebInspector.UIString("Uncaught Exceptions"));
     111        this._assertionsBreakpointTreeElement = new WebInspector.BreakpointTreeElement(WebInspector.debuggerManager.assertionsBreakpoint, WebInspector.DebuggerSidebarPanel.AssertionIconStyleClassName, WebInspector.UIString("Assertion Failures"));
     112
     113        this.suppressFilteringOnTreeElements([this._allExceptionsBreakpointTreeElement, this._allUncaughtExceptionsBreakpointTreeElement, this._assertionsBreakpointTreeElement]);
    112114
    113115        this.filterBar.placeholder = WebInspector.UIString("Filter List");
     
    151153        this._breakpointsContentTreeOutline.appendChild(this._allUncaughtExceptionsBreakpointTreeElement);
    152154
     155        // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
     156        if (DebuggerAgent.setPauseOnAssertions)
     157            this._breakpointsContentTreeOutline.appendChild(this._assertionsBreakpointTreeElement);
     158
    153159        this._scriptsContentTreeOutline = this.createContentTreeOutline(true);
    154160        this._scriptsContentTreeOutline.addEventListener(WebInspector.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
     
    282288        }
    283289
     290        if (representedObject === WebInspector.debuggerManager.assertionsBreakpoint) {
     291            cookie[WebInspector.DebuggerSidebarPanel.SelectedAssertionsCookieKey] = true;
     292            return;
     293        }
     294
    284295        super.saveStateToCookie(cookie);
    285296    }
     
    294305        else if (cookie[WebInspector.DebuggerSidebarPanel.SelectedAllUncaughtExceptionsCookieKey])
    295306            this._allUncaughtExceptionsBreakpointTreeElement.revealAndSelect();
     307        else if (cookie[WebInspector.DebuggerSidebarPanel.SelectedAssertionsCookieKey])
     308            this._assertionsBreakpointTreeElement.revealAndSelect();
    296309        else
    297310            super.restoreStateFromCookie(cookie, relaxedMatchDelay);
     
    692705            return false;
    693706
    694         var wasTopResourceTreeElement = treeElement.previousSibling === this._allUncaughtExceptionsBreakpointTreeElement;
     707        var wasTopResourceTreeElement = treeElement.previousSibling === this._assertionsBreakpointTreeElement || treeElement.previousSibling === this._allUncaughtExceptionsBreakpointTreeElement;
    695708        var nextSibling = treeElement.nextSibling;
    696709
     
    775788        function isSpecialBreakpoint(treeElement)
    776789        {
    777             return treeElement.representedObject === WebInspector.debuggerManager.allExceptionsBreakpoint || treeElement.representedObject === WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint;
     790            return treeElement.representedObject === WebInspector.debuggerManager.allExceptionsBreakpoint
     791                || treeElement.representedObject === WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint
     792                || treeElement.representedObject === WebInspector.debuggerManager.assertionsBreakpoint;
    778793        }
    779794
     
    956971WebInspector.DebuggerSidebarPanel.DebuggerPausedStyleClassName = "paused";
    957972WebInspector.DebuggerSidebarPanel.ExceptionIconStyleClassName = "breakpoint-exception-icon";
     973WebInspector.DebuggerSidebarPanel.AssertionIconStyleClassName = "breakpoint-assertion-icon";
    958974WebInspector.DebuggerSidebarPanel.PausedBreakpointIconStyleClassName = "breakpoint-paused-icon";
    959975
    960976WebInspector.DebuggerSidebarPanel.SelectedAllExceptionsCookieKey = "debugger-sidebar-panel-all-exceptions-breakpoint";
    961977WebInspector.DebuggerSidebarPanel.SelectedAllUncaughtExceptionsCookieKey = "debugger-sidebar-panel-all-uncaught-exceptions-breakpoint";
     978WebInspector.DebuggerSidebarPanel.SelectedAssertionsCookieKey = "debugger-sidebar-panel-assertions-breakpoint";
Note: See TracChangeset for help on using the changeset viewer.