chrome-devtools-frontend 1.0.1582745 → 1.0.1583146

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 (27) hide show
  1. package/front_end/core/root/Runtime.ts +0 -5
  2. package/front_end/core/sdk/NetworkManager.ts +63 -115
  3. package/front_end/entrypoint_template.html +1 -5
  4. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +15 -3
  5. package/front_end/panels/ai_assistance/components/ChatMessage.ts +4 -2
  6. package/front_end/panels/autofill/AutofillView.ts +4 -8
  7. package/front_end/panels/common/AiCodeGenerationTeaser.ts +27 -8
  8. package/front_end/panels/elements/ComputedStyleWidget.ts +41 -29
  9. package/front_end/panels/elements/ElementStatePaneWidget.ts +1 -1
  10. package/front_end/panels/elements/ElementsTreeElement.ts +487 -426
  11. package/front_end/panels/elements/EventListenersWidget.ts +2 -4
  12. package/front_end/panels/elements/PropertiesWidget.ts +1 -2
  13. package/front_end/panels/elements/StylePropertyTreeElement.ts +18 -2
  14. package/front_end/panels/elements/computedStyleWidget.css +30 -0
  15. package/front_end/panels/network/NetworkLogView.ts +64 -105
  16. package/front_end/panels/network/RequestConditionsDrawer.ts +40 -131
  17. package/front_end/panels/network/network-meta.ts +4 -27
  18. package/front_end/panels/settings/WorkspaceSettingsTab.ts +1 -1
  19. package/front_end/panels/sources/CallStackSidebarPane.ts +2 -2
  20. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +8 -0
  21. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +8 -0
  22. package/front_end/ui/components/text_editor/config.ts +6 -0
  23. package/front_end/ui/legacy/Toolbar.ts +12 -4
  24. package/front_end/ui/legacy/UIUtils.ts +26 -1
  25. package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
  26. package/package.json +1 -1
  27. package/front_end/panels/elements/computedStyleSidebarPane.css +0 -18
@@ -105,8 +105,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
105
105
  <devtools-toolbar class="event-listener-toolbar" role="presentation">
106
106
  <devtools-button ${bindToAction(input.refreshEventListenersActionName)}></devtools-button>
107
107
  <devtools-checkbox title=${i18nString(UIStrings.showListenersOnTheAncestors)}
108
- ${bindToSetting(input.showForAncestorsSetting)}
109
- jslog=${VisualLogging.toggle('show-event-listeners-for-ancestors').track({ change: true })}>
108
+ ${bindToSetting(input.showForAncestorsSetting)}>
110
109
  ${i18nString(UIStrings.ancestors)}
111
110
  </devtools-checkbox>
112
111
  <select class="dispatch-filter"
