chrome-devtools-frontend 1.0.1582745 → 1.0.1585538

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/front_end/core/host/InspectorFrontendHostAPI.ts +1 -0
  2. package/front_end/core/host/InspectorFrontendHostStub.ts +2 -0
  3. package/front_end/core/root/Runtime.ts +12 -11
  4. package/front_end/core/sdk/CSSMatchedStyles.ts +3 -0
  5. package/front_end/core/sdk/CSSMetadata.ts +3 -0
  6. package/front_end/core/sdk/NetworkManager.ts +63 -115
  7. package/front_end/entrypoint_template.html +1 -5
  8. package/front_end/entrypoints/main/MainImpl.ts +1 -0
  9. package/front_end/generated/Deprecation.ts +21 -0
  10. package/front_end/generated/InspectorBackendCommands.ts +5 -3
  11. package/front_end/generated/SupportedCSSProperties.js +6 -2
  12. package/front_end/generated/protocol-mapping.d.ts +2 -1
  13. package/front_end/generated/protocol-proxy-api.d.ts +2 -1
  14. package/front_end/generated/protocol.ts +14 -0
  15. package/front_end/models/ai_assistance/AiConversation.ts +34 -2
  16. package/front_end/models/ai_assistance/BuiltInAi.ts +1 -2
  17. package/front_end/models/ai_assistance/agents/AiAgent.ts +3 -10
  18. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +1 -1
  19. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +17 -9
  20. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +0 -24
  21. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -0
  22. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +16 -8
  23. package/front_end/models/computed_style/ComputedStyleModel.ts +20 -15
  24. package/front_end/models/greendev/Prototypes.ts +1 -5
  25. package/front_end/models/issues_manager/CorsIssue.ts +2 -9
  26. package/front_end/models/issues_manager/descriptions/corsLocalNetworkAccessPermissionDenied.md +2 -2
  27. package/front_end/models/javascript_metadata/NativeFunctions.js +20 -0
  28. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +28 -39
  29. package/front_end/panels/ai_assistance/components/ChatInput.ts +73 -95
  30. package/front_end/panels/ai_assistance/components/ChatMessage.ts +4 -2
  31. package/front_end/panels/ai_assistance/components/ChatView.ts +0 -2
  32. package/front_end/panels/autofill/AutofillView.ts +4 -8
  33. package/front_end/panels/common/AiCodeGenerationTeaser.ts +37 -8
  34. package/front_end/panels/console/ConsoleView.ts +1 -2
  35. package/front_end/panels/console/ConsoleViewMessage.ts +18 -11
  36. package/front_end/panels/elements/ComputedStyleWidget.ts +80 -48
  37. package/front_end/panels/elements/ElementStatePaneWidget.ts +1 -1
  38. package/front_end/panels/elements/ElementsPanel.ts +18 -5
  39. package/front_end/panels/elements/ElementsTreeElement.ts +459 -435
  40. package/front_end/panels/elements/EventListenersWidget.ts +2 -4
  41. package/front_end/panels/elements/NodeStackTraceWidget.ts +1 -3
  42. package/front_end/panels/elements/PropertiesWidget.ts +1 -2
  43. package/front_end/panels/elements/StylePropertyTreeElement.ts +18 -2
  44. package/front_end/panels/elements/computedStyleWidget.css +25 -0
  45. package/front_end/panels/issues/AffectedResourcesView.ts +1 -2
  46. package/front_end/panels/network/NetworkDataGridNode.ts +0 -8
  47. package/front_end/panels/network/NetworkLogView.ts +64 -105
  48. package/front_end/panels/network/RequestConditionsDrawer.ts +168 -233
  49. package/front_end/panels/network/network-meta.ts +4 -27
  50. package/front_end/panels/settings/SettingsScreen.ts +12 -4
  51. package/front_end/panels/settings/WorkspaceSettingsTab.ts +1 -1
  52. package/front_end/panels/snippets/SnippetsQuickOpen.ts +6 -9
  53. package/front_end/panels/sources/CallStackSidebarPane.ts +6 -8
  54. package/front_end/panels/sources/DebuggerPlugin.ts +2 -1
  55. package/front_end/panels/sources/GoToLineQuickOpen.ts +0 -4
  56. package/front_end/panels/sources/OpenFileQuickOpen.ts +0 -4
  57. package/front_end/panels/sources/OutlineQuickOpen.ts +0 -4
  58. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +3 -1
  59. package/front_end/panels/sources/sources-meta.ts +9 -6
  60. package/front_end/panels/timeline/TimelineFlameChartView.ts +0 -12
  61. package/front_end/panels/timeline/TimelinePanel.ts +35 -15
  62. package/front_end/panels/timeline/components/Sidebar.ts +21 -0
  63. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +1 -20
  64. package/front_end/panels/timeline/components/insights/InsightRenderer.ts +0 -1
  65. package/front_end/third_party/chromium/README.chromium +1 -1
  66. package/front_end/third_party/puppeteer/README.chromium +2 -2
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts +1 -1
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +1 -1
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +2 -3
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  75. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  76. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.d.ts.map +1 -1
  77. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.js +5 -3
  78. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.js.map +1 -1
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +8 -6
  82. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts +1 -1
  83. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +1 -1
  85. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  86. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +2 -3
  88. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  89. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  90. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  91. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.d.ts.map +1 -1
  92. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.js +5 -3
  93. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.js.map +1 -1
  94. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  95. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  96. package/front_end/third_party/puppeteer/package/package.json +4 -4
  97. package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +1 -1
  98. package/front_end/third_party/puppeteer/package/src/bidi/core/BrowsingContext.ts +2 -2
  99. package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +4 -3
  100. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  101. package/front_end/third_party/puppeteer/package/src/util/encoding.ts +5 -3
  102. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  103. package/front_end/ui/components/linkifier/LinkifierImpl.ts +3 -0
  104. package/front_end/ui/components/linkifier/LinkifierUtils.ts +3 -0
  105. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +8 -0
  106. package/front_end/ui/components/text_editor/AiCodeGenerationParser.ts +29 -7
  107. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +42 -18
  108. package/front_end/ui/components/text_editor/config.ts +6 -0
  109. package/front_end/ui/legacy/InspectorView.ts +41 -15
  110. package/front_end/ui/legacy/Toolbar.ts +12 -4
  111. package/front_end/ui/legacy/UIUtils.ts +56 -7
  112. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +4 -3
  113. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +2 -1
  114. package/front_end/ui/legacy/components/quick_open/HelpQuickOpen.ts +8 -2
  115. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +8 -8
  116. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +12 -9
  117. package/front_end/ui/legacy/components/utils/Linkifier.ts +116 -87
  118. package/front_end/ui/legacy/legacy.ts +0 -2
  119. package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
  120. package/mcp/HostBindings.ts +3 -0
  121. package/package.json +1 -1
  122. package/front_end/models/issues_manager/descriptions/corsInsecurePrivateNetwork.md +0 -10
  123. package/front_end/models/issues_manager/descriptions/corsPreflightAllowPrivateNetworkError.md +0 -10
  124. package/front_end/models/issues_manager/descriptions/corsPrivateNetworkPermissionDenied.md +0 -10
  125. package/front_end/panels/elements/computedStyleSidebarPane.css +0 -18
  126. package/front_end/ui/legacy/Floaty.ts +0 -438
  127. package/front_end/ui/legacy/floaty.css +0 -77
