Changeset 266538 in webkit


Ignore:
Timestamp:
Sep 3, 2020 1:07:39 PM (4 years ago)
Author:
Devin Rousso
Message:

Web Inspector: allow url breakpoints to be configured
https://bugs.webkit.org/show_bug.cgi?id=215793

Reviewed by Brian Burg.

Source/JavaScriptCore:

  • inspector/protocol/DOMDebugger.json:

Add an options parameter to DOMDebugger.setURLBreakpoint to allow configuration.
Add an isRegex parameter to DOMDebugger.removeURLBreakpoint so that we know what
type of URL breakpoint is being removed.

Source/WebCore:

Tests: inspector/dom-debugger/url-breakpoints.html

inspector/dom-debugger/url-breakpoints-all-requests.html
inspector/dom-debugger/url-breakpoints-containing.html
inspector/dom-debugger/url-breakpoints-matching.html

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

(WebCore::InspectorDOMDebuggerAgent::disable):
(WebCore::InspectorDOMDebuggerAgent::setURLBreakpoint):
(WebCore::InspectorDOMDebuggerAgent::removeURLBreakpoint):
(WebCore::InspectorDOMDebuggerAgent::breakOnURLIfNeeded):

Source/WebInspectorUI:

  • UserInterface/Models/URLBreakpoint.js:

(WI.URLBreakpoint.get editable): Added.
(WI.URLBreakpoint.fromJSON):
(WI.URLBreakpoint.prototype.get editable):

  • UserInterface/Controllers/DOMDebuggerManager.js:

(WI.DOMDebuggerManager):
(WI.DOMDebuggerManager.prototype.initializeTarget):
(WI.DOMDebuggerManager.prototype.addURLBreakpoint):
(WI.DOMDebuggerManager.prototype.removeURLBreakpoint):
(WI.DOMDebuggerManager.prototype._setURLBreakpoint): Added.
(WI.DOMDebuggerManager.prototype._removeURLBreakpoint): Added.
(WI.DOMDebuggerManager.prototype._handleURLBreakpointDisabledStateChanged):
(WI.DOMDebuggerManager.prototype._handleURLBreakpointEditablePropertyChanged): Added.
(WI.DOMDebuggerManager.prototype._handleURLBreakpointActionsChanged): Added.
(WI.DOMDebuggerManager.prototype._updateURLBreakpoint): Deleted.

  • UserInterface/Views/SourcesNavigationSidebarPanel.js:

(WI.SourcesNavigationSidebarPanel):
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu):
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu.addToggleForSpecialBreakpoint): Added.
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu.addToggleForSpecialEventBreakpoint): Deleted.

  • UserInterface/Views/URLBreakpointPopover.js:

(WI.URLBreakpointPopover.get editable):

  • UserInterface/Base/Setting.js:

LayoutTests:

  • inspector/debugger/resources/breakpoint-options-utilities.js:

(TestPage.registerInitializer.InspectorTest.BreakpointOptions.addTestCases):

  • inspector/dom-debugger/resources/url-breakpoint-utilities.js: Added.

(TestPage.registerInitializer.InspectorTest.URLBreakpoint.teardown):
(TestPage.registerInitializer.InspectorTest.URLBreakpoint.createBreakpoint):
(TestPage.registerInitializer.InspectorTest.URLBreakpoint.addBreakpoint):
(TestPage.registerInitializer.InspectorTest.URLBreakpoint.request):

  • inspector/dom-debugger/url-breakpoints.html:
  • inspector/dom-debugger/url-breakpoints-expected.txt:
  • inspector/dom-debugger/url-breakpoints-all-requests.html: Added.
  • inspector/dom-debugger/url-breakpoints-all-requests-expected.txt: Added.
  • inspector/dom-debugger/url-breakpoints-containing.html: Added.
  • inspector/dom-debugger/url-breakpoints-containing-expected.txt: Added.
  • inspector/dom-debugger/url-breakpoints-matching.html: Added.
  • inspector/dom-debugger/url-breakpoints-matching-expected.txt: Added.

Split the one URL breakpoint test into four so they run quicker.

  • inspector/dom-debugger/resources/event-breakpoint-utilities.js:

(TestPage.registerInitializer.InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases): Deleted.

  • inspector/dom-debugger/event-animation-frame-breakpoints.html:
  • inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt:
  • inspector/dom-debugger/event-interval-breakpoints.html:
  • inspector/dom-debugger/event-interval-breakpoints-expected.txt:
  • inspector/dom-debugger/event-listener-breakpoints.html:
  • inspector/dom-debugger/event-listener-breakpoints-expected.txt:
  • inspector/dom-debugger/event-timeout-breakpoints.html:
  • inspector/dom-debugger/event-timeout-breakpoints-expected.txt:

Use InspectorTest.BreakpointOptions.addTestCases instead of duplicating the logic.