@@ -120,8 +119,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
120
119
  </option>`)}
121
120
  </select>
122
121
  <devtools-checkbox title=${i18nString(UIStrings.resolveEventListenersBoundWith)}
123
- ${bindToSetting(input.showFrameworkListenersSetting)}
124
- jslog=${VisualLogging.toggle('show-frameowkr-listeners').track({ change: true })}>
122
+ ${bindToSetting(input.showFrameworkListenersSetting)}>
125
123
  ${i18nString(UIStrings.frameworkListeners)}
126
124
  </devtools-checkbox>
127
125
  </devtools-toolbar>
@@ -86,8 +86,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
86
86
  <div class="hbox properties-widget-toolbar">
87
87
  <devtools-toolbar class="styles-pane-toolbar" role="presentation">
88
88
  <devtools-toolbar-input type="filter" @change=${input.onFilterChanged} style="flex-grow:1; flex-shrink:1"></devtools-toolbar-input>
89
- <devtools-checkbox title=${i18nString(UIStrings.showAllTooltip)} ${bindToSetting(getShowAllPropertiesSetting())}
90
- jslog=${VisualLogging.toggle('show-all-properties').track({change: true})}>
89
+ <devtools-checkbox title=${i18nString(UIStrings.showAllTooltip)} ${bindToSetting(getShowAllPropertiesSetting())}>
91
90
  ${i18nString(UIStrings.showAll)}
92
91
  </devtools-checkbox>
93
92
  </devtools-toolbar>
@@ -2155,6 +2155,9 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2155
2155
  }
2156
2156
 
2157
2157
  renderedPropertyText(): string {
2158
+ if (!this.#isConnected()) {
2159
+ return '';
2160
+ }
2158
2161
  if (!this.nameElement || !this.valueElement) {
2159
2162
  return '';
2160
2163
  }
@@ -2895,8 +2898,7 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2895
2898
  const regex = new RegExp(propertyNamePattern, 'i');
2896
2899
  await computedStyleWidget.filterComputedStyles(regex);
2897
2900
 
2898
- computedStyleWidget.input.setValue(this.property.name);
2899
- computedStyleWidget.input.element.focus();
2901
+ computedStyleWidget.setFilterInput(this.property.name);
2900
2902
  }
2901
2903
 
2902
2904
  private copyCssDeclarationAsJs(): void {
@@ -3434,7 +3436,17 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3434
3436
  styleTextAppliedForTest(): void {
3435
3437
  }
3436
3438
 
3439
+ // If the item isn't connected to the DOM, then reading its innerText will
3440
+ // also include any invisible text (e.g. sources, styles), so we don't want
3441
+ // to do that.
3442
+ #isConnected(): boolean {
3443
+ return this.listItemElement.isConnected;
3444
+ }
3445
+
3437
3446
  applyStyleText(styleText: string, majorChange: boolean, property?: SDK.CSSProperty.CSSProperty|null): Promise<void> {
3447
+ if (!this.#isConnected()) {
3448
+ return Promise.resolve();
3449
+ }
3438
3450
  return this.applyStyleThrottler.schedule(this.innerApplyStyleText.bind(this, styleText, majorChange, property));
3439
3451
  }
3440
3452
 
@@ -3445,6 +3457,10 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
3445
3457
  return;
3446
3458
  }
3447
3459
 
3460
+ if (!this.#isConnected()) {
3461
+ return;
3462
+ }
3463
+
3448
3464
  const oldStyleRange = this.style.range;
3449
3465
  if (!oldStyleRange) {
3450
3466
  return;
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright 2015 The Chromium Authors
3
+ * Use of this source code is governed by a BSD-style license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ @scope to (devtools-widget > *) {
8
+ .styles-sidebar-pane-toolbar {
9
+ border-bottom: 1px solid var(--sys-color-divider);
10
+ flex-shrink: 0;
11
+ }
12
+
13
+ .styles-pane-toolbar {
14
+ width: 100%;
15
+ }
16
+
17
+ .styles-sidebar-computed-style-widget {
18
+ min-height: auto;
19
+ }
20
+
21
+ .computed-style-tree-outline-container {
22
+ flex-grow: 1;
23
+ flex-shrink: 0;
24
+ }
25
+
26
+ devtools-toolbar-input[type="filter"] {
27
+ flex-grow: 1;
28
+ flex-shrink: 1;
29
+ }
30
+ }
@@ -39,7 +39,6 @@ import * as Common from '../../core/common/common.js';
39
39
  import * as Host from '../../core/host/host.js';
40
40
  import * as i18n from '../../core/i18n/i18n.js';
41
41
  import * as Platform from '../../core/platform/platform.js';
42
- import * as Root from '../../core/root/root.js';
43
42
  import * as SDK from '../../core/sdk/sdk.js';
44
43
  import * as Protocol from '../../generated/protocol.js';
45
44
  import * as Annotations from '../../models/annotations/annotations.js';
@@ -1722,21 +1721,21 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
1722
1721
  }
1723
1722
 
1724
1723
  UI.Context.Context.instance().setFlavor(SDK.NetworkRequest.NetworkRequest, request);
1725
- const action = UI.ActionRegistry.ActionRegistry.instance().getAction(openAiAssistanceId);
1726
- const submenu = contextMenu.footerSection().appendSubMenuItem(action.title(), false, openAiAssistanceId);
1727
- submenu.defaultSection().appendAction(openAiAssistanceId, i18nString(UIStrings.startAChat));
1728
- appendSubmenuPromptAction(
1729
- submenu, action, i18nString(UIStrings.explainPurpose), 'What is the purpose of this request?',
1730
- openAiAssistanceId + '.purpose');
1731
- appendSubmenuPromptAction(
1732
- submenu, action, i18nString(UIStrings.explainSlowness), 'Why is this request taking so long?',
1733
- openAiAssistanceId + '.slowness');
1734
- appendSubmenuPromptAction(
1735
- submenu, action, i18nString(UIStrings.explainFailures), 'Why is the request failing?',
1736
- openAiAssistanceId + '.failures');
1737
- appendSubmenuPromptAction(
1738
- submenu, action, i18nString(UIStrings.assessSecurityHeaders), 'Are there any security headers present?',
1739
- openAiAssistanceId + '.security');
1724
+ const action = UI.ActionRegistry.ActionRegistry.instance().getAction(openAiAssistanceId);
1725
+ const submenu = contextMenu.footerSection().appendSubMenuItem(action.title(), false, openAiAssistanceId);
1726
+ submenu.defaultSection().appendAction(openAiAssistanceId, i18nString(UIStrings.startAChat));
1727
+ appendSubmenuPromptAction(
1728
+ submenu, action, i18nString(UIStrings.explainPurpose), 'What is the purpose of this request?',
1729
+ openAiAssistanceId + '.purpose');
1730
+ appendSubmenuPromptAction(
1731
+ submenu, action, i18nString(UIStrings.explainSlowness), 'Why is this request taking so long?',
1732
+ openAiAssistanceId + '.slowness');
1733
+ appendSubmenuPromptAction(
1734
+ submenu, action, i18nString(UIStrings.explainFailures), 'Why is the request failing?',
1735
+ openAiAssistanceId + '.failures');
1736
+ appendSubmenuPromptAction(
1737
+ submenu, action, i18nString(UIStrings.assessSecurityHeaders), 'Are there any security headers present?',
1738
+ openAiAssistanceId + '.security');
1740
1739
  }
1741
1740
  copyMenu.defaultSection().appendItem(
1742
1741
  i18nString(UIStrings.copyURL),
@@ -1854,98 +1853,58 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
1854
1853
  const maxBlockedURLLength = 20;
1855
1854
  const manager = SDK.NetworkManager.MultitargetNetworkManager.instance();
1856
1855
 
1857
- if (!Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
1858
- function addBlockedURL(url: string): void {
1859
- manager.requestConditions.add(SDK.NetworkManager.RequestCondition.createFromSetting(
1860
- {enabled: true, url: url as Platform.DevToolsPath.UrlString}));
1861
- manager.requestConditions.conditionsEnabled = true;
1856
+ function removeRequestCondition(pattern: SDK.NetworkManager.RequestURLPattern): void {
1857
+ const entry = manager.requestConditions.findCondition(pattern.constructorString);
1858
+ if (entry) {
1859
+ manager.requestConditions.delete(entry);
1862
1860
  void UI.ViewManager.ViewManager.instance().showView('network.blocked-urls');
1863
1861
  }
1862
+ }
1864
1863
 
1865
- function removeBlockedURL(url: string): void {
1866
- const entry = manager.requestConditions.findCondition(url);
1867
- if (entry) {
1868
- manager.requestConditions.delete(entry);
1869
- }
1870
- void UI.ViewManager.ViewManager.instance().showView('network.blocked-urls');
1871
- }
1872
-
1873
- const urlWithoutScheme = request.parsedURL.urlWithoutScheme();
1874
- if (urlWithoutScheme && !manager.requestConditions.has(urlWithoutScheme)) {
1875
- contextMenu.debugSection().appendItem(
1876
- i18nString(UIStrings.blockRequestUrl), addBlockedURL.bind(null, urlWithoutScheme),
1877
- {jslogContext: 'block-request-url'});
1878
- } else if (urlWithoutScheme) {
1879
- const croppedURL = Platform.StringUtilities.trimMiddle(urlWithoutScheme, maxBlockedURLLength);
1880
- contextMenu.debugSection().appendItem(
1881
- i18nString(UIStrings.unblockS, {PH1: croppedURL}), removeBlockedURL.bind(null, urlWithoutScheme),
1882
- {jslogContext: 'unblock'});
1883
- }
1884
-
1885
- const domain = request.parsedURL.domain();
1886
- if (domain && !manager.requestConditions.has(domain)) {
1887
- contextMenu.debugSection().appendItem(
1888
- i18nString(UIStrings.blockRequestDomain), addBlockedURL.bind(null, domain),
1889
- {jslogContext: 'block-request-domain'});
1890
- } else if (domain) {
1891
- const croppedDomain = Platform.StringUtilities.trimMiddle(domain, maxBlockedURLLength);
1892
- contextMenu.debugSection().appendItem(
1893
- i18nString(UIStrings.unblockS, {PH1: croppedDomain}), removeBlockedURL.bind(null, domain),
1894
- {jslogContext: 'unblock'});
1895
- }
1896
- } else {
1897
- function removeRequestCondition(pattern: SDK.NetworkManager.RequestURLPattern): void {
1898
- const entry = manager.requestConditions.findCondition(pattern.constructorString);
1899
- if (entry) {
1900
- manager.requestConditions.delete(entry);
1901
- void UI.ViewManager.ViewManager.instance().showView('network.blocked-urls');
1902
- }
1903
- }
1904
-
1905
- function addRequestCondition(
1906
- pattern: SDK.NetworkManager.RequestURLPattern,
1907
- conditions: SDK.NetworkManager.ThrottlingConditions,
1908
- ): void {
1909
- const entry = manager.requestConditions.findCondition(pattern.constructorString);
1910
- if (entry) {
1911
- entry.conditions = conditions;
1912
- } else {
1913
- manager.requestConditions.add(SDK.NetworkManager.RequestCondition.create(pattern, conditions));
1914
- }
1915
- manager.requestConditions.conditionsEnabled = true;
1916
- void UI.ViewManager.ViewManager.instance().showView('network.blocked-urls');
1864
+ function addRequestCondition(
1865
+ pattern: SDK.NetworkManager.RequestURLPattern,
1866
+ conditions: SDK.NetworkManager.ThrottlingConditions,
1867
+ ): void {
1868
+ const entry = manager.requestConditions.findCondition(pattern.constructorString);
1869
+ if (entry) {
1870
+ entry.conditions = conditions;
1871
+ } else {
1872
+ manager.requestConditions.add(SDK.NetworkManager.RequestCondition.create(pattern, conditions));
1917
1873
  }
1874
+ manager.requestConditions.conditionsEnabled = true;
1875
+ void UI.ViewManager.ViewManager.instance().showView('network.blocked-urls');
1876
+ }
1918
1877
 
1919
- const blockingMenu =
1920
- contextMenu.debugSection().appendSubMenuItem(i18nString(UIStrings.blockRequests), /* disabled=*/ true);
1921
- const throttlingMenu =
1922
- contextMenu.debugSection().appendSubMenuItem(i18nString(UIStrings.throttleRequests), /* disabled=*/ true);
1923
-
1924
- const urlWithoutScheme = request.parsedURL.urlWithoutScheme();
1925
- const urlPattern = urlWithoutScheme &&
1926
- SDK.NetworkManager.RequestURLPattern.create(
1927
- `*://${urlWithoutScheme}` as SDK.NetworkManager.URLPatternConstructorString);
1928
- if (urlPattern) {
1929
- throttlingMenu.setEnabled(true);
1930
- blockingMenu.setEnabled(true);
1931
- const existingConditions = manager.requestConditions.findCondition(urlPattern.constructorString);
1932
- const isBlocking = existingConditions?.conditions === SDK.NetworkManager.BlockingConditions;
1933
- const isThrottling = existingConditions &&
1934
- existingConditions.conditions !== SDK.NetworkManager.BlockingConditions &&
1935
- existingConditions.conditions !== SDK.NetworkManager.NoThrottlingConditions;
1936
- const croppedURL = Platform.StringUtilities.trimMiddle(urlPattern.constructorString, maxBlockedURLLength);
1937
- blockingMenu.debugSection().appendItem(
1938
- isBlocking ? i18nString(UIStrings.unblockS, {PH1: croppedURL}) : i18nString(UIStrings.blockRequestUrl),
1939
- () => isBlocking ? removeRequestCondition(urlPattern) :
1940
- addRequestCondition(urlPattern, SDK.NetworkManager.BlockingConditions),
1941
- {jslogContext: 'block-request-url'});
1942
- throttlingMenu.debugSection().appendItem(
1943
- isThrottling ? i18nString(UIStrings.unthrottleS, {PH1: croppedURL}) :
1944
- i18nString(UIStrings.throttleRequestUrl),
1945
- () => isThrottling ? removeRequestCondition(urlPattern) :
1946
- addRequestCondition(urlPattern, SDK.NetworkManager.Slow3GConditions),
1947
- {jslogContext: 'throttle-request-url'});
1948
- }
1878
+ const blockingMenu =
1879
+ contextMenu.debugSection().appendSubMenuItem(i18nString(UIStrings.blockRequests), /* disabled=*/ true);
1880
+ const throttlingMenu =
1881
+ contextMenu.debugSection().appendSubMenuItem(i18nString(UIStrings.throttleRequests), /* disabled=*/ true);
1882
+
1883
+ const urlWithoutScheme = request.parsedURL.urlWithoutScheme();
1884
+ const urlPattern = urlWithoutScheme &&
1885
+ SDK.NetworkManager.RequestURLPattern.create(
1886
+ `*://${urlWithoutScheme}` as SDK.NetworkManager.URLPatternConstructorString);
1887
+ if (urlPattern) {
1888
+ throttlingMenu.setEnabled(true);
1889
+ blockingMenu.setEnabled(true);
1890
+ const existingConditions = manager.requestConditions.findCondition(urlPattern.constructorString);
1891
+ const isBlocking = existingConditions?.conditions === SDK.NetworkManager.BlockingConditions;
1892
+ const isThrottling = existingConditions &&
1893
+ existingConditions.conditions !== SDK.NetworkManager.BlockingConditions &&
1894
+ existingConditions.conditions !== SDK.NetworkManager.NoThrottlingConditions;
1895
+ const croppedURL = Platform.StringUtilities.trimMiddle(urlPattern.constructorString, maxBlockedURLLength);
1896
+ blockingMenu.debugSection().appendItem(
1897
+ isBlocking ? i18nString(UIStrings.unblockS, {PH1: croppedURL}) : i18nString(UIStrings.blockRequestUrl),
1898
+ () => isBlocking ? removeRequestCondition(urlPattern) :
1899
+ addRequestCondition(urlPattern, SDK.NetworkManager.BlockingConditions),
1900
+ {jslogContext: 'block-request-url'});
1901
+ throttlingMenu.debugSection().appendItem(
1902
+ isThrottling ? i18nString(UIStrings.unthrottleS, {PH1: croppedURL}) :
1903
+ i18nString(UIStrings.throttleRequestUrl),
1904
+ () => isThrottling ? removeRequestCondition(urlPattern) :
1905
+ addRequestCondition(urlPattern, SDK.NetworkManager.Slow3GConditions),
1906
+ {jslogContext: 'throttle-request-url'});
1907
+ }
1949
1908
 