@@ -10,7 +10,6 @@ import '../../ui/components/tooltips/tooltips.js';
10
10
  import type * as Common from '../../core/common/common.js';
11
11
  import * as i18n from '../../core/i18n/i18n.js';
12
12
  import * as Platform from '../../core/platform/platform.js';
13
- import * as Root from '../../core/root/root.js';
14
13
  import * as SDK from '../../core/sdk/sdk.js';
15
14
  import * as Logs from '../../models/logs/logs.js';
16
15
  import * as Buttons from '../../ui/components/buttons/buttons.js';
@@ -28,34 +27,18 @@ const {ref, live} = Directives;
28
27
  const {widgetConfig} = UI.Widget;
29
28
 
30
29
  const UIStrings = {
31
- /**
32
- * @description Text to enable blocking of network requests
33
- */
34
- enableNetworkRequestBlocking: 'Enable network request blocking',
35
30
  /**
36
31
  * @description Text to enable blocking of network requests
37
32
  */
38
33
  enableBlockingAndThrottling: 'Enable blocking and throttling',
39
- /**
40
- * @description Tooltip text that appears when hovering over the plus button in the Blocked URLs Pane of the Network panel
41
- */
42
- addPattern: 'Add pattern',
43
34
  /**
44
35
  * @description Tooltip text that appears when hovering over the plus button in the Blocked URLs Pane of the Network panel
45
36
  */
46
37
  addRule: 'Add rule',
47
- /**
48
- * @description Accessible label for the button to add request blocking patterns in the network request blocking tool
49
- */
50
- addNetworkRequestBlockingPattern: 'Add network request blocking pattern',
51
38
  /**
52
39
  * @description Accessible label for the button to add request blocking patterns in the network request blocking tool
53
40
  */
54
41
  addPatternLabel: 'Add network request throttling or blocking pattern',
55
- /**
56
- * @description Text that shows in the network request blocking panel if no pattern has yet been added.
57
- */
58
- noNetworkRequestsBlocked: 'No blocked network requests',
59
42
  /**
60
43
  * @description Text that shows in the network request blocking panel if no pattern has yet been added.
61
44
  */
@@ -66,25 +49,11 @@ const UIStrings = {
66
49
  */
67
50
  noThrottlingOrBlockingPattern:
68
51
  `To throttle or block a network request, add a rule here manually or via the network panel's context menu. {PH1}`,
69
- /**
70
- * @description Text that shows in the network request blocking panel if no pattern has yet been added.
71
- * @example {Add pattern} PH1
72
- */
73
- addPatternToBlock: 'Add a pattern by clicking on the "{PH1}" button.',
74
- /**
75
- * @description Text in Blocked URLs Pane of the Network panel
76
- * @example {4} PH1
77
- */
78
- dBlocked: '{PH1} blocked',
79
52
  /**
80
53
  * @description Text in Blocked URLs Pane of the Network panel
81
54
  * @example {4} PH1
82
55
  */
83
56
  dAffected: '{PH1} affected',
84
- /**
85
- * @description Text in Blocked URLs Pane of the Network panel
86
- */
87
- textPatternToBlockMatching: 'Text pattern to block matching requests; use * for wildcard',
88
57
  /**
89
58
  * @description Text in Blocked URLs Pane of the Network panel
90
59
  */
@@ -178,7 +147,6 @@ interface ViewInput {
178
147
  }
179
148
  type View = (input: ViewInput, output: object, target: HTMLElement) => void;
180
149
  export const DEFAULT_VIEW: View = (input, output, target) => {
181
- const individualThrottlingEnabled = Boolean(Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled);
182
150
  render(
183
151
  // clang-format off
184
152
  html`
@@ -187,31 +155,24 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
187
155
  ?checked=${input.enabled}
188
156
  @click=${input.toggleEnabled}
189
157
  .jslogContext=${'network.enable-request-blocking'}>
190
- ${individualThrottlingEnabled ? i18nString(UIStrings.enableBlockingAndThrottling)
191
- : i18nString(UIStrings.enableNetworkRequestBlocking)}
158
+ ${i18nString(UIStrings.enableBlockingAndThrottling)}
192
159
  </devtools-checkbox>
193
160
  <div class="toolbar-divider"></div>
194
161
  <devtools-button ${bindToAction('network.add-network-request-blocking-pattern')}></devtools-button>
195
162
  <devtools-button ${bindToAction('network.remove-all-network-request-blocking-patterns')}></devtools-button>
196
163
  </devtools-toolbar>
197
164
  <div class=empty-state ${ref(e => input.list.setEmptyPlaceholder(e ?? null))}>
198
- <span class=empty-state-header>${individualThrottlingEnabled
199
- ? i18nString(UIStrings.noPattern)
200
- : i18nString(UIStrings.noNetworkRequestsBlocked)}</span>
165
+ <span class=empty-state-header>${i18nString(UIStrings.noPattern)}</span>
201
166
  <div class=empty-state-description>
202
- ${individualThrottlingEnabled
203
- ? uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.noThrottlingOrBlockingPattern, {PH1: learnMore()})
204
- : html`<span>${i18nString(UIStrings.addPatternToBlock,
205
- {PH1: i18nString(UIStrings.addPattern)})}</span>${learnMore()}`}
167
+ ${uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.noThrottlingOrBlockingPattern, {PH1: learnMore()})}
206
168
  </div>
207
169
  <devtools-button
208
170
  @click=${input.addPattern}
209
171
  class=add-button
210
172
  .jslogContext=${'network.add-network-request-blocking-pattern'}
211
- title=${individualThrottlingEnabled ? i18nString(UIStrings.addPatternLabel)
212
- : i18nString(UIStrings.addNetworkRequestBlockingPattern)}
173
+ title=${i18nString(UIStrings.addPatternLabel)}
213
174
  .variant=${Buttons.Button.Variant.TONAL}>
214
- ${individualThrottlingEnabled ? i18nString(UIStrings.addRule) : i18nString(UIStrings.addPattern)}
175
+ ${i18nString(UIStrings.addRule)}
215
176
  </devtools-button>
216
177
  </div>
217
178
  <devtools-widget .widgetConfig=${UI.Widget.widgetConfig(UI.Widget.VBox)}>
@@ -222,79 +183,154 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
222
183
  target);
223
184
  };
224
185
 
186
+ function renderItem(
187
+ condition: SDK.NetworkManager.RequestCondition, editable: boolean, index: number,
188
+ onToggle: (condition: SDK.NetworkManager.RequestCondition) => void,
189
+ onConditionsChanged: (
190
+ condition: SDK.NetworkManager.RequestCondition, conditions: SDK.NetworkManager.ThrottlingConditions) => void,
191
+ onIncreasePriority: (condition: SDK.NetworkManager.RequestCondition) => void,
192
+ onDecreasePriority: (condition: SDK.NetworkManager.RequestCondition) => void,
193
+ lookUpRequestCount: (condition: SDK.NetworkManager.RequestCondition) => number): LitTemplate {
194
+ const {enabled, originalOrUpgradedURLPattern, constructorStringOrWildcardURL, wildcardURL} = condition;
195
+ const toggle = (e: Event): void => {
196
+ e.consume(true);
197
+ onToggle(condition);
198
+ };
199
+
200
+ const moveUp = (e: Event): void => {
201
+ e.consume(true);
202
+ onIncreasePriority(condition);
203
+ };
204
+
205
+ const moveDown = (e: Event): void => {
206
+ e.consume(true);
207
+ onDecreasePriority(condition);
208
+ };
209
+
210
+ // clang-format off
211
+ return html`
212
+ <input class=blocked-url-checkbox
213
+ @change=${toggle}
214
+ type=checkbox
215
+ title=${i18nString(UIStrings.enableThrottlingToggleLabel, {PH1: constructorStringOrWildcardURL})}
216
+ .checked=${live(enabled)}
217
+ .disabled=${!editable || !originalOrUpgradedURLPattern}
218
+ jslog=${VisualLogging.toggle().track({ change: true })}>
219
+ <devtools-button
220
+ .iconName=${'arrow-up'}
221
+ .variant=${Buttons.Button.Variant.ICON}
222
+ .title=${i18nString(UIStrings.increasePriority, {PH1: constructorStringOrWildcardURL})}
223
+ .jslogContext=${'decrease-priority'}
224
+ ?disabled=${!editable || !originalOrUpgradedURLPattern}
225
+ @click=${moveUp}>
226
+ </devtools-button>
227
+ <devtools-button
228
+ .iconName=${'arrow-down'}
229
+ .variant=${Buttons.Button.Variant.ICON}
230
+ .title=${i18nString(UIStrings.decreasePriority, {PH1: constructorStringOrWildcardURL})}
231
+ .jslogContext=${'increase-priority'}
232
+ ?disabled=${!editable || !originalOrUpgradedURLPattern}
233
+ @click=${moveDown}></devtools-button>
234
+ ${originalOrUpgradedURLPattern ? html`
235
+ <devtools-tooltip variant=rich jslogcontext=url-pattern id=url-pattern-${index}>
236
+ <div>hash: ${originalOrUpgradedURLPattern.hash}</div>
237
+ <div>hostname: ${originalOrUpgradedURLPattern.hostname}</div>
238
+ <div>password: ${originalOrUpgradedURLPattern.password}</div>
239
+ <div>pathname: ${originalOrUpgradedURLPattern.pathname}</div>
240
+ <div>port: ${originalOrUpgradedURLPattern.port}</div>
241
+ <div>protocol: ${originalOrUpgradedURLPattern.protocol}</div>
242
+ <div>search: ${originalOrUpgradedURLPattern.search}</div>
243
+ <div>username: ${originalOrUpgradedURLPattern.username}</div>
244
+ <hr />
245
+ ${learnMore()}
246
+ </devtools-tooltip>` : nothing}
247
+ ${wildcardURL ? html`
248
+ <devtools-icon name=warning-filled class="small warning" aria-details=url-pattern-warning-${index}>
249
+ </devtools-icon>
250
+ <devtools-tooltip variant=rich jslogcontext=url-pattern-warning id=url-pattern-warning-${index}>
251
+ ${i18nString(UIStrings.patternWasUpgraded, {PH1: wildcardURL})}
252
+ </devtools-tooltip>
253
+ `: nothing}
254
+ ${!originalOrUpgradedURLPattern ? html`
255
+ <devtools-icon name=cross-circle-filled class=small aria-details=url-pattern-error-${index}>
256
+ </devtools-icon>
257
+ <devtools-tooltip variant=rich jslogcontext=url-pattern-warning id=url-pattern-error-${index}>
258
+ ${SDK.NetworkManager.RequestURLPattern.isValidPattern(constructorStringOrWildcardURL) ===
259
+ SDK.NetworkManager.RequestURLPatternValidity.HAS_REGEXP_GROUPS
260
+ ? i18nString(UIStrings.patternFailedWithRegExpGroups)
261
+ : i18nString(UIStrings.patternFailedToParse)}
262
+ ${learnMore()}
263
+ </devtools-tooltip>`: nothing}
264
+ <div
265
+ @click=${toggle}
266
+ ?disabled=${!editable || !originalOrUpgradedURLPattern}
267
+ class=blocked-url-label
268
+ aria-details=url-pattern-${index}>
269
+ ${constructorStringOrWildcardURL}
270
+ </div>
271
+ <devtools-widget
272
+ class=conditions-selector
273
+ title=${i18nString(UIStrings.requestConditionsLabel)}
274
+ .widgetConfig=${UI.Widget.widgetConfig(
275
+ MobileThrottling.NetworkThrottlingSelector.NetworkThrottlingSelectorWidget, {
276
+ variant:
277
+ MobileThrottling.NetworkThrottlingSelector.NetworkThrottlingSelect.Variant.INDIVIDUAL_REQUEST_CONDITIONS,
278
+ jslogContext: 'request-conditions',
279
+ disabled: !editable,
280
+ onConditionsChanged: conditions => onConditionsChanged(condition, conditions),
281
+ currentConditions: condition.conditions,
282
+ })}></devtools-widget>
283
+ <devtools-widget
284
+ ?disabled=${!editable || !originalOrUpgradedURLPattern}
285
+ .widgetConfig=${widgetConfig(AffectedCountWidget, {condition, lookUpRequestCount})}></devtools-widget>`;
286
+ // clang-format on
287
+ }
288
+
225
289
  interface AffectedCountViewInput {
226
290
  count: number;
227
291
  }
228
292
  type AffectedCountView = (input: AffectedCountViewInput, output: object, target: HTMLElement) => void;
229
293
  export const AFFECTED_COUNT_DEFAULT_VIEW: AffectedCountView = (input, output, target) => {
230
- if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
231
- render(html`${i18nString(UIStrings.dAffected, {PH1: input.count})}`, target);
232
- } else {
233
- render(html`${i18nString(UIStrings.dBlocked, {PH1: input.count})}`, target);
234
- }
294
+ render(html`${i18nString(UIStrings.dAffected, {PH1: input.count})}`, target);
235
295
  };
236
296
 
237
297
  function matchesUrl(conditions: SDK.NetworkManager.RequestCondition, url: string): boolean {
238
- function matchesPattern(pattern: string, url: string): boolean {
239
- let pos = 0;
240
- const parts = pattern.split('*');
241
- for (let index = 0; index < parts.length; index++) {
242
- const part = parts[index];
243
- if (!part.length) {
244
- continue;
245
- }
246
- pos = url.indexOf(part, pos);
247
- if (pos === -1) {
248
- return false;
249
- }
250
- pos += part.length;
251
- }
252
- return true;
253
- }
254
-
255
- return Boolean(
256
- Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled ?
257
- conditions.originalOrUpgradedURLPattern?.test(url) :
258
- (conditions.wildcardURL && matchesPattern(conditions.wildcardURL, url)));
298
+ return Boolean(conditions.originalOrUpgradedURLPattern?.test(url));
259
299
  }
260
300
 
261
301
  export class AffectedCountWidget extends UI.Widget.Widget {
262
302
  readonly #view: AffectedCountView;
263
303
  #condition?: SDK.NetworkManager.RequestCondition;
264
- #drawer?: RequestConditionsDrawer;
304
+ #lookUpRequestCount?: (condition: SDK.NetworkManager.RequestCondition) => number;
305
+
265
306
  constructor(target?: HTMLElement, view = AFFECTED_COUNT_DEFAULT_VIEW) {
266
307
  super(target, {classes: ['blocked-url-count']});
267
308
  this.#view = view;
268
309
  }
269
310
 
270
- get condition(): SDK.NetworkManager.RequestCondition|undefined {
271
- return this.#condition;
311
+ get lookUpRequestCount(): ((condition: SDK.NetworkManager.RequestCondition) => number)|undefined {
312
+ return this.#lookUpRequestCount;
272
313
  }
273
314
 
274
- set condition(conditions: SDK.NetworkManager.RequestCondition) {
275
- this.#condition = conditions;
276
- this.requestUpdate();
315
+ set lookUpRequestCount(val: (condition: SDK.NetworkManager.RequestCondition) => number) {
316
+ this.#lookUpRequestCount = val;
277
317
  }
278
318
 
279
- get drawer(): RequestConditionsDrawer|undefined {
280
- return this.#drawer;
319
+ get condition(): SDK.NetworkManager.RequestCondition|undefined {
320
+ return this.#condition;
281
321
  }
282
322
 
283
- set drawer(drawer: RequestConditionsDrawer) {
284
- this.#drawer = drawer;
323
+ set condition(conditions: SDK.NetworkManager.RequestCondition) {
324
+ this.#condition = conditions;
285
325
  this.requestUpdate();
286
326
  }
287
327
 
288
328
  override performUpdate(): void {
289
- if (!this.#condition || !this.#drawer) {
329
+ if (!this.#condition || !this.#lookUpRequestCount) {
290
330
  return;
291
331
  }
292
332
 
293
- const count = !Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled || this.#condition.isBlocking ?
294
- this.#drawer.blockedRequestsCount(this.#condition) :
295
- this.#drawer.throttledRequestsCount(this.#condition);
296
-
297
- this.#view({count}, {}, this.element);
333
+ this.#view({count: this.#lookUpRequestCount(this.#condition)}, {}, this.element);
298
334
  }
299
335
 
300
336
  override wasShown(): void {
@@ -406,129 +442,39 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
406
442
 
407
443
  updateItem(element: HTMLElement, condition: SDK.NetworkManager.RequestCondition, editable: boolean, index: number):
408
444
  void {
409
- const toggle = (e: Event): void => {
445
+ const onToggle = (condition: {enabled: boolean}): void => {
410
446
  if (editable) {
411
- e.consume(true);
412
447
  condition.enabled = !condition.enabled;
413
448
  }
414
449
  };
415
- const onConditionsChanged = (conditions: SDK.NetworkManager.ThrottlingConditions): void => {
416
- if (editable) {
417
- condition.conditions = conditions;
450
+
451
+ const onConditionsChanged =
452
+ (condition: {conditions: SDK.NetworkManager.ThrottlingConditions},
453
+ conditions: SDK.NetworkManager.ThrottlingConditions): void => {
454
+ if (editable) {
455
+ condition.conditions = conditions;
456
+ }
457
+ };
458
+
459
+ const onIncreasePriority = (condition: SDK.NetworkManager.RequestCondition): void => {
460
+ if (this.manager.requestConditions.conditionsEnabled) {
461
+ UI.ARIAUtils.LiveAnnouncer.status(i18nString(UIStrings.patternMovedUp));
462
+ this.manager.requestConditions.increasePriority(condition);
418
463
  }
419
464
  };
420
465
 
421
- const {enabled, originalOrUpgradedURLPattern, constructorStringOrWildcardURL, wildcardURL} = condition;
466
+ const onDecreasePriority = (condition: SDK.NetworkManager.RequestCondition): void => {
467
+ if (this.manager.requestConditions.conditionsEnabled) {
468
+ UI.ARIAUtils.LiveAnnouncer.status(i18nString(UIStrings.patternMovedDown));
469
+ this.manager.requestConditions.decreasePriority(condition);
470
+ }
471
+ };
422
472
 
423
- if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
424
- const moveUp = (e: Event): void => {
425
- if (this.manager.requestConditions.conditionsEnabled) {
426
- UI.ARIAUtils.LiveAnnouncer.status(i18nString(UIStrings.patternMovedUp));
427
- e.consume(true);
428
- this.manager.requestConditions.increasePriority(condition);
429
- }
430
- };
431
- const moveDown = (e: Event): void => {
432
- if (this.manager.requestConditions.conditionsEnabled) {
433
- UI.ARIAUtils.LiveAnnouncer.status(i18nString(UIStrings.patternMovedDown));
434
- e.consume(true);
435
- this.manager.requestConditions.decreasePriority(condition);
436
- }
437
- };
438
- render(
439
- // clang-format off
440
- html`
441
- <input class=blocked-url-checkbox
442
- @change=${toggle}
443
- type=checkbox
444
- title=${i18nString(UIStrings.enableThrottlingToggleLabel, {PH1: constructorStringOrWildcardURL})}
445
- .checked=${live(enabled)}
446
- .disabled=${!editable || !originalOrUpgradedURLPattern}
447
- jslog=${VisualLogging.toggle().track({ change: true })}>
448
- <devtools-button
449
- .iconName=${'arrow-up'}
450
- .variant=${Buttons.Button.Variant.ICON}
451
- .title=${i18nString(UIStrings.increasePriority, {PH1: constructorStringOrWildcardURL})}
452
- .jslogContext=${'decrease-priority'}
453
- ?disabled=${!editable || !originalOrUpgradedURLPattern}
454
- @click=${moveUp}>
455
- </devtools-button>
456
- <devtools-button
457
- .iconName=${'arrow-down'}
458
- .variant=${Buttons.Button.Variant.ICON}
459
- .title=${i18nString(UIStrings.decreasePriority, {PH1: constructorStringOrWildcardURL})}
460
- .jslogContext=${'increase-priority'}
461
- ?disabled=${!editable || !originalOrUpgradedURLPattern}
462
- @click=${moveDown}></devtools-button>
463
- ${originalOrUpgradedURLPattern ? html`
464
- <devtools-tooltip variant=rich jslogcontext=url-pattern id=url-pattern-${index}>
465
- <div>hash: ${originalOrUpgradedURLPattern.hash}</div>
466
- <div>hostname: ${originalOrUpgradedURLPattern.hostname}</div>
467
- <div>password: ${originalOrUpgradedURLPattern.password}</div>
468
- <div>pathname: ${originalOrUpgradedURLPattern.pathname}</div>
469
- <div>port: ${originalOrUpgradedURLPattern.port}</div>
470
- <div>protocol: ${originalOrUpgradedURLPattern.protocol}</div>
471
- <div>search: ${originalOrUpgradedURLPattern.search}</div>
472
- <div>username: ${originalOrUpgradedURLPattern.username}</div>
473
- <hr />
474
- ${learnMore()}
475
- </devtools-tooltip>` : nothing}
476
- ${wildcardURL ? html`
477
- <devtools-icon name=warning-filled class="small warning" aria-details=url-pattern-warning-${index}>
478
- </devtools-icon>
479
- <devtools-tooltip variant=rich jslogcontext=url-pattern-warning id=url-pattern-warning-${index}>
480
- ${i18nString(UIStrings.patternWasUpgraded, {PH1: wildcardURL})}
481
- </devtools-tooltip>
482
- `: nothing}
483
- ${!originalOrUpgradedURLPattern ? html`
484
- <devtools-icon name=cross-circle-filled class=small aria-details=url-pattern-error-${index}>
485
- </devtools-icon>
486
- <devtools-tooltip variant=rich jslogcontext=url-pattern-warning id=url-pattern-error-${index}>
487
- ${SDK.NetworkManager.RequestURLPattern.isValidPattern(constructorStringOrWildcardURL) ===
488
- SDK.NetworkManager.RequestURLPatternValidity.HAS_REGEXP_GROUPS
489
- ? i18nString(UIStrings.patternFailedWithRegExpGroups)
490
- : i18nString(UIStrings.patternFailedToParse)}
491
- ${learnMore()}
492
- </devtools-tooltip>`: nothing}
493
- <div
494
- @click=${toggle}
495
- ?disabled=${!editable || !originalOrUpgradedURLPattern}
496
- class=blocked-url-label
497
- aria-details=url-pattern-${index}>
498
- ${constructorStringOrWildcardURL}
499
- </div>
500
- <devtools-widget
501
- class=conditions-selector
502
- title=${i18nString(UIStrings.requestConditionsLabel)}
503
- .widgetConfig=${UI.Widget.widgetConfig(
504
- MobileThrottling.NetworkThrottlingSelector.NetworkThrottlingSelectorWidget, {
505
- variant:
506
- MobileThrottling.NetworkThrottlingSelector.NetworkThrottlingSelect.Variant.INDIVIDUAL_REQUEST_CONDITIONS,
507
- jslogContext: 'request-conditions',
508
- disabled: !editable,
509
- onConditionsChanged,
510
- currentConditions: condition.conditions,
511
- })}></devtools-widget>
512
- <devtools-widget
513
- ?disabled=${!editable || !originalOrUpgradedURLPattern}
514
- .widgetConfig=${widgetConfig(AffectedCountWidget, {condition, drawer: this})}></devtools-widget>`,
515
- // clang-format on
516
- element);
517
- } else {
518
- render(
519
- // clang-format off
520
- html`
521
- <input class=blocked-url-checkbox
522
- @change=${toggle}
523
- type=checkbox
524
- .checked=${condition.enabled}
525
- .disabled=${!editable}
526
- jslog=${VisualLogging.toggle().track({ change: true })}>
527
- <div @click=${toggle} class=blocked-url-label>${wildcardURL}</div>
528
- <devtools-widget .widgetConfig=${widgetConfig(AffectedCountWidget, {condition, drawer: this})}></devtools-widget>`,
529
- // clang-format on
530
- element);
531
- }
473
+ render(
474
+ renderItem(
475
+ condition, editable, index, onToggle, onConditionsChanged, onIncreasePriority, onDecreasePriority,
476
+ this.#getRequestCount.bind(this)),
477
+ element);
532
478
  }
533
479
 
534
480
  private toggleEnabled(): void {
@@ -543,9 +489,7 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
543
489
 
544
490
  beginEdit(pattern: SDK.NetworkManager.RequestCondition): UI.ListWidget.Editor<SDK.NetworkManager.RequestCondition> {
545
491
  this.editor = this.createEditor();
546
- this.editor.control('url').value = Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled ?
547
- pattern.constructorStringOrWildcardURL :
548
- pattern.wildcardURL ?? '';
492
+ this.editor.control('url').value = pattern.constructorStringOrWildcardURL;
549
493
  return this.editor;
550
494
  }
551
495
 
@@ -553,9 +497,7 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
553
497
  item: SDK.NetworkManager.RequestCondition, editor: UI.ListWidget.Editor<SDK.NetworkManager.RequestCondition>,
554
498
  isNew: boolean): void {
555
499
  const constructorString = editor.control('url').value as SDK.NetworkManager.URLPatternConstructorString;
556
- const pattern = Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled ?
557
- SDK.NetworkManager.RequestURLPattern.create(constructorString) :
558
- constructorString;
500
+ const pattern = SDK.NetworkManager.RequestURLPattern.create(constructorString);
559
501
  if (!pattern) {
560
502
  throw new Error('Failed to parse pattern');
561
503
  }
@@ -574,14 +516,10 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
574
516
  const content = editor.contentElement();
575
517
  const titles = content.createChild('div', 'blocked-url-edit-row');
576
518
  const label = titles.createChild('label');
577
- if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
578
- const learnMore = Link.create(PATTERN_API_DOCS_URL, i18nString(UIStrings.learnMore), undefined, 'learn-more');
579
- learnMore.title = i18nString(UIStrings.learnMoreLabel);
580
- titles.append('\xA0', learnMore);
581
- label.textContent = i18nString(UIStrings.textEditPattern);
582
- } else {
583
- label.textContent = i18nString(UIStrings.textPatternToBlockMatching);
584
- }
519
+ const learnMore = Link.create(PATTERN_API_DOCS_URL, i18nString(UIStrings.learnMore), undefined, 'learn-more');
520
+ learnMore.title = i18nString(UIStrings.learnMoreLabel);
521
+ titles.append('\xA0', learnMore);
522
+ label.textContent = i18nString(UIStrings.textEditPattern);
585
523
  const fields = content.createChild('div', 'blocked-url-edit-row');
586
524
  const validator =
587
525
  (_item: SDK.NetworkManager.RequestCondition, _index: number, input: UI.ListWidget.EditorControl): {
@@ -594,14 +532,12 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
594
532
  if (this.manager.requestConditions.has(input.value)) {
595
533
  return {errorMessage: i18nString(UIStrings.patternAlreadyExists), valid: false};
596
534
  }
597
- if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
598
- const isValid = SDK.NetworkManager.RequestURLPattern.isValidPattern(input.value);
599
- switch (isValid) {
600
- case SDK.NetworkManager.RequestURLPatternValidity.FAILED_TO_PARSE:
601
- return {errorMessage: i18nString(UIStrings.patternFailedToParse), valid: false};
602
- case SDK.NetworkManager.RequestURLPatternValidity.HAS_REGEXP_GROUPS:
603
- return {errorMessage: i18nString(UIStrings.patternFailedWithRegExpGroups), valid: false};
604
- }
535
+ const isValid = SDK.NetworkManager.RequestURLPattern.isValidPattern(input.value);
536
+ switch (isValid) {
537
+ case SDK.NetworkManager.RequestURLPatternValidity.FAILED_TO_PARSE:
538
+ return {errorMessage: i18nString(UIStrings.patternFailedToParse), valid: false};
539
+ case SDK.NetworkManager.RequestURLPatternValidity.HAS_REGEXP_GROUPS:
540
+ return {errorMessage: i18nString(UIStrings.patternFailedWithRegExpGroups), valid: false};
605
541
  }
606
542
  return {valid: true, errorMessage: undefined};
607
543
  };
@@ -613,8 +549,7 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
613
549
 
614
550
  update(): void {
615
551
  const enabled = this.manager.requestConditions.conditionsEnabled;
616
- const newItems = Array.from(this.manager.requestConditions.conditions.filter(
617
- pattern => Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled || pattern.wildcardURL));
552
+ const newItems = Array.from(this.manager.requestConditions.conditions);
618
553
 
619
554
  let oldIndex = 0;
620
555
  for (; oldIndex < newItems.length; ++oldIndex) {
@@ -637,17 +572,17 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
637
572
  this.requestUpdate();
638
573
  }
639
574
 
640
- blockedRequestsCount(condition: SDK.NetworkManager.RequestCondition): number {
641
- let result = 0;
642
- for (const blockedUrl of this.blockedCountForUrl.keys()) {
643
- if (matchesUrl(condition, blockedUrl)) {
644
- result += (this.blockedCountForUrl.get(blockedUrl) as number);
575
+ #getRequestCount(condition: SDK.NetworkManager.RequestCondition): number {
576
+ if (condition.isBlocking) {
577
+ let result = 0;
578
+ for (const blockedUrl of this.blockedCountForUrl.keys()) {
579
+ if (matchesUrl(condition, blockedUrl)) {
580
+ result += (this.blockedCountForUrl.get(blockedUrl) as number);
581
+ }
645
582
  }
583
+ return result;
646
584
  }
647
- return result;
648
- }
649
585
 
650
- throttledRequestsCount(condition: SDK.NetworkManager.RequestCondition): number {
651
586
  let result = 0;
652
587
  for (const ruleId of condition.ruleIds) {
653
588
  result += this.#throttledCount.get(ruleId) ?? 0;
@@ -23,18 +23,10 @@ const UIStrings = {
23
23
  * @description Title of the Network tool
24
24
  */
25
25
  network: 'Network',
26
- /**
27
- * @description Command for showing the 'Network request blocking' tool
28
- */
29
- showNetworkRequestBlocking: 'Show Network request blocking',
30
26
  /**
31
27
  * @description Command for showing the 'Network request blocking' tool
32
28
  */
33
29
  showRequestConditions: 'Show Request conditions',
34
- /**
35
- * @description Title of the 'Network request blocking' tool in the bottom drawer
36
- */
37
- networkRequestBlocking: 'Network request blocking',
38
30
  /**
39
31
  * @description Title of the 'Request conditions' tool in the bottom drawer
40
32
  */
@@ -123,14 +115,6 @@ const UIStrings = {
123
115
  * @description Title of a button for clearing the network log
124
116
  */
125
117
  clear: 'Clear network log',
126
- /**
127
- * @description Title of an action in the Network request blocking panel to add a new URL pattern to the blocklist.
128
- */
129
- addNetworkRequestBlockingPattern: 'Add network request blocking pattern',
130
- /**
131
- * @description Title of an action in the Network request blocking panel to clear all URL patterns.
132
- */
133
- removeAllNetworkRequestBlockingPatterns: 'Remove all network request blocking patterns',
134
118
  /**
135
119
  * @description Title of an action in the Network request blocking panel to add a new URL pattern to the blocklist.
136
120
  */
@@ -190,15 +174,11 @@ UI.ViewManager.registerViewExtension({
190
174
  },
191
175
  });
192
176
 
193
- const individualThrottlingEnabled = (): boolean =>
194
- Boolean(Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled);
195
177
  UI.ViewManager.registerViewExtension({
196
178
  location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW,
197
179
  id: 'network.blocked-urls',
198
- commandPrompt: () => individualThrottlingEnabled() ? i18nString(UIStrings.showRequestConditions) :
199
- i18nString(UIStrings.showNetworkRequestBlocking),
200
- title: () => individualThrottlingEnabled() ? i18nString(UIStrings.networkRequestConditions) :
201
- i18nString(UIStrings.networkRequestBlocking),
180
+ commandPrompt: () => i18nString(UIStrings.showRequestConditions),
181
+ title: () => i18nString(UIStrings.networkRequestConditions),
202
182
  persistence: UI.ViewManager.ViewPersistence.CLOSEABLE,
203
183
  order: 60,
204
184
  async loadView() {
@@ -350,8 +330,7 @@ UI.ActionRegistration.registerActionExtension({
350
330
  UI.ActionRegistration.registerActionExtension({
351
331
  actionId: 'network.add-network-request-blocking-pattern',
352
332
  category: UI.ActionRegistration.ActionCategory.NETWORK,
353
- title: () => individualThrottlingEnabled() ? i18nString(UIStrings.addNetworkRequestBlockingOrThrottlingPattern) :
354
- i18nString(UIStrings.addNetworkRequestBlockingPattern),
333
+ title: () => i18nString(UIStrings.addNetworkRequestBlockingOrThrottlingPattern),
355
334
  iconClass: UI.ActionRegistration.IconClass.PLUS,
356
335
  contextTypes() {
357
336
  return maybeRetrieveContextTypes(Network => [Network.RequestConditionsDrawer.RequestConditionsDrawer]);
@@ -365,9 +344,7 @@ UI.ActionRegistration.registerActionExtension({
365
344
  UI.ActionRegistration.registerActionExtension({
366
345
  actionId: 'network.remove-all-network-request-blocking-patterns',
367
346
  category: UI.ActionRegistration.ActionCategory.NETWORK,
368
- title: () => individualThrottlingEnabled() ?
369
- i18nString(UIStrings.removeAllNetworkRequestBlockingOrThrottlingPatterns) :
370
- i18nString(UIStrings.removeAllNetworkRequestBlockingPatterns),
347
+ title: () => i18nString(UIStrings.removeAllNetworkRequestBlockingOrThrottlingPatterns),
371
348
  iconClass: UI.ActionRegistration.IconClass.CLEAR,
372
349
  contextTypes() {
373
350
  return maybeRetrieveContextTypes(Network => [Network.RequestConditionsDrawer.RequestConditionsDrawer]);