Location:
trunk
Files:
7 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r266534 r266538  
     12020-09-03  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: allow url breakpoints to be configured
     4        https://bugs.webkit.org/show_bug.cgi?id=215793
     5
     6        Reviewed by Brian Burg.
     7
     8        * inspector/debugger/resources/breakpoint-options-utilities.js:
     9        (TestPage.registerInitializer.InspectorTest.BreakpointOptions.addTestCases):
     10
     11        * inspector/dom-debugger/resources/url-breakpoint-utilities.js: Added.
     12        (TestPage.registerInitializer.InspectorTest.URLBreakpoint.teardown):
     13        (TestPage.registerInitializer.InspectorTest.URLBreakpoint.createBreakpoint):
     14        (TestPage.registerInitializer.InspectorTest.URLBreakpoint.addBreakpoint):
     15        (TestPage.registerInitializer.InspectorTest.URLBreakpoint.request):
     16        * inspector/dom-debugger/url-breakpoints.html:
     17        * inspector/dom-debugger/url-breakpoints-expected.txt:
     18        * inspector/dom-debugger/url-breakpoints-all-requests.html: Added.
     19        * inspector/dom-debugger/url-breakpoints-all-requests-expected.txt: Added.
     20        * inspector/dom-debugger/url-breakpoints-containing.html: Added.
     21        * inspector/dom-debugger/url-breakpoints-containing-expected.txt: Added.
     22        * inspector/dom-debugger/url-breakpoints-matching.html: Added.
     23        * inspector/dom-debugger/url-breakpoints-matching-expected.txt: Added.
     24        Split the one URL breakpoint test into four so they run quicker.
     25
     26        * inspector/dom-debugger/resources/event-breakpoint-utilities.js:
     27        (TestPage.registerInitializer.InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases): Deleted.
     28        * inspector/dom-debugger/event-animation-frame-breakpoints.html:
     29        * inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt:
     30        * inspector/dom-debugger/event-interval-breakpoints.html:
     31        * inspector/dom-debugger/event-interval-breakpoints-expected.txt:
     32        * inspector/dom-debugger/event-listener-breakpoints.html:
     33        * inspector/dom-debugger/event-listener-breakpoints-expected.txt:
     34        * inspector/dom-debugger/event-timeout-breakpoints.html:
     35        * inspector/dom-debugger/event-timeout-breakpoints-expected.txt:
     36        Use `InspectorTest.BreakpointOptions.addTestCases` instead of duplicating the logic.
     37
    1382020-09-03  Devin Rousso  <drousso@apple.com>
    239
  • trunk/LayoutTests/inspector/debugger/resources/breakpoint-options-utilities.js

    r266534 r266538  
    22    InspectorTest.BreakpointOptions = {};
    33
    4     InspectorTest.BreakpointOptions.addTestCases = function(suite, {createBreakpoint, triggerBreakpoint}) {
     4    InspectorTest.BreakpointOptions.addTestCases = function(suite, {testCaseNamePrefix, createBreakpoint, triggerBreakpoint}) {
     5        testCaseNamePrefix ??= "";
     6
    57        function removeBreakpoint(breakpoint) {
    68            if (breakpoint.removable)
     
    1315
    1416        suite.addTestCase({
    15             name: suite.name + ".Options.Condition",
     17            name: suite.name + "." + testCaseNamePrefix + "Options.Condition",
    1618            description: "Check that the debugger will not pause unless the breakpoint has a truthy breakpoint condition.",
    1719            async test() {
     
    5658
    5759        suite.addTestCase({
    58             name: suite.name + ".Options.IgnoreCount",
     60            name: suite.name + "." + testCaseNamePrefix + "Options.IgnoreCount",
    5961            description: "Check that the debugger will not pause unless the breakpoint is hit at least as many times as it's `ignoreCount`.",
    6062            async test() {
     
    9294
    9395        suite.addTestCase({
    94             name: suite.name + ".Options.Action.Log",
     96            name: suite.name + "." + testCaseNamePrefix + "Options.Action.Log",
    9597            description: "Check that log breakpoint actions execute when the breakpoint is hit.",
    9698            async test() {
     
    151153
    152154        suite.addTestCase({
    153             name: suite.name + ".Options.Actions.Evaluate",
     155            name: suite.name + "." + testCaseNamePrefix + "Options.Actions.Evaluate",
    154156            description: "Check that evaluate breakpoint actions execute when the breakpoint is hit.",
    155157            async test() {
  • trunk/LayoutTests/inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt

    r266074 r266538  
    6464Triggering breakpoint...
    6565PASS: Should pause.
    66 -- Running test teardown.
    6766
    6867-- Running test case: DOMDebugger.Event.AnimationFrame.Options.IgnoreCount
     
    8382Triggering breakpoint...
    8483PASS: Should pause.
    85 -- Running test teardown.
    8684
    8785-- Running test case: DOMDebugger.Event.AnimationFrame.Options.Action.Log
     
    113111PASS: Should execute breakpoint action.
    114112PASS: Should not pause.
    115 -- Running test teardown.
    116113
    117114-- Running test case: DOMDebugger.Event.AnimationFrame.Options.Actions.Evaluate
     
    143140PASS: Should execute breakpoint action.
    144141PASS: Should not pause.
    145 -- Running test teardown.
    146142
  • trunk/LayoutTests/inspector/dom-debugger/event-animation-frame-breakpoints.html

    r266074 r266538  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="../debugger/resources/breakpoint-options-utilities.js"></script>
    56<script src="../debugger/resources/log-active-stack-trace.js"></script>
    67<script src="resources/event-breakpoint-utilities.js"></script>
     
    9697    });
    9798
    98     InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases(suite, WI.EventBreakpoint.Type.AnimationFrame, eventName);
     99    InspectorTest.BreakpointOptions.addTestCases(suite, {
     100        createBreakpoint() {
     101            return InspectorTest.EventBreakpoint.createBreakpoint(WI.EventBreakpoint.Type.AnimationFrame, {eventName});
     102        },
     103        triggerBreakpoint() {
     104            return Promise.all([
     105                InspectorTest.awaitEvent("TestPage-" + eventName),
     106                InspectorTest.evaluateInPage(`trigger_${eventName}()`),
     107            ]);
     108        },
     109    });
    99110
    100111    suite.runTestCasesAndFinish();
  • trunk/LayoutTests/inspector/dom-debugger/event-interval-breakpoints-expected.txt

    r266074 r266538  
    8484Triggering breakpoint...
    8585PASS: Should pause.
    86 -- Running test teardown.
    8786
    8887-- Running test case: DOMDebugger.Event.Interval.Options.IgnoreCount
     
    103102Triggering breakpoint...
    104103PASS: Should pause.
    105 -- Running test teardown.
    106104
    107105-- Running test case: DOMDebugger.Event.Interval.Options.Action.Log
     
    133131PASS: Should execute breakpoint action.
    134132PASS: Should not pause.
    135 -- Running test teardown.
    136133
    137134-- Running test case: DOMDebugger.Event.Interval.Options.Actions.Evaluate
     
    163160PASS: Should execute breakpoint action.
    164161PASS: Should not pause.
    165 -- Running test teardown.
    166162
  • trunk/LayoutTests/inspector/dom-debugger/event-interval-breakpoints.html

    r266074 r266538  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="../debugger/resources/breakpoint-options-utilities.js"></script>
    56<script src="../debugger/resources/log-active-stack-trace.js"></script>
    67<script src="resources/event-breakpoint-utilities.js"></script>
     
    145146    });
    146147
    147     InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases(suite, WI.EventBreakpoint.Type.Interval, eventName);
     148    InspectorTest.BreakpointOptions.addTestCases(suite, {
     149        createBreakpoint() {
     150            return InspectorTest.EventBreakpoint.createBreakpoint(WI.EventBreakpoint.Type.Interval, {eventName});
     151        },
     152        triggerBreakpoint() {
     153            return Promise.all([
     154                InspectorTest.awaitEvent("TestPage-" + eventName),
     155                InspectorTest.evaluateInPage(`trigger_${eventName}()`),
     156            ]);
     157        },
     158    });
    148159
    149160    suite.runTestCasesAndFinish();
  • trunk/LayoutTests/inspector/dom-debugger/event-listener-breakpoints-expected.txt

    r266074 r266538  
    146146Triggering breakpoint...
    147147PASS: Should pause.
    148 -- Running test teardown.
    149148
    150149-- Running test case: DOMDebugger.Event.Listener.Options.IgnoreCount
     
    165164Triggering breakpoint...
    166165PASS: Should pause.
    167 -- Running test teardown.
    168166
    169167-- Running test case: DOMDebugger.Event.Listener.Options.Action.Log
     
    195193PASS: Should execute breakpoint action.
    196194PASS: Should not pause.
    197 -- Running test teardown.
    198195
    199196-- Running test case: DOMDebugger.Event.Listener.Options.Actions.Evaluate
     
    225222PASS: Should execute breakpoint action.
    226223PASS: Should not pause.
    227 -- Running test teardown.
    228 
     224
  • trunk/LayoutTests/inspector/dom-debugger/event-listener-breakpoints.html

    r266074 r266538  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="../debugger/resources/breakpoint-options-utilities.js"></script>
    56<script src="../debugger/resources/log-active-stack-trace.js"></script>
    67<script src="resources/event-breakpoint-utilities.js"></script>
     
    222223    });
    223224
    224     InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases(suite, WI.EventBreakpoint.Type.Listener, "click");
     225    InspectorTest.BreakpointOptions.addTestCases(suite, {
     226        createBreakpoint() {
     227            return InspectorTest.EventBreakpoint.createBreakpoint(WI.EventBreakpoint.Type.Listener, {eventName: "click"});
     228        },
     229        triggerBreakpoint() {
     230            return Promise.all([
     231                InspectorTest.awaitEvent("TestPage-click"),
     232                InspectorTest.evaluateInPage(`trigger_click()`),
     233            ]);
     234        },
     235    });
    225236
    226237    suite.runTestCasesAndFinish();
  • trunk/LayoutTests/inspector/dom-debugger/event-timeout-breakpoints-expected.txt

    r266074 r266538  
    6464Triggering breakpoint...
    6565PASS: Should pause.
    66 -- Running test teardown.
    6766
    6867-- Running test case: DOMDebugger.Event.Timer.Options.IgnoreCount
     
    8382Triggering breakpoint...
    8483PASS: Should pause.
    85 -- Running test teardown.
    8684
    8785-- Running test case: DOMDebugger.Event.Timer.Options.Action.Log
     
    113111PASS: Should execute breakpoint action.
    114112PASS: Should not pause.
    115 -- Running test teardown.
    116113
    117114-- Running test case: DOMDebugger.Event.Timer.Options.Actions.Evaluate
     
    143140PASS: Should execute breakpoint action.
    144141PASS: Should not pause.
    145 -- Running test teardown.
    146142
  • trunk/LayoutTests/inspector/dom-debugger/event-timeout-breakpoints.html

    r266074 r266538  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="../debugger/resources/breakpoint-options-utilities.js"></script>
    56<script src="../debugger/resources/log-active-stack-trace.js"></script>
    67<script src="resources/event-breakpoint-utilities.js"></script>
     
    9697    });
    9798
    98     InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases(suite, WI.EventBreakpoint.Type.Timeout, eventName);
     99    InspectorTest.BreakpointOptions.addTestCases(suite, {
     100        createBreakpoint() {
     101            return InspectorTest.EventBreakpoint.createBreakpoint(WI.EventBreakpoint.Type.Timeout, {eventName});
     102        },
     103        triggerBreakpoint() {
     104            return Promise.all([
     105                InspectorTest.awaitEvent("TestPage-" + eventName),
     106                InspectorTest.evaluateInPage(`trigger_${eventName}()`),
     107            ]);
     108        },
     109    });
    99110
    100111    suite.runTestCasesAndFinish();
  • trunk/LayoutTests/inspector/dom-debugger/resources/event-breakpoint-utilities.js

    r266480 r266538  
    11TestPage.registerInitializer(() => {
    22    InspectorTest.EventBreakpoint = {};
    3 
    4     InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases = function(suite, type, eventName) {
    5         async function triggerBreakpoint() {
    6             InspectorTest.log("Triggering breakpoint...");
    7             return Promise.all([
    8                 InspectorTest.awaitEvent("TestPage-" + eventName),
    9                 InspectorTest.evaluateInPage(`trigger_${eventName}()`),
    10             ]);
    11         }
    12 
    13         suite.addTestCase({
    14             name: suite.name + ".Options.Condition",
    15             description: "Check that the debugger will not pause unless the breakpoint has a truthy breakpoint condition.",
    16             async test() {
    17                 let pauseCount = 0;
    18 
    19                 let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
    20                     ++pauseCount;
    21                     WI.debuggerManager.resume();
    22                 });
    23 
    24                 let breakpoint = await InspectorTest.EventBreakpoint.createBreakpoint(type, {eventName});
    25 
    26                 InspectorTest.newline();
    27 
    28                 InspectorTest.log("Setting condition to 'false'...");
    29                 breakpoint.condition = "false";
    30 
    31                 for (let i = 1; i <= 4; ++i) {
    32                     if (i === 3) {
    33                         InspectorTest.newline();
    34 
    35                         InspectorTest.log("Setting condition to 'true'...");
    36                         breakpoint.condition = "true";
    37                     }
    38 
    39                     InspectorTest.newline();
    40 
    41                     await triggerBreakpoint();
    42 
    43                     if (i <= 2)
    44                         InspectorTest.expectEqual(pauseCount, 0, "Should not pause.");
    45                     else
    46                         InspectorTest.expectEqual(pauseCount, i - 2, "Should pause.");
    47                 }
    48 
    49                 WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    50             },
    51             teardown: InspectorTest.EventBreakpoint.teardown,
    52         });
    53 
    54         suite.addTestCase({
    55             name: suite.name + ".Options.IgnoreCount",
    56             description: "Check that the debugger will not pause unless the breakpoint is hit at least as many times as it's `ignoreCount`.",
    57             async test() {
    58                 let pauseCount = 0;
    59 
    60                 let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
    61                     ++pauseCount;
    62                     WI.debuggerManager.resume();
    63                 });
    64 
    65                 let breakpoint = await InspectorTest.EventBreakpoint.createBreakpoint(type, {eventName});
    66 
    67                 InspectorTest.newline();
    68 
    69                 InspectorTest.log("Setting ignoreCount to '2'...");
    70                 breakpoint.ignoreCount = 2;
    71 
    72                 for (let i = 1; i <=4; ++i) {
    73                     InspectorTest.newline();
    74 
    75                     await triggerBreakpoint();
    76 
    77                     if (i <= 2)
    78                         InspectorTest.expectEqual(pauseCount, 0, "Should not pause.");
    79                     else
    80                         InspectorTest.expectEqual(pauseCount, i - 2, "Should pause.");
    81                 }
    82 
    83                 WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    84             },
    85             teardown: InspectorTest.EventBreakpoint.teardown,
    86         });
    87 
    88         suite.addTestCase({
    89             name: suite.name + ".Options.Action.Log",
    90             description: "Check that log breakpoint actions execute when the breakpoint is hit.",
    91             async test() {
    92                 let pauseCount = 0;
    93 
    94                 let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
    95                     ++pauseCount;
    96                     WI.debuggerManager.resume();
    97                 });
    98 
    99                 let breakpoint = await InspectorTest.EventBreakpoint.createBreakpoint(type, {eventName});
    100 
    101                 InspectorTest.newline();
    102 
    103                 InspectorTest.log("Adding log action...");
    104                 let action = new WI.BreakpointAction(WI.BreakpointAction.Type.Log, {data: "BREAKPOINT ACTION LOG 1"});
    105                 breakpoint.addAction(action);
    106 
    107                 for (let i = 1; i <= 4; ++i) {
    108                     if (i > 1) {
    109                         InspectorTest.newline();
    110 
    111                         InspectorTest.log("Editing log action...");
    112                         action.data = `BREAKPOINT ACTION LOG ${i}`;
    113 
    114                         if (i === 3) {
    115                             InspectorTest.log("Enabling auto-continue...");
    116                             breakpoint.autoContinue = true;
    117                         }
    118                     }
    119 
    120                     InspectorTest.newline();
    121 
    122                     let [messageAddedEvent] = await Promise.all([
    123                         WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded),
    124                         triggerBreakpoint(),
    125                     ]);
    126 
    127                     InspectorTest.expectEqual(messageAddedEvent.data.message.messageText, action.data, "Should execute breakpoint action.");
    128 
    129                     if (i <= 2)
    130                         InspectorTest.expectEqual(pauseCount, i, "Should pause.");
    131                     else
    132                         InspectorTest.expectEqual(pauseCount, 2, "Should not pause.");
    133                 }
    134 
    135                 WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    136             },
    137             teardown: InspectorTest.EventBreakpoint.teardown,
    138         });
    139 
    140         suite.addTestCase({
    141             name: suite.name + ".Options.Actions.Evaluate",
    142             description: "Check that evaluate breakpoint actions execute when the breakpoint is hit.",
    143             async test() {
    144                 let pauseCount = 0;
    145 
    146                 let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
    147                     ++pauseCount;
    148                     WI.debuggerManager.resume();
    149                 });
    150 
    151                 let breakpoint = await InspectorTest.EventBreakpoint.createBreakpoint(type, {eventName});
    152 
    153                 InspectorTest.newline();
    154 
    155                 InspectorTest.log("Adding evaluate action...");
    156                 let action = new WI.BreakpointAction(WI.BreakpointAction.Type.Evaluate, {data: "window.BREAKPOINT_ACTION_EVALUATE = 1;"});
    157                 breakpoint.addAction(action);
    158 
    159                 for (let i = 1; i <= 4; ++i) {
    160                     if (i > 1) {
    161                         InspectorTest.newline();
    162 
    163                         InspectorTest.log("Editing evaluate action...");
    164                         action.data = `window.BREAKPOINT_ACTION_EVALUATE = ${i};`;
    165 
    166                         if (i === 3) {
    167                             InspectorTest.log("Enabling auto-continue...");
    168                             breakpoint.autoContinue = true;
    169                         }
    170                     }
    171 
    172                     InspectorTest.newline();
    173 
    174                     await triggerBreakpoint();
    175 
    176                     let breakpointActionEvaluateResult = await InspectorTest.evaluateInPage(`window.BREAKPOINT_ACTION_EVALUATE`);
    177                     InspectorTest.expectEqual(breakpointActionEvaluateResult, i, "Should execute breakpoint action.");
    178 
    179                     if (i <= 2)
    180                         InspectorTest.expectEqual(pauseCount, i, "Should pause.");
    181                     else
    182                         InspectorTest.expectEqual(pauseCount, 2, "Should not pause.");
    183                 }
    184 
    185                 WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    186             },
    187             teardown: InspectorTest.EventBreakpoint.teardown,
    188         });
    189     };
    1903
    1914    InspectorTest.EventBreakpoint.teardown = function(resolve, reject) {
  • trunk/LayoutTests/inspector/dom-debugger/url-breakpoints-expected.txt

    r239703 r266538  
    33
    44== Running test suite: URLBreakpoint
    5 -- Running test case: URLBreakpoint.BreakOnAll.Fetch
    6 Set pause on all requests.
    7 Request Fetch "resources/dataFetch.json"...
    8 PAUSED:
    9 PASS: Pause reason should be Fetch.
    10 PASS: Pause data URL should be empty.
    11 CALL STACK:
    12 0: [F] loadResourceFetch
    13 1: [P] Global Code
    14 -- Running test teardown.
    15 
    16 -- Running test case: URLBreakpoint.BreakOnContainingText.Fetch
    17 PASS: Added breakpoint for URL: data
    18 PASS: Breakpoint should not be disabled initially.
    19 Request Fetch "resources/dataFetch.json"...
    20 PAUSED:
    21 PASS: Pause reason should be Fetch.
    22 PASS: Pause data URL should match breakpoint URL.
    23 CALL STACK:
    24 0: [F] loadResourceFetch
    25 1: [P] Global Code
    26 -- Running test teardown.
    27 
    28 -- Running test case: URLBreakpoint.BreakOnMatchingRegularExpression.Fetch
    29 PASS: Added breakpoint for URL: data[A-Z]*.(json|txt|png)
    30 PASS: Breakpoint should not be disabled initially.
    31 Request Fetch "resources/dataFetch.json"...
    32 PAUSED:
    33 PASS: Pause reason should be Fetch.
    34 PASS: Pause data URL should match breakpoint URL.
    35 CALL STACK:
    36 0: [F] loadResourceFetch
    37 1: [P] Global Code
    38 -- Running test teardown.
    39 
    405-- Running test case: URLBreakpoint.ShouldNotPauseOnDisabledBreakpoint.Fetch
    41 PASS: Added breakpoint for URL: data
    42 PASS: Breakpoint should not be disabled initially.
    43 Breakpoint disabled.
     6Adding "text:data" URL Breakpoint...
     7Disabling breakpoint...
    448Request Fetch "resources/dataFetch.json"...
    459PASS: Should not pause for disabled breakpoint.
     
    4711
    4812-- Running test case: URLBreakpoint.ShouldNotPauseOnNotContainingURL.Fetch
    49 PASS: Added breakpoint for URL: nonexistant-url
    50 PASS: Breakpoint should not be disabled initially.
     13Adding "text:nonexistant-url" URL Breakpoint...
    5114Request Fetch "resources/dataFetch.json"...
    5215PASS: Should not pause for breakpoint with different URL.
     
    5417
    5518-- Running test case: URLBreakpoint.RemoveBreakpoint.Fetch
    56 PASS: Added breakpoint for URL: data
    57 PASS: Breakpoint should not be disabled initially.
    58 Breakpoint removed.
     19Adding "text:data" URL Breakpoint...
     20Removing breakpoint...
    5921Request Fetch "resources/dataFetch.json"...
    6022PASS: Should not pause for removed breakpoint.
     
    6224
    6325-- Running test case: URLBreakpoint.RemoveDisabledBreakpoint.Fetch
    64 PASS: Added breakpoint for URL: data
    65 PASS: Breakpoint should not be disabled initially.
    66 Breakpoint disabled.
    67 Breakpoint removed.
     26Adding "text:data" URL Breakpoint...
     27Disabling breakpoint...
     28Removing breakpoint...
    6829Request Fetch "resources/dataFetch.json"...
    6930PASS: Should not pause for removed disabled breakpoint.
    7031-- Running test teardown.
    7132
    72 -- Running test case: URLBreakpoint.BreakOnAll.XHR
    73 Set pause on all requests.
    74 Request XHR "resources/dataXHR.json"...
    75 PAUSED:
    76 PASS: Pause reason should be XHR.
    77 PASS: Pause data URL should be empty.
    78 CALL STACK:
    79 0: [F] loadResourceXHR
    80 1: [P] Global Code
    81 -- Running test teardown.
    82 
    83 -- Running test case: URLBreakpoint.BreakOnContainingText.XHR
    84 PASS: Added breakpoint for URL: data
    85 PASS: Breakpoint should not be disabled initially.
    86 Request XHR "resources/dataXHR.json"...
    87 PAUSED:
    88 PASS: Pause reason should be XHR.
    89 PASS: Pause data URL should match breakpoint URL.
    90 CALL STACK:
    91 0: [F] loadResourceXHR
    92 1: [P] Global Code
    93 -- Running test teardown.
    94 
    95 -- Running test case: URLBreakpoint.BreakOnMatchingRegularExpression.XHR
    96 PASS: Added breakpoint for URL: data[A-Z]*.(json|txt|png)
    97 PASS: Breakpoint should not be disabled initially.
    98 Request XHR "resources/dataXHR.json"...
    99 PAUSED:
    100 PASS: Pause reason should be XHR.
    101 PASS: Pause data URL should match breakpoint URL.
    102 CALL STACK:
    103 0: [F] loadResourceXHR
    104 1: [P] Global Code
    105 -- Running test teardown.
    106 
    10733-- Running test case: URLBreakpoint.ShouldNotPauseOnDisabledBreakpoint.XHR
    108 PASS: Added breakpoint for URL: data
    109 PASS: Breakpoint should not be disabled initially.
    110 Breakpoint disabled.
     34Adding "text:data" URL Breakpoint...
     35Disabling breakpoint...
    11136Request XHR "resources/dataXHR.json"...
    11237PASS: Should not pause for disabled breakpoint.
     
    11439
    11540-- Running test case: URLBreakpoint.ShouldNotPauseOnNotContainingURL.XHR
    116 PASS: Added breakpoint for URL: nonexistant-url
    117 PASS: Breakpoint should not be disabled initially.
     41Adding "text:nonexistant-url" URL Breakpoint...
    11842Request XHR "resources/dataXHR.json"...
    11943PASS: Should not pause for breakpoint with different URL.
     
    12145
    12246-- Running test case: URLBreakpoint.RemoveBreakpoint.XHR
    123 PASS: Added breakpoint for URL: data
    124 PASS: Breakpoint should not be disabled initially.
    125 Breakpoint removed.
     47Adding "text:data" URL Breakpoint...
     48Removing breakpoint...
    12649Request XHR "resources/dataXHR.json"...
    12750PASS: Should not pause for removed breakpoint.
     
    12952
    13053-- Running test case: URLBreakpoint.RemoveDisabledBreakpoint.XHR
    131 PASS: Added breakpoint for URL: data
    132 PASS: Breakpoint should not be disabled initially.
    133 Breakpoint disabled.
    134 Breakpoint removed.
     54Adding "text:data" URL Breakpoint...
     55Disabling breakpoint...
     56Removing breakpoint...
    13557Request XHR "resources/dataXHR.json"...
    13658PASS: Should not pause for removed disabled breakpoint.
  • trunk/LayoutTests/inspector/dom-debugger/url-breakpoints.html

    r239703 r266538  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="../debugger/resources/breakpoint-options-utilities.js"></script>
    56<script src="../debugger/resources/log-active-stack-trace.js"></script>
    67<script src="../worker/resources/resource-utilities.js"></script>
     8<script src="resources/url-breakpoint-utilities.js"></script>
    79<script>
    810function test()
     
    1012    let suite = InspectorTest.createAsyncSuite("URLBreakpoint");
    1113
    12     function request(type) {
    13         let url = `resources/data${type}.json`;
    14         InspectorTest.log(`Request ${type} "${url}"...`);
    15         return InspectorTest.evaluateInPage(`loadResource${type}("${url}")`);
    16     }
    17 
    18     function teardown(resolve) {
    19         let breakpoints = WI.domDebuggerManager.urlBreakpoints;
    20         for (let breakpoint of breakpoints)
    21             WI.domDebuggerManager.removeURLBreakpoint(breakpoint);
    22 
    23         WI.domDebuggerManager.allRequestsBreakpoint.disabled = true;
    24         resolve();
    25     }
    26 
    27     function addBreakpoint(type, url) {
    28         return new Promise((resolve, reject) => {
    29             let mainFrame = WI.networkManager.mainFrame;
    30             InspectorTest.assert(mainFrame, "Missing main frame.");
    31             if (!mainFrame)
    32                 reject();
    33 
    34             let breakpoint = new WI.URLBreakpoint(type, url);
    35             WI.domDebuggerManager.awaitEvent(WI.DOMDebuggerManager.Event.URLBreakpointAdded)
    36             .then(() => {
    37                 InspectorTest.pass("Added breakpoint for URL: " + url);
    38                 InspectorTest.expectFalse(breakpoint.disabled, "Breakpoint should not be disabled initially.");
    39                 resolve(breakpoint);
    40             });
    41 
    42             WI.domDebuggerManager.addURLBreakpoint(breakpoint);
    43         });
    44     }
    45 
    46     for (let type of ["Fetch", "XHR"]) {
     14    for (let api of ["Fetch", "XHR"]) {
    4715        suite.addTestCase({
    48             name: "URLBreakpoint.BreakOnAll." + type,
    49             description: "Check that debugger pauses for all requests.",
    50             teardown,
    51             test(resolve, reject) {
    52                 InspectorTest.log("Set pause on all requests.");
    53                 WI.domDebuggerManager.allRequestsBreakpoint.disabled = false;
    54 
    55                 request(type);
    56 
    57                 WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused)
    58                 .then(() => {
    59                     let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
    60                     InspectorTest.log("PAUSED:");
    61                     InspectorTest.expectEqual(targetData.pauseReason, WI.DebuggerManager.PauseReason[type], `Pause reason should be ${type}.`);
    62                     InspectorTest.expectFalse(targetData.pauseData.breakpointURL, "Pause data URL should be empty.");
    63 
    64                     logActiveStackTrace();
    65 
    66                     return WI.debuggerManager.resume();
    67                 })
    68                 .then(resolve, reject);
    69             }
    70         });
    71 
    72         suite.addTestCase({
    73             name: "URLBreakpoint.BreakOnContainingText." + type,
    74             description: "Check that debugger pauses on a URL containing text.",
    75             teardown,
    76             test(resolve, reject) {
    77                 let expectedBreakpointURL;
    78 
    79                 addBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    80                 .then((breakpoint) => {
    81                     expectedBreakpointURL = breakpoint.url;
    82 
    83                     request(type);
    84                     return WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
    85                 })
    86                 .then(() => {
    87                     let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
    88                     InspectorTest.log("PAUSED:");
    89                     InspectorTest.expectEqual(targetData.pauseReason, WI.DebuggerManager.PauseReason[type], `Pause reason should be ${type}.`);
    90                     InspectorTest.expectEqual(targetData.pauseData.breakpointURL, expectedBreakpointURL, "Pause data URL should match breakpoint URL.");
    91 
    92                     logActiveStackTrace();
    93 
    94                     return WI.debuggerManager.resume();
    95                 })
    96                 .then(resolve, reject);
    97             }
    98         });
    99 
    100         suite.addTestCase({
    101             name: "URLBreakpoint.BreakOnMatchingRegularExpression." + type,
    102             description: "Check that debugger pauses based on a URL matching a regex pattern.",
    103             teardown,
    104             test(resolve, reject) {
    105                 let expectedBreakpointURL;
    106                 addBreakpoint(WI.URLBreakpoint.Type.RegularExpression, "data[A-Z]*\.(json|txt|png)")
    107                 .then((breakpoint) => {
    108                     expectedBreakpointURL = breakpoint.url;
    109 
    110                     request(type);
    111                     return WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
    112                 })
    113                 .then(() => {
    114                     let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
    115                     InspectorTest.log("PAUSED:");
    116                     InspectorTest.expectEqual(targetData.pauseReason, WI.DebuggerManager.PauseReason[type], `Pause reason should be ${type}.`);
    117                     InspectorTest.expectEqual(targetData.pauseData.breakpointURL, expectedBreakpointURL, "Pause data URL should match breakpoint URL.");
    118 
    119                     logActiveStackTrace();
    120 
    121                     return WI.debuggerManager.resume();
    122                 })
    123                 .then(resolve, reject);
    124             }
    125         });
    126 
    127         suite.addTestCase({
    128             name: "URLBreakpoint.ShouldNotPauseOnDisabledBreakpoint." + type,
     16            name: "URLBreakpoint.ShouldNotPauseOnDisabledBreakpoint." + api,
    12917            description: "Check that debugger does not pause for disabled breakpoint.",
    130             teardown,
    131             test(resolve, reject) {
     18            async test() {
    13219                let paused = false;
    13320                let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
     
    13623                });
    13724
    138                 addBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    139                 .then((breakpoint) => {
    140                     breakpoint.disabled = true;
    141                     InspectorTest.log("Breakpoint disabled.");
     25                let breakpoint = await InspectorTest.URLBreakpoint.createBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    14226
    143                     return request(type);
    144                 })
    145                 .then(() => {
    146                     InspectorTest.expectFalse(paused, "Should not pause for disabled breakpoint.");
    147                     WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    148                     resolve();
    149                 })
    150                 .catch(reject);
    151             }
     27                InspectorTest.log("Disabling breakpoint...");
     28                breakpoint.disabled = true;
     29
     30                await InspectorTest.URLBreakpoint.request(api);
     31
     32                InspectorTest.expectFalse(paused, "Should not pause for disabled breakpoint.");
     33                WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
     34            },
     35            teardown: InspectorTest.URLBreakpoint.teardown,
    15236        });
    15337
    15438        suite.addTestCase({
    155             name: "URLBreakpoint.ShouldNotPauseOnNotContainingURL." + type,
     39            name: "URLBreakpoint.ShouldNotPauseOnNotContainingURL." + api,
    15640            description: "Check that debugger does not pause for breakpoint with different URL.",
    157             teardown,
    158             test(resolve, reject) {
     41            async test() {
    15942                let paused = false;
    16043                let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
     
    16346                });
    16447
    165                 addBreakpoint(WI.URLBreakpoint.Type.Text, "nonexistant-url")
    166                 .then((breakpoint) => {
    167                     return request(type);
    168                 })
    169                 .then(() => {
    170                     InspectorTest.expectFalse(paused, "Should not pause for breakpoint with different URL.");
    171                     WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    172                     resolve();
    173                 })
    174                 .catch(reject);
    175             }
     48                let breakpoint = await InspectorTest.URLBreakpoint.createBreakpoint(WI.URLBreakpoint.Type.Text, "nonexistant-url")
     49
     50                await InspectorTest.URLBreakpoint.request(api);
     51
     52                InspectorTest.expectFalse(paused, "Should not pause for breakpoint with different URL.");
     53                WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
     54            },
     55            teardown: InspectorTest.URLBreakpoint.teardown,
    17656        });
    17757
    17858        suite.addTestCase({
    179             name: "URLBreakpoint.RemoveBreakpoint." + type,
     59            name: "URLBreakpoint.RemoveBreakpoint." + api,
    18060            description: "Check that debugger does not pause for removed breakpoint.",
    181             teardown,
    182             test(resolve, reject) {
     61            async test() {
    18362                let paused = false;
    18463                let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
     
    18766                });
    18867
    189                 addBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    190                 .then((breakpoint) => {
    191                     WI.domDebuggerManager.removeURLBreakpoint(breakpoint);
    192                     InspectorTest.log("Breakpoint removed.");
     68                let breakpoint = await InspectorTest.URLBreakpoint.createBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    19369
    194                     return request(type);
    195                 })
    196                 .then(() => {
    197                     InspectorTest.expectFalse(paused, "Should not pause for removed breakpoint.");
    198                     WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    199                     resolve();
    200                 })
    201                 .catch(reject);
    202             }
     70                InspectorTest.log("Removing breakpoint...");
     71                breakpoint.remove();
     72
     73                await InspectorTest.URLBreakpoint.request(api);
     74
     75                InspectorTest.expectFalse(paused, "Should not pause for removed breakpoint.");
     76                WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
     77            },
     78            teardown: InspectorTest.URLBreakpoint.teardown,
    20379        });
    20480
    20581        suite.addTestCase({
    206             name: "URLBreakpoint.RemoveDisabledBreakpoint." + type,
     82            name: "URLBreakpoint.RemoveDisabledBreakpoint." + api,
    20783            description: "Check that a disabled breakpoint can be removed.",
    208             teardown,
    209             test(resolve, reject) {
     84            async test() {
    21085                let paused = false;
    21186                let listener = WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.Paused, (event) => {
     
    21489                });
    21590
    216                 addBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    217                 .then((breakpoint) => {
    218                     breakpoint.disabled = true;
    219                     InspectorTest.log("Breakpoint disabled.");
     91                let breakpoint = await InspectorTest.URLBreakpoint.createBreakpoint(WI.URLBreakpoint.Type.Text, "data")
    22092
    221                     WI.domDebuggerManager.removeURLBreakpoint(breakpoint);
    222                     InspectorTest.log("Breakpoint removed.");
     93                InspectorTest.log("Disabling breakpoint...");
     94                breakpoint.disabled = true;
    22395
    224                     return request(type);
    225                 })
    226                 .then(() => {
    227                     InspectorTest.expectFalse(paused, "Should not pause for removed disabled breakpoint.");
    228                     WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
    229                     resolve();
    230                 })
    231                 .catch(reject);
    232             }
     96                InspectorTest.log("Removing breakpoint...");
     97                breakpoint.remove();
     98
     99                await InspectorTest.URLBreakpoint.request(api);
     100
     101                InspectorTest.expectFalse(paused, "Should not pause for removed disabled breakpoint.");
     102                WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
     103            },
     104            teardown: InspectorTest.URLBreakpoint.teardown,
    233105        });
    234106    }
  • trunk/Source/JavaScriptCore/ChangeLog

    r266534 r266538  
     12020-09-03  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: allow url breakpoints to be configured
     4        https://bugs.webkit.org/show_bug.cgi?id=215793
     5
     6        Reviewed by Brian Burg.
     7
     8        * inspector/protocol/DOMDebugger.json:
     9        Add an `options` parameter to `DOMDebugger.setURLBreakpoint` to allow configuration.
     10        Add an `isRegex` parameter to `DOMDebugger.removeURLBreakpoint` so that we know what
     11        type of URL breakpoint is being removed.
     12
    1132020-09-03  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/JavaScriptCore/inspector/protocol/DOMDebugger.json

    r266074 r266538  
    5757            "parameters": [
    5858                { "name": "url", "type": "string", "description": "Resource URL substring or regular expression. All requests having this substring in the URL will get stopped upon. An empty string will pause on all requests." },
    59                 { "name": "isRegex", "type": "boolean", "optional": true, "description": "Whether the URL string is a regular expression." }
     59                { "name": "isRegex", "type": "boolean", "optional": true, "description": "Whether the URL string is a regular expression." },
     60                { "name": "options", "$ref": "Debugger.BreakpointOptions", "optional": true, "description": "Options to apply to this breakpoint to modify its behavior." }
    6061            ]
    6162        },
     
    6465            "description": "Removes breakpoint from network activity for the given URL.",
    6566            "parameters": [
    66                 { "name": "url", "type": "string", "description": "Resource URL substring. An empty string will stop pausing on all requests." }
     67                { "name": "url", "type": "string", "description": "Resource URL substring. An empty string will stop pausing on all requests." },
     68                { "name": "isRegex", "type": "boolean", "optional": true, "description": "Whether the URL string is a regular expression." }
    6769            ]
    6870        }
  • trunk/Source/WebCore/ChangeLog

    r266533 r266538  
     12020-09-03  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: allow url breakpoints to be configured
     4        https://bugs.webkit.org/show_bug.cgi?id=215793
     5
     6        Reviewed by Brian Burg.
     7
     8        Tests: inspector/dom-debugger/url-breakpoints.html
     9               inspector/dom-debugger/url-breakpoints-all-requests.html
     10               inspector/dom-debugger/url-breakpoints-containing.html
     11               inspector/dom-debugger/url-breakpoints-matching.html
     12
     13        * inspector/agents/InspectorDOMDebuggerAgent.h:
     14        * inspector/agents/InspectorDOMDebuggerAgent.cpp:
     15        (WebCore::InspectorDOMDebuggerAgent::disable):
     16        (WebCore::InspectorDOMDebuggerAgent::setURLBreakpoint):
     17        (WebCore::InspectorDOMDebuggerAgent::removeURLBreakpoint):
     18        (WebCore::InspectorDOMDebuggerAgent::breakOnURLIfNeeded):
     19
    1202020-09-03  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp

    r266074 r266538  
    8181    m_pauseOnAllTimeoutsBreakpoint = nullptr;
    8282
    83     m_urlBreakpoints.clear();
    84     m_pauseOnAllURLsEnabled = false;
     83    m_urlTextBreakpoints.clear();
     84    m_urlRegexBreakpoints.clear();
     85    m_pauseOnAllURLsBreakpoint = nullptr;
    8586}
    8687
     
    329330}
    330331
    331 void InspectorDOMDebuggerAgent::setURLBreakpoint(ErrorString& errorString, const String& url, const bool* optionalIsRegex)
    332 {
     332void InspectorDOMDebuggerAgent::setURLBreakpoint(ErrorString& errorString, const String& url, const bool* optionalIsRegex, const JSON::Object* optionsPayload)
     333{
     334    auto breakpoint = InspectorDebuggerAgent::debuggerBreakpointFromPayload(errorString, optionsPayload);
     335    if (!breakpoint)
     336        return;
     337
    333338    if (url.isEmpty()) {
    334         if (m_pauseOnAllURLsEnabled)
     339        if (!m_pauseOnAllURLsBreakpoint)
     340            m_pauseOnAllURLsBreakpoint = WTFMove(breakpoint);
     341        else
    335342            errorString = "Breakpoint for all URLs already exists"_s;
    336         m_pauseOnAllURLsEnabled = true;
    337         return;
    338     }
    339 
    340     bool isRegex = optionalIsRegex ? *optionalIsRegex : false;
    341     auto result = m_urlBreakpoints.set(url, isRegex ? URLBreakpointType::RegularExpression : URLBreakpointType::Text);
    342     if (!result.isNewEntry)
    343         errorString = "Breakpoint for given url already exists"_s;
    344 }
    345 
    346 void InspectorDOMDebuggerAgent::removeURLBreakpoint(ErrorString& errorString, const String& url)
     343        return;
     344    }
     345
     346    if (optionalIsRegex && *optionalIsRegex) {
     347        if (!m_urlRegexBreakpoints.add(url, breakpoint.releaseNonNull()))
     348            errorString = "Breakpoint for given regex already exists"_s;
     349    } else {
     350        if (!m_urlTextBreakpoints.add(url, breakpoint.releaseNonNull()))
     351            errorString = "Breakpoint for given URL already exists"_s;
     352    }
     353}
     354
     355void InspectorDOMDebuggerAgent::removeURLBreakpoint(ErrorString& errorString, const String& url, const bool* optionalIsRegex)
    347356{
    348357    if (url.isEmpty()) {
    349         if (!m_pauseOnAllURLsEnabled)
     358        if (!m_pauseOnAllURLsBreakpoint)
    350359            errorString = "Breakpoint for all URLs missing"_s;
    351         m_pauseOnAllURLsEnabled = false;
    352         return;
    353     }
    354 
    355     auto result = m_urlBreakpoints.remove(url);
    356     if (!result)
    357         errorString = "Breakpoint for given url missing"_s;
     360        m_pauseOnAllURLsBreakpoint = nullptr;
     361        return;
     362    }
     363
     364    if (optionalIsRegex && *optionalIsRegex) {
     365        if (!m_urlRegexBreakpoints.remove(url))
     366            errorString = "Missing breakpoint for given regex"_s;
     367    } else {
     368        if (!m_urlTextBreakpoints.remove(url))
     369            errorString = "Missing breakpoint for given URL"_s;
     370    }
    358371}
    359372
     
    363376        return;
    364377
    365     String breakpointURL;
    366     if (m_pauseOnAllURLsEnabled)
    367         breakpointURL = emptyString();
    368     else {
    369         for (auto& [query, type] : m_urlBreakpoints) {
    370             bool isRegex = type == URLBreakpointType::RegularExpression;
    371             auto searchStringType = isRegex ? ContentSearchUtilities::SearchStringType::Regex : ContentSearchUtilities::SearchStringType::ContainsString;
    372             auto regex = ContentSearchUtilities::createRegularExpressionForSearchString(query, false, searchStringType);
     378    constexpr bool caseSensitive = false;
     379
     380    auto breakpointURL = emptyString();
     381    auto breakpoint = m_pauseOnAllURLsBreakpoint.copyRef();
     382    if (!breakpoint) {
     383        for (auto& [query, textBreakpoint] : m_urlTextBreakpoints) {
     384            auto regex = ContentSearchUtilities::createRegularExpressionForSearchString(query, caseSensitive, ContentSearchUtilities::SearchStringType::ContainsString);
    373385            if (regex.match(url) != -1) {
     386                breakpoint = textBreakpoint.copyRef();
    374387                breakpointURL = query;
    375388                break;
     
    377390        }
    378391    }
    379 
    380     if (breakpointURL.isNull())
    381         return;
    382 
    383     Inspector::DebuggerFrontendDispatcher::Reason breakReason;
    384     if (source == URLBreakpointSource::Fetch)
     392    if (!breakpoint) {
     393        for (auto& [query, regexBreakpoint] : m_urlRegexBreakpoints) {
     394            auto regex = ContentSearchUtilities::createRegularExpressionForSearchString(query, caseSensitive, ContentSearchUtilities::SearchStringType::Regex);
     395            if (regex.match(url) != -1) {
     396                breakpoint = regexBreakpoint.copyRef();
     397                breakpointURL = query;
     398                break;
     399            }
     400        }
     401    }
     402    if (!breakpoint)
     403        return;
     404
     405    auto breakReason = Inspector::DebuggerFrontendDispatcher::Reason::Other;
     406    switch (source) {
     407    case URLBreakpointSource::Fetch:
    385408        breakReason = Inspector::DebuggerFrontendDispatcher::Reason::Fetch;
    386     else if (source == URLBreakpointSource::XHR)
     409        break;
     410
     411    case URLBreakpointSource::XHR:
    387412        breakReason = Inspector::DebuggerFrontendDispatcher::Reason::XHR;
    388     else {
    389         ASSERT_NOT_REACHED();
    390         breakReason = Inspector::DebuggerFrontendDispatcher::Reason::Other;
     413        break;
    391414    }
    392415
     
    394417    eventData->setString("breakpointURL", breakpointURL);
    395418    eventData->setString("url", url);
    396     m_debuggerAgent->breakProgram(breakReason, WTFMove(eventData));
     419    m_debuggerAgent->breakProgram(breakReason, WTFMove(eventData), WTFMove(breakpoint));
    397420}
    398421
  • trunk/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.h

    r266074 r266538  
    6666
    6767    // DOMDebuggerBackendDispatcherHandler
    68     void setURLBreakpoint(ErrorString&, const String& url, const bool* optionalIsRegex) final;
    69     void removeURLBreakpoint(ErrorString&, const String& url) final;
     68    void setURLBreakpoint(ErrorString&, const String& url, const bool* isRegex, const JSON::Object* options) final;
     69    void removeURLBreakpoint(ErrorString&, const String& url, const bool* isRegex) final;
    7070    void setEventBreakpoint(ErrorString&, const String& breakpointType, const String* eventName, const JSON::Object* options) final;
    7171    void removeEventBreakpoint(ErrorString&, const String& breakpointType, const String* eventName) final;
     
    105105    RefPtr<JSC::Breakpoint> m_pauseOnAllTimeoutsBreakpoint;
    106106
    107     enum class URLBreakpointType { RegularExpression, Text };
    108     HashMap<String, URLBreakpointType> m_urlBreakpoints;
    109     bool m_pauseOnAllURLsEnabled { false };
     107    HashMap<String, Ref<JSC::Breakpoint>> m_urlTextBreakpoints;
     108    HashMap<String, Ref<JSC::Breakpoint>> m_urlRegexBreakpoints;
     109    RefPtr<JSC::Breakpoint> m_pauseOnAllURLsBreakpoint;
    110110};
    111111
  • trunk/Source/WebInspectorUI/ChangeLog

    r266537 r266538  
     12020-09-03  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: allow url breakpoints to be configured
     4        https://bugs.webkit.org/show_bug.cgi?id=215793
     5
     6        Reviewed by Brian Burg.
     7
     8        * UserInterface/Models/URLBreakpoint.js:
     9        (WI.URLBreakpoint.get editable): Added.
     10        (WI.URLBreakpoint.fromJSON):
     11        (WI.URLBreakpoint.prototype.get editable):
     12
     13        * UserInterface/Controllers/DOMDebuggerManager.js:
     14        (WI.DOMDebuggerManager):
     15        (WI.DOMDebuggerManager.prototype.initializeTarget):
     16        (WI.DOMDebuggerManager.prototype.addURLBreakpoint):
     17        (WI.DOMDebuggerManager.prototype.removeURLBreakpoint):
     18        (WI.DOMDebuggerManager.prototype._setURLBreakpoint): Added.
     19        (WI.DOMDebuggerManager.prototype._removeURLBreakpoint): Added.
     20        (WI.DOMDebuggerManager.prototype._handleURLBreakpointDisabledStateChanged):
     21        (WI.DOMDebuggerManager.prototype._handleURLBreakpointEditablePropertyChanged): Added.
     22        (WI.DOMDebuggerManager.prototype._handleURLBreakpointActionsChanged): Added.
     23        (WI.DOMDebuggerManager.prototype._updateURLBreakpoint): Deleted.
     24
     25        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
     26        (WI.SourcesNavigationSidebarPanel):
     27        (WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu):
     28        (WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu.addToggleForSpecialBreakpoint): Added.
     29        (WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu.addToggleForSpecialEventBreakpoint): Deleted.
     30
     31        * UserInterface/Views/URLBreakpointPopover.js:
     32        (WI.URLBreakpointPopover.get editable):
     33
     34        * UserInterface/Base/Setting.js:
     35
    1362020-09-03  Nikita Vasilyev  <nvasilyev@apple.com>
    237
  • trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js

    r266534 r266538  
    206206    selectedNetworkDetailContentViewIdentifier: new WI.Setting("network-detail-content-view-identifier", "preview"),
    207207    sourceMapsEnabled: new WI.Setting("source-maps-enabled", true),
    208     showAllRequestsBreakpoint: new WI.Setting("show-all-requests-breakpoint", false),
    209208    showCanvasPath: new WI.Setting("show-canvas-path", false),
    210209    showImageGrid: new WI.Setting("show-image-grid", true),
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMDebuggerManager.js

    r266074 r266538  
    4040
    4141        this._urlBreakpoints = [];
    42 
    43         this._allRequestsBreakpointEnabledSetting = new WI.Setting("break-on-all-requests", false);
    44         this._allRequestsBreakpoint = new WI.URLBreakpoint(WI.URLBreakpoint.Type.Text, "", {
    45             disabled: !this._allRequestsBreakpointEnabledSetting.value,
    46         });
     42        this._allRequestsBreakpoint = null;
    4743
    4844        WI.DOMBreakpoint.addEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this._handleDOMBreakpointDisabledStateChanged, this);
     
    5551
    5652        WI.URLBreakpoint.addEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this._handleURLBreakpointDisabledStateChanged, this);
     53        WI.URLBreakpoint.addEventListener(WI.Breakpoint.Event.ConditionDidChange, this._handleURLBreakpointEditablePropertyChanged, this);
     54        WI.URLBreakpoint.addEventListener(WI.Breakpoint.Event.IgnoreCountDidChange, this._handleURLBreakpointEditablePropertyChanged, this);
     55        WI.URLBreakpoint.addEventListener(WI.Breakpoint.Event.AutoContinueDidChange, this._handleURLBreakpointEditablePropertyChanged, this);
     56        WI.URLBreakpoint.addEventListener(WI.Breakpoint.Event.ActionsDidChange, this._handleURLBreakpointActionsChanged, this);
    5757
    5858        WI.domManager.addEventListener(WI.DOMManager.Event.NodeRemoved, this._nodeRemoved, this);
     
    8989        };
    9090
     91        function loadLegacySpecialBreakpoint(shownSettingsKey, enabledSettingsKey, callback) {
     92            if (!WI.Setting.migrateValue(shownSettingsKey))
     93                return;
     94
     95            return callback({
     96                disabled: !WI.Setting.migrateValue(enabledSettingsKey),
     97            });
     98        }
     99
    91100        if (DOMDebuggerManager.supportsDOMBreakpoints()) {
    92101            loadBreakpoints(WI.DOMBreakpoint, WI.objectStores.domBreakpoints, ["dom-breakpoints"], (breakpoint) => {
     
    100109            });
    101110
    102             let loadLegacyGlobalEventBreakpoint = (type, shownSettingsKey, enabledSettingsKey) => {
    103                 if (!WI.Setting.migrateValue(shownSettingsKey))
    104                     return;
    105 
    106                 return new WI.EventBreakpoint(type, {
    107                     disabled: !WI.Setting.migrateValue(enabledSettingsKey),
    108                 });
    109             };
    110             this._allAnimationFramesBreakpoint ??= loadLegacyGlobalEventBreakpoint(WI.EventBreakpoint.Type.AnimationFrame, "show-all-animation-frames-breakpoint", "break-on-all-animation-frames");
    111             this._allIntervalsBreakpoint ??= loadLegacyGlobalEventBreakpoint(WI.EventBreakpoint.Type.Interval, "show-all-inteverals-breakpoint", "break-on-all-intervals");
    112             this._allListenersBreakpoint ??= loadLegacyGlobalEventBreakpoint(WI.EventBreakpoint.Type.Listener, "show-all-listeners-breakpoint", "break-on-all-listeners");
    113             this._allTimeoutsBreakpoint ??= loadLegacyGlobalEventBreakpoint(WI.EventBreakpoint.Type.Timeout, "show-all-timeouts-breakpoint", "break-on-all-timeouts");
     111            this._allAnimationFramesBreakpoint ??= loadLegacySpecialBreakpoint("show-all-animation-frames-breakpoint", "break-on-all-animation-frames", (options) => new WI.EventBreakpoint(WI.EventBreakpoint.Type.AnimationFrame, options));
     112            this._allIntervalsBreakpoint ??= loadLegacySpecialBreakpoint("show-all-inteverals-breakpoint", "break-on-all-intervals", (options) => new WI.EventBreakpoint(WI.EventBreakpoint.Type.Interval, options));
     113            this._allListenersBreakpoint ??= loadLegacySpecialBreakpoint("show-all-listeners-breakpoint", "break-on-all-listeners", (options) => new WI.EventBreakpoint(WI.EventBreakpoint.Type.Listener, options));
     114            this._allTimeoutsBreakpoint ??= loadLegacySpecialBreakpoint("show-all-timeouts-breakpoint", "break-on-all-timeouts", (options) => new WI.EventBreakpoint(WI.EventBreakpoint.Type.Timeout, options));
    114115        }
    115116
     
    118119                this.addURLBreakpoint(breakpoint);
    119120            });
     121
     122            this._allRequestsBreakpoint ??= loadLegacySpecialBreakpoint("show-all-requests-breakpoint", "break-on-all-requests", (options) => new WI.URLBreakpoint(WI.URLBreakpoint.Type.Text, "", options));
    120123        }
    121124    }
     
    143146                this._setEventBreakpoint(this._allTimeoutsBreakpoint, target);
    144147
    145             if (!this._allRequestsBreakpoint.disabled)
    146                 this._updateURLBreakpoint(this._allRequestsBreakpoint, target);
     148            if (this._allRequestsBreakpoint)
     149                this._setURLBreakpoint(this._allRequestsBreakpoint, target);
    147150
    148151            for (let breakpoint of this._listenerBreakpoints) {
     
    153156            for (let breakpoint of this._urlBreakpoints) {
    154157                if (!breakpoint.disabled)
    155                     this._updateURLBreakpoint(breakpoint, target);
     158                    this._setURLBreakpoint(breakpoint, target);
    156159            }
    157160
     
    446449    addURLBreakpoint(breakpoint)
    447450    {
    448         console.assert(breakpoint instanceof WI.URLBreakpoint);
     451        console.assert(breakpoint instanceof WI.URLBreakpoint, breakpoint);
    449452        if (!breakpoint)
    450453            return false;
    451454
    452         if (breakpoint.special) {
    453             this.dispatchEventToListeners(WI.DOMDebuggerManager.Event.URLBreakpointAdded, {breakpoint});
    454             return true;
    455         }
    456 
    457         console.assert(!this._urlBreakpoints.includes(breakpoint), "Already added URL breakpoint.", breakpoint);
    458         if (this._urlBreakpoints.includes(breakpoint))
    459             return false;
    460 
    461         if (this._urlBreakpoints.some((entry) => entry.type === breakpoint.type && entry.url === breakpoint.url))
    462             return false;
    463 
    464         this._urlBreakpoints.push(breakpoint);
     455        console.assert(!breakpoint.special, breakpoint);
     456        if (breakpoint.url) {
     457            if (this._urlBreakpoints.some((entry) => entry.type === breakpoint.type && entry.url === breakpoint.url))
     458                return false;
     459
     460            this._urlBreakpoints.push(breakpoint);
     461        } else {
     462            console.assert(!this._allRequestsBreakpoint, this._allRequestsBreakpoint, breakpoint);
     463            this._allRequestsBreakpoint = breakpoint;
     464        }
     465
     466        WI.debuggerManager.addProbesForBreakpoint(breakpoint);
    465467
    466468        this.dispatchEventToListeners(WI.DOMDebuggerManager.Event.URLBreakpointAdded, {breakpoint});
     
    468470        if (!breakpoint.disabled) {
    469471            for (let target of WI.targets)
    470                 this._updateURLBreakpoint(breakpoint, target);
     472                this._setURLBreakpoint(breakpoint, target);
    471473        }
    472474
     
    479481    removeURLBreakpoint(breakpoint)
    480482    {
    481         console.assert(breakpoint instanceof WI.URLBreakpoint);
     483        console.assert(breakpoint instanceof WI.URLBreakpoint, breakpoint);
    482484        if (!breakpoint)
    483485            return;
    484486
    485         if (breakpoint.special) {
    486             breakpoint.disabled = true;
    487             this.dispatchEventToListeners(WI.DOMDebuggerManager.Event.URLBreakpointRemoved, {breakpoint});
    488             return;
    489         }
    490 
    491         if (!this._urlBreakpoints.includes(breakpoint))
    492             return;
    493 
    494         this._urlBreakpoints.remove(breakpoint, true);
     487        // Disable the breakpoint first, so removing actions doesn't re-add the breakpoint.
     488        breakpoint.disabled = true;
     489        breakpoint.clearActions();
     490
     491        if (breakpoint.url) {
     492            console.assert(this._urlBreakpoints.includes(breakpoint), breakpoint);
     493            if (!this._urlBreakpoints.includes(breakpoint))
     494                return;
     495
     496            this._urlBreakpoints.remove(breakpoint);
     497        } else {
     498            console.assert(this._allRequestsBreakpoint, this._allRequestsBreakpoint);
     499            this._allRequestsBreakpoint = null;
     500        }
    495501
    496502        if (!this._restoringBreakpoints)
    497503            WI.objectStores.urlBreakpoints.deleteObject(breakpoint);
    498504
     505        WI.debuggerManager.removeProbesForBreakpoint(breakpoint);
     506
    499507        this.dispatchEventToListeners(WI.DOMDebuggerManager.Event.URLBreakpointRemoved, {breakpoint});
    500 
    501         if (breakpoint.disabled)
    502             return;
    503 
    504         for (let target of WI.targets) {
    505             // COMPATIBILITY (iOS 12.1): DOMDebugger.removeURLBreakpoint did not exist.
    506             if (target.hasCommand("DOMDebugger.removeURLBreakpoint"))
    507                 target.DOMDebuggerAgent.removeURLBreakpoint(breakpoint.url);
    508             else if (target.hasCommand("DOMDebugger.removeXHRBreakpoint"))
    509                 target.DOMDebuggerAgent.removeXHRBreakpoint(breakpoint.url);
    510         }
    511508    }
    512509
     
    676673            return;
    677674
    678         // COMPATIBILITY (iOS 12): DOMDebugger.setEventBreakpoint did not exist.
     675        // COMPATIBILITY (iOS 10.3): DOMDebugger.setEventListenerBreakpoint did not exist yet.
     676        // COMPATIBILITY (iOS 12.0): DOMDebugger.setEventListenerBreakpoint was replaced by DOMDebugger.setEventBreakpoint.
    679677        if (target.hasCommand("DOMDebugger.setEventListenerBreakpoint")) {
    680678            console.assert(breakpoint.type === WI.EventBreakpoint.Type.Listener);
     
    687685        }
    688686
     687        // COMPATIBILITY (iOS 12.0): DOMDebugger.setEventBreakpoint did not exist yet.
    689688        if (!target.hasCommand("DOMDebugger.setEventBreakpoint"))
    690689            return;
     
    706705            return;
    707706
    708         // COMPATIBILITY (iOS 12): DOMDebugger.removeEventBreakpoint did not exist.
     707        // COMPATIBILITY (iOS 10.3): DOMDebugger.removeEventListenerBreakpoint did not exist yet.
     708        // COMPATIBILITY (iOS 12.0): DOMDebugger.removeEventListenerBreakpoint was replaced by DOMDebugger.removeEventBreakpoint.
    709709        if (target.hasCommand("DOMDebugger.removeEventListenerBreakpoint")) {
    710710            console.assert(breakpoint.type === WI.EventBreakpoint.Type.Listener);
     
    713713        }
    714714
     715        // COMPATIBILITY (iOS 12.0): DOMDebugger.removeEventBreakpoint did not exist yet.
    715716        if (!target.hasCommand("DOMDebugger.removeEventBreakpoint"))
    716717            return;
     
    721722    }
    722723
    723     _updateURLBreakpoint(breakpoint, target)
    724     {
    725         // COMPATIBILITY (iOS 12.1): DOMDebugger.removeURLBreakpoint did not exist.
    726         if (target.hasCommand("DOMDebugger.setXHRBreakpoint") && target.hasCommand("DOMDebugger.removeXHRBreakpoint")) {
    727             if (breakpoint.disabled)
    728                 target.DOMDebuggerAgent.removeXHRBreakpoint(breakpoint.url);
    729             else {
    730                 if (!this._restoringBreakpoints && !WI.debuggerManager.breakpointsDisabledTemporarily)
    731                     WI.debuggerManager.breakpointsEnabled = true;
    732 
    733                 let isRegex = breakpoint.type === WI.URLBreakpoint.Type.RegularExpression;
    734                 target.DOMDebuggerAgent.setXHRBreakpoint(breakpoint.url, isRegex);
    735             }
    736             return;
    737         }
    738 
    739         if (!target.hasCommand("DOMDebugger.setURLBreakpoint") || !target.hasCommand("DOMDebugger.removeURLBreakpoint"))
    740             return;
    741 
    742         if (breakpoint.disabled)
    743             target.DOMDebuggerAgent.removeURLBreakpoint(breakpoint.url);
    744         else {
     724    _setURLBreakpoint(breakpoint, target)
     725    {
     726        console.assert(!breakpoint.disabled, breakpoint);
     727
     728        // COMPATIBILITY (iOS 10.3): DOMDebugger.setXHRBreakpoint did not exist yet.
     729        // COMPATIBILITY (iOS 12.2): DOMDebugger.setXHRBreakpoint was replaced by DOMDebugger.setURLBreakpoint.
     730        if (target.hasCommand("DOMDebugger.setXHRBreakpoint")) {
    745731            if (!this._restoringBreakpoints && !WI.debuggerManager.breakpointsDisabledTemporarily)
    746732                WI.debuggerManager.breakpointsEnabled = true;
    747733
    748734            let isRegex = breakpoint.type === WI.URLBreakpoint.Type.RegularExpression;
    749             target.DOMDebuggerAgent.setURLBreakpoint(breakpoint.url, isRegex);
    750         }
     735            target.DOMDebuggerAgent.setXHRBreakpoint(breakpoint.url, isRegex);
     736            return;
     737        }
     738
     739        // COMPATIBILITY (iOS 12.2): DOMDebugger.setURLBreakpoint did not exist yet.
     740        if (!target.hasCommand("DOMDebugger.setURLBreakpoint"))
     741            return;
     742
     743        if (!this._restoringBreakpoints && !WI.debuggerManager.breakpointsDisabledTemporarily)
     744            WI.debuggerManager.breakpointsEnabled = true;
     745
     746        target.DOMDebuggerAgent.setURLBreakpoint.invoke({
     747            url: breakpoint.url,
     748            isRegex: breakpoint.type === WI.URLBreakpoint.Type.RegularExpression,
     749            options: breakpoint.optionsToProtocol(),
     750        });
     751    }
     752
     753    _removeURLBreakpoint(breakpoint, target)
     754    {
     755        // COMPATIBILITY (iOS 10.3): DOMDebugger.removeXHRBreakpoint did not exist yet.
     756        // COMPATIBILITY (iOS 12.2): DOMDebugger.removeXHRBreakpoint was replaced by DOMDebugger.setURLBreakpoint.
     757        if (target.hasCommand("DOMDebugger.removeXHRBreakpoint")) {
     758            target.DOMDebuggerAgent.removeXHRBreakpoint(breakpoint.url);
     759            return;
     760        }
     761
     762        // COMPATIBILITY (iOS 12.2): DOMDebugger.removeURLBreakpoint did not exist yet.
     763        if (!target.hasCommand("DOMDebugger.removeURLBreakpoint"))
     764            return;
     765
     766        target.DOMDebuggerAgent.removeURLBreakpoint.invoke({
     767            url: breakpoint.url,
     768            isRegex: breakpoint.type === WI.URLBreakpoint.Type.RegularExpression,
     769        });
    751770    }
    752771
     
    795814            return;
    796815
     816        this._restoringBreakpoints = true;
    797817        for (let target of WI.targets) {
    798818            // Clear the old breakpoint from the backend before setting the new one.
    799             this._removeEventBreakpoint(breakpoint, target)
     819            this._removeEventBreakpoint(breakpoint, target);
    800820            this._setEventBreakpoint(breakpoint, target);
    801821        }
     822        this._restoringBreakpoints = false;
    802823    }
    803824
     
    819840        let breakpoint = event.target;
    820841
    821         for (let target of WI.targets)
    822             this._updateURLBreakpoint(breakpoint, target);
    823 
    824         if (breakpoint === this._allRequestsBreakpoint) {
    825             this._allRequestsBreakpointEnabledSetting.value = !breakpoint.disabled;
    826             return;
     842        for (let target of WI.targets) {
     843            if (breakpoint.disabled)
     844                this._removeURLBreakpoint(breakpoint, target);
     845            else
     846                this._setURLBreakpoint(breakpoint, target);
    827847        }
    828848
    829849        if (!this._restoringBreakpoints)
    830850            WI.objectStores.urlBreakpoints.putObject(breakpoint);
     851    }
     852
     853    _handleURLBreakpointEditablePropertyChanged(event)
     854    {
     855        let breakpoint = event.target;
     856
     857        if (!this._restoringBreakpoints)
     858            WI.objectStores.urlBreakpoints.putObject(breakpoint);
     859
     860        if (breakpoint.disabled)
     861            return;
     862
     863        this._restoringBreakpoints = true;
     864        for (let target of WI.targets) {
     865            // Clear the old breakpoint from the backend before setting the new one.
     866            this._removeURLBreakpoint(breakpoint, target)
     867            this._setURLBreakpoint(breakpoint, target);
     868        }
     869        this._restoringBreakpoints = false;
     870    }
     871
     872    _handleURLBreakpointActionsChanged(event)
     873    {
     874        let breakpoint = event.target;
     875
     876        this._handleURLBreakpointEditablePropertyChanged(event);
     877
     878        WI.debuggerManager.updateProbesForBreakpoint(breakpoint);
    831879    }
    832880
  • trunk/Source/WebInspectorUI/UserInterface/Models/URLBreakpoint.js

    r266480 r266538  
    2626WI.URLBreakpoint = class URLBreakpoint extends WI.Breakpoint
    2727{
    28     constructor(type, url, {disabled} = {})
     28    constructor(type, url, {disabled, actions, condition, ignoreCount, autoContinue} = {})
    2929    {
    3030        console.assert(Object.values(WI.URLBreakpoint.Type).includes(type), type);
    3131        console.assert(typeof url === "string", url);
    3232
    33         super({disabled});
     33        super({disabled, actions, condition, ignoreCount, autoContinue});
    3434
    3535        this._type = type;
     
    3939    // Static
    4040
     41    static get editable()
     42    {
     43        // COMPATIBILITY (iOS 14): DOMDebugger.setURLBreakpoint did not have an "options" parameter yet.
     44        return InspectorBackend.hasCommand("DOMDebugger.setURLBreakpoint", "options");
     45    }
     46
    4147    static fromJSON(json)
    4248    {
    4349        return new WI.URLBreakpoint(json.type, json.url, {
    4450            disabled: json.disabled,
     51            condition: json.condition,
     52            actions: json.actions?.map((actionJSON) => WI.BreakpointAction.fromJSON(actionJSON)) || [],
     53            ignoreCount: json.ignoreCount,
     54            autoContinue: json.autoContinue,
    4555        });
    4656    }
     
    7181    {
    7282        return this === WI.domDebuggerManager.allRequestsBreakpoint || super.special;
     83    }
     84
     85    get editable()
     86    {
     87        return WI.URLBreakpoint.editable || super.editable;
    7388    }
    7489
  • trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js

    r266534 r266538  
    410410                this._addBreakpoint(domBreakpoint);
    411411
    412             if (WI.settings.showAllRequestsBreakpoint.value)
    413                 WI.domDebuggerManager.addURLBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
     412            if (WI.domDebuggerManager.allRequestsBreakpoint)
     413                this._addBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
    414414
    415415            for (let urlBreakpoints of WI.domDebuggerManager.urlBreakpoints)
     
    19751975    _populateCreateBreakpointContextMenu(contextMenu)
    19761976    {
    1977         contextMenu.appendCheckboxItem(WI.repeatedUIString.assertionFailures(), () => {
    1978             if (WI.debuggerManager.assertionFailuresBreakpoint)
    1979                 WI.debuggerManager.assertionFailuresBreakpoint.remove();
    1980             else
    1981                 WI.debuggerManager.createAssertionFailuresBreakpoint();
    1982         }, WI.debuggerManager.assertionFailuresBreakpoint);
     1977        function addToggleForSpecialBreakpoint(label, breakpoint, callback) {
     1978            contextMenu.appendCheckboxItem(label, () => {
     1979                if (breakpoint)
     1980                    breakpoint.remove();
     1981                else
     1982                    callback();
     1983            }, !!breakpoint);
     1984        }
     1985
     1986        addToggleForSpecialBreakpoint(WI.repeatedUIString.assertionFailures(), WI.debuggerManager.assertionFailuresBreakpoint, () => {
     1987            WI.debuggerManager.createAssertionFailuresBreakpoint();
     1988        });
    19831989
    19841990        contextMenu.appendSeparator();
    19851991
    19861992        if (WI.JavaScriptBreakpoint.supportsMicrotasks()) {
    1987             contextMenu.appendCheckboxItem(WI.repeatedUIString.allMicrotasks(), () => {
    1988                 if (WI.debuggerManager.allMicrotasksBreakpoint)
    1989                     WI.debuggerManager.allMicrotasksBreakpoint.remove();
    1990                 else
    1991                     WI.debuggerManager.createAllMicrotasksBreakpoint();
    1992             }, WI.debuggerManager.allMicrotasksBreakpoint);
     1993            addToggleForSpecialBreakpoint(WI.repeatedUIString.allMicrotasks(), WI.debuggerManager.allMicrotasksBreakpoint, () => {
     1994                WI.debuggerManager.createAllMicrotasksBreakpoint();
     1995            });
    19931996        }
    19941997
    19951998        if (WI.DOMDebuggerManager.supportsEventBreakpoints() || WI.DOMDebuggerManager.supportsEventListenerBreakpoints()) {
    1996             function addToggleForSpecialEventBreakpoint(label, breakpoint, type) {
    1997                 contextMenu.appendCheckboxItem(label, () => {
    1998                     if (breakpoint)
    1999                         WI.domDebuggerManager.removeEventBreakpoint(breakpoint);
    2000                     else
    2001                         WI.domDebuggerManager.addEventBreakpoint(new WI.EventBreakpoint(type));
    2002                 }, !!breakpoint);
    2003             }
    2004 
    2005             addToggleForSpecialEventBreakpoint(WI.repeatedUIString.allAnimationFrames(), WI.domDebuggerManager.allAnimationFramesBreakpoint, WI.EventBreakpoint.Type.AnimationFrame);
    2006             addToggleForSpecialEventBreakpoint(WI.repeatedUIString.allTimeouts(), WI.domDebuggerManager.allTimeoutsBreakpoint, WI.EventBreakpoint.Type.Timeout);
    2007             addToggleForSpecialEventBreakpoint(WI.repeatedUIString.allIntervals(), WI.domDebuggerManager.allIntervalsBreakpoint, WI.EventBreakpoint.Type.Interval);
     1999            addToggleForSpecialBreakpoint(WI.repeatedUIString.allAnimationFrames(), WI.domDebuggerManager.allAnimationFramesBreakpoint, () => {
     2000                WI.domDebuggerManager.addEventBreakpoint(new WI.EventBreakpoint(WI.EventBreakpoint.Type.AnimationFrame));
     2001            });
     2002            addToggleForSpecialBreakpoint(WI.repeatedUIString.allTimeouts(), WI.domDebuggerManager.allTimeoutsBreakpoint, () => {
     2003                WI.domDebuggerManager.addEventBreakpoint(new WI.EventBreakpoint(WI.EventBreakpoint.Type.Timeout));
     2004            });
     2005            addToggleForSpecialBreakpoint(WI.repeatedUIString.allIntervals(), WI.domDebuggerManager.allIntervalsBreakpoint, () => {
     2006                WI.domDebuggerManager.addEventBreakpoint(new WI.EventBreakpoint(WI.EventBreakpoint.Type.Interval));
     2007            });
    20082008
    20092009            contextMenu.appendSeparator();
    20102010
    20112011            if (WI.DOMDebuggerManager.supportsAllListenersBreakpoint())
    2012                 addToggleForSpecialEventBreakpoint(WI.repeatedUIString.allEvents(), WI.domDebuggerManager.allListenersBreakpoint, WI.EventBreakpoint.Type.Listener);
     2012                addToggleForSpecialBreakpoint(WI.repeatedUIString.allEvents(), WI.domDebuggerManager.allListenersBreakpoint, () => {
     2013                    WI.domDebuggerManager.addEventBreakpoint(new WI.EventBreakpoint(WI.EventBreakpoint.Type.Listener));
     2014                });
    20132015
    20142016            contextMenu.appendItem(WI.UIString("Event Breakpoint\u2026"), () => {
     
    20212023            contextMenu.appendSeparator();
    20222024
    2023             let allRequestsBreakpointShown = WI.settings.showAllRequestsBreakpoint.value;
    2024             contextMenu.appendCheckboxItem(WI.repeatedUIString.allRequests(), () => {
    2025                 if (allRequestsBreakpointShown)
    2026                     WI.domDebuggerManager.removeURLBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
    2027                 else {
    2028                     WI.domDebuggerManager.allRequestsBreakpoint.disabled = false;
    2029                     WI.domDebuggerManager.addURLBreakpoint(WI.domDebuggerManager.allRequestsBreakpoint);
    2030                 }
    2031             }, allRequestsBreakpointShown);
     2025            addToggleForSpecialBreakpoint(WI.repeatedUIString.allRequests(), WI.domDebuggerManager.allRequestsBreakpoint, () => {
     2026                const url = "";
     2027                WI.domDebuggerManager.addURLBreakpoint(new WI.URLBreakpoint(WI.URLBreakpoint.Type.Text, url));
     2028            });
    20322029
    20332030            contextMenu.appendItem(WI.DOMDebuggerManager.supportsURLBreakpoints() ? WI.UIString("URL Breakpoint\u2026") : WI.UIString("XHR Breakpoint\u2026"), () => {
  • trunk/Source/WebInspectorUI/UserInterface/Views/URLBreakpointPopover.js

    r266480 r266538  
    3939    static get supportsEditing()
    4040    {
    41         return false;
     41        return WI.URLBreakpoint.editable;
    4242    }
    4343
Note: See TracChangeset for help on using the changeset viewer.