1950
1909
  const domain = request.parsedURL.domain();
1951
1910
  const domainPattern = domain &&
@@ -1971,7 +1930,6 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
1971
1930
  () => isThrottling ? removeRequestCondition(domainPattern) :
1972
1931
  addRequestCondition(domainPattern, SDK.NetworkManager.Slow3GConditions),
1973
1932
  {jslogContext: 'throttle-request-domain'});
1974
- }
1975
1933
  }
1976
1934
 
1977
1935
  if (SDK.NetworkManager.NetworkManager.canReplayRequest(request)) {
@@ -2758,7 +2716,8 @@ export class MoreFiltersDropDownUI extends Common.ObjectWrapper.ObjectWrapper<UI
2758
2716
  this.updateActiveFiltersCount();
2759
2717
 
2760
2718
  this.dropDownButton = new UI.Toolbar.ToolbarMenuButton(
2761
- this.showMoreFiltersContextMenu.bind(this), /* isIconDropdown=*/ false, /* useSoftMenu=*/ true,
2719
+ this.showMoreFiltersContextMenu.bind(this),
2720
+ /* isIconDropdown=*/ false, /* useSoftMenu=*/ true,
2762
2721
  /* jslogContext=*/ undefined, /* iconName=*/ undefined,
2763
2722
  /* keepOpen=*/ true);
2764
2723
  this.dropDownButton.setTitle(i18nString(UIStrings.showOnlyHideRequests));
@@ -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)}>
@@ -227,35 +188,11 @@ interface AffectedCountViewInput {
227
188
  }
