Ignore:
Timestamp:
Sep 3, 2019, 7:26:37 PM (6 years ago)
Author:
Devin Rousso
Message:

Web Inspector: implement blackboxing of script resources
https://bugs.webkit.org/show_bug.cgi?id=17240
<rdar://problem/5732847>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

When a script is blackboxed and the debugger attempts to pause in that script, the pause
reason/data will be saved and execution will continue until it has left the blackboxed
script. Once outside, execution is paused with the saved reason/data.

This is especially useful when debugging issues using libraries/frameworks, as it allows the
developer to "skip" the internal logic of the library/framework and instead focus only on
how they're using it.

  • inspector/protocol/Debugger.json:

Add setShouldBlackboxURL command.

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

(Inspector::InspectorDebuggerAgent):
(Inspector::InspectorDebuggerAgent::enable):
(Inspector::InspectorDebuggerAgent::updatePauseReasonAndData): Added.
(Inspector::InspectorDebuggerAgent::schedulePauseOnNextStatement):
(Inspector::InspectorDebuggerAgent::cancelPauseOnNextStatement):
(Inspector::InspectorDebuggerAgent::setShouldBlackboxURL): Added.
(Inspector::InspectorDebuggerAgent::setPauseForInternalScripts):
(Inspector::InspectorDebuggerAgent::didParseSource):
(Inspector::InspectorDebuggerAgent::didPause):
(Inspector::InspectorDebuggerAgent::didContinue):
(Inspector::InspectorDebuggerAgent::breakProgram):
(Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState):
(Inspector::InspectorDebuggerAgent::clearPauseDetails): Added.
(Inspector::InspectorDebuggerAgent::clearBreakDetails): Deleted.
Renamed "break" to "pause" to match Debugger naming.

  • debugger/Debugger.h:
  • debugger/Debugger.cpp:

(JSC::Debugger::pauseIfNeeded):
(JSC::Debugger::setBlackboxType): Added.
(JSC::Debugger::clearBlackbox): Added.
(JSC::Debugger::isBlacklisted const): Deleted.
(JSC::Debugger::addToBlacklist): Deleted.
(JSC::Debugger::clearBlacklist): Deleted.

Source/WebInspectorUI:

When a script is blackboxed and the debugger attempts to pause in that script, the pause
reason/data will be saved and execution will continue until it has left the blackboxed
script. Once outside, execution is paused with the saved reason/data.

This is especially useful when debugging issues using libraries/frameworks, as it allows the
developer to "skip" the internal logic of the library/framework and instead focus only on
how they're using it.

  • UserInterface/Controllers/DebuggerManager.js:

(WI.DebuggerManager):
(WI.DebuggerManager.prototype.initializeTarget):
(WI.DebuggerManager.supportsBlackboxingScripts): Added.
(WI.DebuggerManager.pauseReasonFromPayload): Added.
(WI.DebuggerManager.prototype.isScriptBlackboxed): Added.
(WI.DebuggerManager.prototype.setShouldBlackboxScript): Added.
(WI.DebuggerManager.prototype._pauseReasonFromPayload):
(WI.DebuggerManager.prototype._pauseReasonFromPayload): Deleted.

  • UserInterface/Models/SourceCode.js:

(WI.SourceCode.prototype.get isScript): Added.
(WI.SourceCode.prototype.get supportsScriptBlackboxing): Added.

  • UserInterface/Models/Script.js:

(WI.Script.prototype.get isScript): Added.

  • UserInterface/Models/Resource.js:

(WI.Resource.prototype.get isScript): Added.
Provide a more straightforward way of determining if a WI.SourceCode is a script.

  • UserInterface/Views/DebuggerSidebarPanel.js:

(WI.DebuggerSidebarPanel.prototype._updatePauseReason):
(WI.DebuggerSidebarPanel.prototype._updatePauseReasonSection):

  • UserInterface/Views/SourcesNavigationSidebarPanel.js:

(WI.SourcesNavigationSidebarPanel.prototype._updatePauseReason):
(WI.SourcesNavigationSidebarPanel.prototype._updatePauseReasonSection):
Display the original pause reason and breakpoint (if applicable) when pausing after leaving
a blackboxed script.

  • UserInterface/Views/SourceCodeTreeElement.js:

(WI.SourceCodeTreeElement.prototype.canSelectOnMouseDown): Added.
(WI.SourceCodeTreeElement.prototype.updateStatus): Added.
(WI.SourceCodeTreeElement.prototype._updateSourceCode):
(WI.SourceCodeTreeElement.prototype._updateToggleBlackboxImageElementState): Added.
(WI.SourceCodeTreeElement.prototype._handleToggleBlackboxedImageElementClick): Added.

  • UserInterface/Views/SourceCodeTreeElement.css: Added.

(.tree-outline .item .status > .toggle-script-blackboxed):
(.tree-outline:not(.navigation-sidebar-panel-content-tree-outline) .item .status > .toggle-script-blackboxed,):
(.tree-outline:focus .item.selected .status > .toggle-script-blackboxed):
(.tree-outline .item .status > .toggle-script-blackboxed.blackboxed):
(@media (prefers-color-scheme: dark) .tree-outline .item .status > .toggle-script-blackboxed):

  • UserInterface/Views/ResourceTreeElement.js:

(WI.ResourceTreeElement.prototype._updateResource):
(WI.ResourceTreeElement.prototype.updateStatus): Added.
(WI.ResourceTreeElement.prototype._updateStatus): Deleted.
Make sure that the loading indicator doesn't override the blackbox toggle.

  • UserInterface/Base/Setting.js:

(WI.Setting.prototype.set value):
(WI.Setting.prototype.save): Added.
When modifying an array value, that doesn't go through WI.Setting.prototype.set value, so
we need a more "manual" way of saving the new value.

  • UserInterface/Main.html:
  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Test/TestHarness.js:

(TestHarness.prototype.newline): Added.
(TestHarness.prototype.expectException):
Add a special case for logging error message objects when running protocol tests.

LayoutTests:

  • inspector/debugger/setShouldBlackboxURL.html: Added.
  • inspector/debugger/setShouldBlackboxURL-expected.txt: Added.
  • inspector/model/remote-object-api-expected.txt:

Update output since WI.TestHarness.prototype.expectException now logs the .constructor.name.

File:
1 edited

Legend:

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

    r248894 r249450  
    101101        PausedForBreakpoint,
    102102        PausedForDebuggerStatement,
     103        PausedAfterBlackboxedScript,
    103104    };
    104105    ReasonForPause reasonForPause() const { return m_reasonForPause; }
     
    112113    void stepOutOfFunction();
    113114
    114     bool isBlacklisted(SourceID) const;
    115     void addToBlacklist(SourceID);
    116     void clearBlacklist();
     115    enum class BlackboxType { Deferred, Ignored };
     116    void setBlackboxType(SourceID, Optional<BlackboxType>);
     117    void clearBlackbox();
    117118
    118119    bool isPaused() const { return m_isPaused; }
     
    225226    HashSet<JSGlobalObject*> m_globalObjects;
    226227    HashMap<SourceID, DebuggerParseData, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> m_parseDataMap;
    227     HashSet<SourceID, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> m_blacklistedScripts;
     228    HashMap<SourceID, BlackboxType, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> m_blackboxedScripts;
    228229
    229230    PauseOnExceptionsState m_pauseOnExceptionsState;
     
    243244    unsigned m_lastExecutedLine;
    244245    SourceID m_lastExecutedSourceID;
     246    bool m_afterBlackboxedScript { false };
    245247
    246248    BreakpointID m_topBreakpointID;
Note: See TracChangeset for help on using the changeset viewer.