228
189
  type AffectedCountView = (input: AffectedCountViewInput, output: object, target: HTMLElement) => void;
229
190
  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
- }
191
+ render(html`${i18nString(UIStrings.dAffected, {PH1: input.count})}`, target);
235
192
  };
236
193
 
237
194
  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)));
195
+ return Boolean(conditions.originalOrUpgradedURLPattern?.test(url));
259
196
  }
260
197
 
261
198
  export class AffectedCountWidget extends UI.Widget.Widget {
@@ -290,9 +227,8 @@ export class AffectedCountWidget extends UI.Widget.Widget {
290
227
  return;
291
228
  }
292
229
 
293
- const count = !Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled || this.#condition.isBlocking ?
294
- this.#drawer.blockedRequestsCount(this.#condition) :
295
- this.#drawer.throttledRequestsCount(this.#condition);
230
+ const count = this.#condition.isBlocking ? this.#drawer.blockedRequestsCount(this.#condition) :
231
+ this.#drawer.throttledRequestsCount(this.#condition);
296
232
 
297
233
  this.#view({count}, {}, this.element);
298
234
  }
@@ -420,23 +356,22 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
420
356
 
421
357
  const {enabled, originalOrUpgradedURLPattern, constructorStringOrWildcardURL, wildcardURL} = condition;
422
358
 
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
359
+ const moveUp = (e: Event): void => {
360
+ if (this.manager.requestConditions.conditionsEnabled) {
361
+ UI.ARIAUtils.LiveAnnouncer.status(i18nString(UIStrings.patternMovedUp));
362
+ e.consume(true);
363
+ this.manager.requestConditions.increasePriority(condition);
364
+ }
365
+ };
366
+ const moveDown = (e: Event): void => {
367
+ if (this.manager.requestConditions.conditionsEnabled) {
368
+ UI.ARIAUtils.LiveAnnouncer.status(i18nString(UIStrings.patternMovedDown));
369
+ e.consume(true);
370
+ this.manager.requestConditions.decreasePriority(condition);
371
+ }
372
+ };
373
+ render(
374
+ // clang-format off
440
375
  html`
441
376
  <input class=blocked-url-checkbox
442
377
  @change=${toggle}
@@ -512,23 +447,8 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
512
447
  <devtools-widget
513
448
  ?disabled=${!editable || !originalOrUpgradedURLPattern}
514
449
  .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
- }
450
+ // clang-format on
451
+ element);
532
452
  }
533
453
 
534
454
  private toggleEnabled(): void {
@@ -543,9 +463,7 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
543
463
 
544
464
  beginEdit(pattern: SDK.NetworkManager.RequestCondition): UI.ListWidget.Editor<SDK.NetworkManager.RequestCondition> {
545
465
  this.editor = this.createEditor();
546
- this.editor.control('url').value = Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled ?
547
- pattern.constructorStringOrWildcardURL :
548
- pattern.wildcardURL ?? '';
466
+ this.editor.control('url').value = pattern.constructorStringOrWildcardURL;
549
467
  return this.editor;
550
468
  }
551
469
 
@@ -553,9 +471,7 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
553
471
  item: SDK.NetworkManager.RequestCondition, editor: UI.ListWidget.Editor<SDK.NetworkManager.RequestCondition>,
554
472
  isNew: boolean): void {
555
473
  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;
474
+ const pattern = SDK.NetworkManager.RequestURLPattern.create(constructorString);
559
475
  if (!pattern) {
560
476
  throw new Error('Failed to parse pattern');
561
477
  }
@@ -574,14 +490,10 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
574
490
  const content = editor.contentElement();
575
491
  const titles = content.createChild('div', 'blocked-url-edit-row');
576
492
  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
- }
493
+ const learnMore = Link.create(PATTERN_API_DOCS_URL, i18nString(UIStrings.learnMore), undefined, 'learn-more');
494
+ learnMore.title = i18nString(UIStrings.learnMoreLabel);
495
+ titles.append('\xA0', learnMore);
496
+ label.textContent = i18nString(UIStrings.textEditPattern);
585
497
  const fields = content.createChild('div', 'blocked-url-edit-row');
586
498
  const validator =
587
499
  (_item: SDK.NetworkManager.RequestCondition, _index: number, input: UI.ListWidget.EditorControl): {
@@ -594,14 +506,12 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
594
506
  if (this.manager.requestConditions.has(input.value)) {
595
507
  return {errorMessage: i18nString(UIStrings.patternAlreadyExists), valid: false};
596
508
  }
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
- }
509
+ const isValid = SDK.NetworkManager.RequestURLPattern.isValidPattern(input.value);
510
+ switch (isValid) {
511
+ case SDK.NetworkManager.RequestURLPatternValidity.FAILED_TO_PARSE:
512
+ return {errorMessage: i18nString(UIStrings.patternFailedToParse), valid: false};
513
+ case SDK.NetworkManager.RequestURLPatternValidity.HAS_REGEXP_GROUPS:
514
+ return {errorMessage: i18nString(UIStrings.patternFailedWithRegExpGroups), valid: false};
605
515
  }
606
516
  return {valid: true, errorMessage: undefined};
607
517
  };
@@ -613,8 +523,7 @@ export class RequestConditionsDrawer extends UI.Widget.VBox implements
613
523
 
614
524
  update(): void {
615
525
  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));
526
+ const newItems = Array.from(this.manager.requestConditions.conditions);
618
527
 
619
528
  let oldIndex = 0;
620
529
  for (; oldIndex < newItems.length; ++oldIndex) {