chrome-devtools-frontend 1.0.1681091 → 1.0.1681498

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 (86) hide show
  1. package/front_end/core/sdk/DOMModel.ts +8 -0
  2. package/front_end/core/sdk/NetworkManager.ts +9 -4
  3. package/front_end/core/sdk/OverlayModel.ts +3 -2
  4. package/front_end/core/sdk/SDKSettings.ts +19 -0
  5. package/front_end/entrypoints/main/main-meta.ts +82 -0
  6. package/front_end/entrypoints/shell/shell.ts +0 -3
  7. package/front_end/entrypoints/trace_app/trace_app.ts +0 -3
  8. package/front_end/models/ai_code_completion/debug.ts +6 -3
  9. package/front_end/models/ai_code_generation/debug.ts +6 -3
  10. package/front_end/models/badges/UserBadges.ts +9 -2
  11. package/front_end/models/emulation/DeviceModeModel.ts +16 -27
  12. package/front_end/models/emulation/EmulatedDevices.ts +30 -125
  13. package/front_end/models/extensions/ExtensionAPI.ts +34 -23
  14. package/front_end/models/logs/NetworkLog.ts +3 -3
  15. package/front_end/models/logs/logs-meta.ts +0 -60
  16. package/front_end/models/persistence/NetworkPersistenceManager.ts +7 -1
  17. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  18. package/front_end/panels/application/StorageView.ts +2 -0
  19. package/front_end/panels/common/BadgeNotification.ts +1 -1
  20. package/front_end/panels/common/ExtensionPanel.ts +12 -7
  21. package/front_end/panels/common/ExtensionServer.ts +76 -16
  22. package/front_end/panels/common/GdpSignUpDialog.ts +1 -1
  23. package/front_end/panels/console/ConsoleView.ts +2 -1
  24. package/front_end/panels/console/ConsoleViewMessage.ts +3 -2
  25. package/front_end/panels/console/console-meta.ts +9 -0
  26. package/front_end/panels/elements/CSSRuleValidator.ts +12 -12
  27. package/front_end/panels/elements/CSSSpecificityBreakdown.ts +1 -1
  28. package/front_end/panels/elements/ClassesPaneWidget.ts +6 -6
  29. package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +1 -1
  30. package/front_end/panels/elements/ComputedStyleWidget.ts +4 -5
  31. package/front_end/panels/elements/DOMTreeContextMenu.ts +3 -6
  32. package/front_end/panels/elements/ElementIssueUtils.ts +20 -20
  33. package/front_end/panels/elements/ElementStatePaneWidget.ts +6 -6
  34. package/front_end/panels/elements/ElementsPanel.ts +10 -10
  35. package/front_end/panels/elements/ElementsTreeElement.ts +28 -28
  36. package/front_end/panels/elements/ElementsTreeOutline.ts +5 -20
  37. package/front_end/panels/elements/EventListenersWidget.ts +8 -8
  38. package/front_end/panels/elements/LayersWidget.ts +4 -4
  39. package/front_end/panels/elements/LayoutPane.ts +11 -11
  40. package/front_end/panels/elements/MarkerDecorator.ts +3 -3
  41. package/front_end/panels/elements/PlatformFontsWidget.ts +8 -8
  42. package/front_end/panels/elements/PropertiesWidget.ts +4 -4
  43. package/front_end/panels/elements/PropertyRenderer.ts +2 -2
  44. package/front_end/panels/elements/ShortcutTreeElement.ts +1 -1
  45. package/front_end/panels/elements/StylePropertiesSection.ts +14 -14
  46. package/front_end/panels/elements/StylePropertyTreeElement.ts +21 -21
  47. package/front_end/panels/elements/StylesSidebarPane.ts +12 -13
  48. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +1 -1
  49. package/front_end/panels/elements/components/CSSHintDetailsView.ts +1 -1
  50. package/front_end/panels/elements/components/CSSVariableValueView.ts +3 -3
  51. package/front_end/panels/elements/components/ElementsBreadcrumbsUtils.ts +2 -2
  52. package/front_end/panels/elements/components/ElementsTreeExpandButton.ts +1 -1
  53. package/front_end/panels/elements/elements-meta.ts +13 -13
  54. package/front_end/panels/issues/AffectedCookiesView.ts +2 -0
  55. package/front_end/panels/issues/AffectedElementsView.ts +5 -0
  56. package/front_end/panels/issues/IssueView.ts +7 -2
  57. package/front_end/panels/layer_viewer/LayerDetailsView.ts +11 -7
  58. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +2 -0
  59. package/front_end/panels/network/NetworkLogView.ts +5 -2
  60. package/front_end/panels/network/NetworkOverview.ts +11 -5
  61. package/front_end/panels/network/NetworkPanel.ts +2 -1
  62. package/front_end/panels/network/NetworkWaterfallColumn.ts +16 -3
  63. package/front_end/panels/network/RequestHeadersView.ts +4 -4
  64. package/front_end/panels/network/components/ResponseHeaderSection.ts +6 -2
  65. package/front_end/panels/network/network-meta.ts +57 -0
  66. package/front_end/panels/settings/components/SyncSection.ts +1 -1
  67. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +0 -3
  68. package/front_end/panels/sources/NavigatorView.ts +6 -2
  69. package/front_end/panels/sources/SourcesNavigator.ts +8 -4
  70. package/front_end/panels/sources/SourcesPanel.ts +4 -2
  71. package/front_end/panels/sources/SourcesSearchScope.ts +3 -1
  72. package/front_end/panels/sources/UISourceCodeFrame.ts +2 -2
  73. package/front_end/panels/web_audio/WebAudioView.ts +8 -0
  74. package/front_end/third_party/chromium/README.chromium +1 -1
  75. package/front_end/third_party/web-vitals/rebuild.sh +1 -1
  76. package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +11 -11
  77. package/front_end/ui/legacy/components/color_picker/FormatPickerContextMenu.ts +1 -1
  78. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +19 -20
  79. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +2 -2
  80. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +164 -325
  81. package/front_end/ui/visual_logging/KnownContextValues.ts +11 -0
  82. package/mcp/mcp.ts +0 -3
  83. package/package.json +1 -1
  84. package/front_end/core/sdk/sdk-meta.ts +0 -40
  85. package/front_end/models/badges/badges-meta.ts +0 -27
  86. package/front_end/models/persistence/persistence-meta.ts +0 -69
@@ -161,7 +161,6 @@ const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/object_ui/ObjectP
161
161
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
162
162
  export const EXPANDABLE_MAX_DEPTH = 100;
163
163
 
164
- const objectPropertiesSectionMap = new WeakMap<Element, ObjectPropertiesSection>();
165
164
  // TODO(crbug.com/457388389): This cache is a temporary workaround for the <devtools-tree> migration.
166
165
  // It can be removed once the entire ObjectPropertiesSection is fully migrated to Lit and
167
166
  // the legacy TreeOutline/TreeElement dependencies are removed.
@@ -621,7 +620,7 @@ export abstract class ObjectTreeNodeBase extends Common.ObjectWrapper.ObjectWrap
621
620
  propertiesMode: ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
622
621
  }));
623
622
  properties?.push(...this.extraProperties);
624
- properties?.sort((a, b) => ObjectPropertiesSection.compareProperties(a, b, this.sortPropertiesAlphabetically));
623
+ properties?.sort((a, b) => compareProperties(a, b, this.sortPropertiesAlphabetically));
625
624
  const accessors = properties && ObjectTreeNodeBase.getGettersAndSetters(properties, this.options);
626
625
 
627
626
  const internalProperties =
@@ -751,7 +750,7 @@ export class ArrayGroupTreeNode extends ObjectTreeNodeBase {
751
750
  ...this.options,
752
751
  }));
753
752
  properties?.push(...this.extraProperties);
754
- properties?.sort((a, b) => ObjectPropertiesSection.compareProperties(a, b, this.sortPropertiesAlphabetically));
753
+ properties?.sort((a, b) => compareProperties(a, b, this.sortPropertiesAlphabetically));
755
754
  const accessors = properties && ObjectTreeNodeBase.getGettersAndSetters(properties, this.options);
756
755
  return {properties, accessors};
757
756
  }
@@ -929,267 +928,179 @@ export class ObjectTreeNode extends ObjectTreeNodeBase {
929
928
  }
930
929
  }
931
930
 
932
- export const getObjectPropertiesSectionFrom = (element: Element): ObjectPropertiesSection|undefined => {
933
- return objectPropertiesSectionMap.get(element);
934
- };
935
-
936
- export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow {
937
- readonly root: ObjectTree;
938
- readonly #objectTreeElement: RootElement;
939
- titleElement: Element;
940
- skipProtoInternal?: boolean;
941
-
942
- constructor(object: SDK.RemoteObject.RemoteObject, title?: string|Element|null,
943
- linkifier?: Components.Linkifier.Linkifier, showOverflow?: boolean, editable = true,
944
- search?: UI.TreeOutline.TreeSearch<ObjectTreeNodeBase>) {
945
- super();
946
- this.root = new ObjectTree(object, {
947
- readOnly: !editable,
948
- propertiesMode: ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
949
- search,
950
- });
951
- if (!showOverflow) {
952
- this.setHideOverflow(true);
953
- }
954
- this.setFocusable(true);
955
- this.setShowSelectionOnKeyboardFocus(true);
956
- this.#objectTreeElement = new RootElement(this.root, linkifier);
957
- this.appendChild(this.#objectTreeElement);
958
- if (typeof title === 'string' || !title) {
959
- this.titleElement = this.element.createChild('span');
960
- this.titleElement.textContent = title ? Platform.StringUtilities.escapeUnicodeAsText(title) : '';
961
- } else {
962
- this.titleElement = title;
963
- this.element.appendChild(title);
964
- }
965
- if (this.titleElement instanceof HTMLElement && !this.titleElement.hasAttribute('tabIndex')) {
966
- this.titleElement.tabIndex = -1;
967
- }
968
-
969
- objectPropertiesSectionMap.set(this.element, this);
970
- this.registerRequiredCSS(objectValueStyles, objectPropertiesSectionStyles);
971
- this.rootElement().childrenListElement.classList.add('source-code', 'object-properties-section');
931
+ // The RemoteObjectProperty overload is kept for web test compatibility for now.
932
+ export function compareProperties(propertyA: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
933
+ propertyB: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
934
+ sortPropertiesAlphabetically = true): number {
935
+ if (propertyA instanceof ObjectTreeNode) {
936
+ propertyA = propertyA.property;
937
+ }
938
+ if (propertyB instanceof ObjectTreeNode) {
939
+ propertyB = propertyB.property;
972
940
  }
973
941
 
974
- // The RemoteObjectProperty overload is kept for web test compatibility for now.
975
- static compareProperties(propertyA: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
976
- propertyB: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
977
- sortPropertiesAlphabetically = true): number {
978
- if (propertyA instanceof ObjectTreeNode) {
979
- propertyA = propertyA.property;
980
- }
981
- if (propertyB instanceof ObjectTreeNode) {
982
- propertyB = propertyB.property;
983
- }
942
+ if (!propertyA.synthetic && propertyB.synthetic) {
943
+ return 1;
944
+ }
945
+ if (!propertyB.synthetic && propertyA.synthetic) {
946
+ return -1;
947
+ }
948
+ if (!propertyA.isOwn && propertyB.isOwn) {
949
+ return 1;
950
+ }
951
+ if (!propertyB.isOwn && propertyA.isOwn) {
952
+ return -1;
953
+ }
954
+ if (!propertyA.enumerable && propertyB.enumerable) {
955
+ return 1;
956
+ }
957
+ if (!propertyB.enumerable && propertyA.enumerable) {
958
+ return -1;
959
+ }
960
+ if (propertyA.symbol && !propertyB.symbol) {
961
+ return 1;
962
+ }
963
+ if (propertyB.symbol && !propertyA.symbol) {
964
+ return -1;
965
+ }
966
+ if (propertyA.private && !propertyB.private) {
967
+ return 1;
968
+ }
969
+ if (propertyB.private && !propertyA.private) {
970
+ return -1;
971
+ }
984
972
 
985
- if (!propertyA.synthetic && propertyB.synthetic) {
986
- return 1;
987
- }
988
- if (!propertyB.synthetic && propertyA.synthetic) {
989
- return -1;
990
- }
991
- if (!propertyA.isOwn && propertyB.isOwn) {
992
- return 1;
993
- }
994
- if (!propertyB.isOwn && propertyA.isOwn) {
995
- return -1;
996
- }
997
- if (!propertyA.enumerable && propertyB.enumerable) {
998
- return 1;
999
- }
1000
- if (!propertyB.enumerable && propertyA.enumerable) {
1001
- return -1;
1002
- }
1003
- if (propertyA.symbol && !propertyB.symbol) {
1004
- return 1;
1005
- }
1006
- if (propertyB.symbol && !propertyA.symbol) {
1007
- return -1;
1008
- }
1009
- if (propertyA.private && !propertyB.private) {
973
+ if (sortPropertiesAlphabetically) {
974
+ const nameA = propertyA.name;
975
+ const nameB = propertyB.name;
976
+ if (nameA.startsWith('_') && !nameB.startsWith('_')) {
1010
977
  return 1;
1011
978
  }
1012
- if (propertyB.private && !propertyA.private) {
979
+ if (nameB.startsWith('_') && !nameA.startsWith('_')) {
1013
980
  return -1;
1014
981
  }
1015
-
1016
- if (sortPropertiesAlphabetically) {
1017
- const nameA = propertyA.name;
1018
- const nameB = propertyB.name;
1019
- if (nameA.startsWith('_') && !nameB.startsWith('_')) {
1020
- return 1;
1021
- }
1022
- if (nameB.startsWith('_') && !nameA.startsWith('_')) {
1023
- return -1;
1024
- }
1025
- return Platform.StringUtilities.naturalOrderComparator(nameA, nameB);
1026
- }
1027
-
1028
- return 0;
1029
- }
1030
-
1031
- static valueElementForFunctionDescription(description?: string, includePreview?: boolean, defaultName?: string,
1032
- details?: SDK.DebuggerModel.FunctionDetails|null,
1033
- linkify?: boolean): LitTemplate {
1034
- const contents =
1035
- (description: string, defaultName: string): {prefix: string, abbreviation: string, body: string} => {
1036
- const text = description.replace(/^function [gs]et /, 'function ')
1037
- .replace(/^function [gs]et\(/, 'function\(')
1038
- .replace(/^[gs]et /, '');
1039
-
1040
- // This set of best-effort regular expressions captures common function descriptions.
1041
- // Ideally, some parser would provide prefix, arguments, function body text separately.
1042
- const asyncMatch = text.match(/^(async\s+function)/);
1043
- const isGenerator = text.startsWith('function*');
1044
- const isGeneratorShorthand = text.startsWith('*');
1045
- const isBasic = !isGenerator && text.startsWith('function');
1046
- const isClass = text.startsWith('class ') || text.startsWith('class{');
1047
- const firstArrowIndex = text.indexOf('=>');
1048
- const isArrow = !asyncMatch && !isGenerator && !isBasic && !isClass && firstArrowIndex > 0;
1049
-
1050
- if (isClass) {
1051
- const body = text.substring('class'.length);
1052
- const classNameMatch = /^[^{\s]+/.exec(body.trim());
1053
- let className: string = defaultName;
1054
- if (classNameMatch) {
1055
- className = classNameMatch[0].trim() || defaultName;
1056
- }
1057
- return {prefix: 'class', body, abbreviation: className};
1058
- }
1059
- if (asyncMatch) {
1060
- const body = text.substring(asyncMatch[1].length);
1061
- return {prefix: 'async \u0192', body, abbreviation: nameAndArguments(body)};
1062
- }
1063
- if (isGenerator) {
1064
- const body = text.substring('function*'.length);
1065
- return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1066
- }
1067
- if (isGeneratorShorthand) {
1068
- const body = text.substring('*'.length);
1069
- return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1070
- }
1071
- if (isBasic) {
1072
- const body = text.substring('function'.length);
1073
- return {prefix: '\u0192', body, abbreviation: nameAndArguments(body)};
1074
- }
1075
- if (isArrow) {
1076
- const maxArrowFunctionCharacterLength = 60;
1077
- let abbreviation: string = text;
1078
- if (defaultName) {
1079
- abbreviation = defaultName + '()';
1080
- } else if (text.length > maxArrowFunctionCharacterLength) {
1081
- abbreviation = text.substring(0, firstArrowIndex + 2) + ' {…}';
1082
- }
1083
- return {prefix: '', body: text, abbreviation};
1084
- }
1085
- return {prefix: '\u0192', body: text, abbreviation: nameAndArguments(text)};
1086
- };
1087
-
1088
- const {prefix, body, abbreviation} = contents(description ?? '', defaultName ?? '');
1089
- const maxFunctionBodyLength = 200;
1090
-
1091
- const location = details?.location;
1092
- const clickHandler = linkify && location ? (event: Event) => {
1093
- void Common.Revealer.reveal(location);
1094
- event.consume(true);
1095
- } : undefined;
1096
-
1097
- const classes = classMap({
1098
- 'object-value-function': true,
1099
- linkified: Boolean(linkify && location),
1100
- });
1101
- const title = description ? Platform.StringUtilities.trimEndWithMaxLength(description, 500) : undefined;
1102
-
1103
- return html`<span
1104
- class=${classes}
1105
- @click=${clickHandler || nothing}
1106
- title=${ifDefined(title)}>${prefix && html`<span class=object-value-function-prefix>${prefix} </span>`}${
1107
- includePreview ? Platform.StringUtilities.trimEndWithMaxLength(body.trim(), maxFunctionBodyLength) :
1108
- abbreviation.replace(/\n/g, ' ')}</span>`;
1109
-
1110
- function nameAndArguments(contents: string): string {
1111
- const startOfArgumentsIndex = contents.indexOf('(');
1112
- const endOfArgumentsMatch = contents.match(/\)\s*{/);
1113
- if (startOfArgumentsIndex !== -1 && endOfArgumentsMatch?.index !== undefined &&
1114
- endOfArgumentsMatch.index > startOfArgumentsIndex) {
1115
- const name = contents.substring(0, startOfArgumentsIndex).trim() || (defaultName ?? '');
1116
- const args = contents.substring(startOfArgumentsIndex, endOfArgumentsMatch.index + 1);
1117
- return name + args;
1118
- }
1119
- return defaultName + '()';
1120
- }
982
+ return Platform.StringUtilities.naturalOrderComparator(nameA, nameB);
1121
983
  }
1122
984
 
1123
- static getMemoryIcon(object: SDK.RemoteObject.RemoteObject, expression?: string): LitTemplate {
1124
- // Directly set styles on memory icon, so that the memory icon is also
1125
- // styled within the context of code mirror.
1126
- // clang-format off
1127
- return !object.isLinearMemoryInspectable() ? nothing : html`<devtools-icon
1128
- name=memory
1129
- style="width: var(--sys-size-8); height: 13px; vertical-align: sub; cursor: pointer;"
1130
- @click=${(event: Event) => {
1131
- event.consume();
1132
- void Common.Revealer.reveal(new SDK.RemoteObject.LinearMemoryInspectable(object, expression));
1133
- }}
1134
- jslog=${VisualLogging.action('open-memory-inspector').track({click: true})}
1135
- title=${i18nString(UIStrings.openInMemoryInpector)}
1136
- aria-label=${i18nString(UIStrings.openInMemoryInpector)}></devtools-icon>`;
1137
- // clang-format on
1138
- }
1139
-
1140
- static appendMemoryIcon(element: Element, object: SDK.RemoteObject.RemoteObject, expression?: string): void {
1141
- const fragment = document.createDocumentFragment();
1142
- // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
1143
- render(ObjectPropertiesSection.getMemoryIcon(object, expression), fragment);
1144
- element.appendChild(fragment);
1145
- }
985
+ return 0;
986
+ }
1146
987
 
1147
- static isDisplayableProperty(property: SDK.RemoteObject.RemoteObjectProperty,
1148
- parentProperty?: SDK.RemoteObject.RemoteObjectProperty): boolean {
1149
- if (!parentProperty?.synthetic) {
1150
- return true;
988
+ export function valueElementForFunctionDescription(description?: string, includePreview?: boolean, defaultName?: string,
989
+ details?: SDK.DebuggerModel.FunctionDetails|null,
990
+ linkify?: boolean): LitTemplate {
991
+ const contents = (description: string, defaultName: string): {prefix: string, abbreviation: string, body: string} => {
992
+ const text = description.replace(/^function [gs]et /, 'function ')
993
+ .replace(/^function [gs]et\(/, 'function\(')
994
+ .replace(/^[gs]et /, '');
995
+
996
+ // This set of best-effort regular expressions captures common function descriptions.
997
+ // Ideally, some parser would provide prefix, arguments, function body text separately.
998
+ const asyncMatch = text.match(/^(async\s+function)/);
999
+ const isGenerator = text.startsWith('function*');
1000
+ const isGeneratorShorthand = text.startsWith('*');
1001
+ const isBasic = !isGenerator && text.startsWith('function');
1002
+ const isClass = text.startsWith('class ') || text.startsWith('class{');
1003
+ const firstArrowIndex = text.indexOf('=>');
1004
+ const isArrow = !asyncMatch && !isGenerator && !isBasic && !isClass && firstArrowIndex > 0;
1005
+
1006
+ if (isClass) {
1007
+ const body = text.substring('class'.length);
1008
+ const classNameMatch = /^[^{\s]+/.exec(body.trim());
1009
+ let className: string = defaultName;
1010
+ if (classNameMatch) {
1011
+ className = classNameMatch[0].trim() || defaultName;
1012
+ }
1013
+ return {prefix: 'class', body, abbreviation: className};
1014
+ }
1015
+ if (asyncMatch) {
1016
+ const body = text.substring(asyncMatch[1].length);
1017
+ return {prefix: 'async \u0192', body, abbreviation: nameAndArguments(body)};
1018
+ }
1019
+ if (isGenerator) {
1020
+ const body = text.substring('function*'.length);
1021
+ return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1022
+ }
1023
+ if (isGeneratorShorthand) {
1024
+ const body = text.substring('*'.length);
1025
+ return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1026
+ }
1027
+ if (isBasic) {
1028
+ const body = text.substring('function'.length);
1029
+ return {prefix: '\u0192', body, abbreviation: nameAndArguments(body)};
1030
+ }
1031
+ if (isArrow) {
1032
+ const maxArrowFunctionCharacterLength = 60;
1033
+ let abbreviation: string = text;
1034
+ if (defaultName) {
1035
+ abbreviation = defaultName + '()';
1036
+ } else if (text.length > maxArrowFunctionCharacterLength) {
1037
+ abbreviation = text.substring(0, firstArrowIndex + 2) + ' {…}';
1038
+ }
1039
+ return {prefix: '', body: text, abbreviation};
1151
1040
  }
1152
- const name = property.name;
1153
- const useless = (parentProperty.name === '[[Entries]]' && (name === 'length' || name === '__proto__'));
1154
- return !useless;
1155
- }
1041
+ return {prefix: '\u0192', body: text, abbreviation: nameAndArguments(text)};
1042
+ };
1156
1043
 
1157
- skipProto(): void {
1158
- this.skipProtoInternal = true;
1159
- }
1044
+ const {prefix, body, abbreviation} = contents(description ?? '', defaultName ?? '');
1045
+ const maxFunctionBodyLength = 200;
1160
1046
 
1161
- expand(): void {
1162
- this.#objectTreeElement.expand();
1163
- }
1047
+ const location = details?.location;
1048
+ const clickHandler = linkify && location ? (event: Event) => {
1049
+ void Common.Revealer.reveal(location);
1050
+ event.consume(true);
1051
+ } : undefined;
1164
1052
 
1165
- objectTreeElement(): UI.TreeOutline.TreeElement {
1166
- return this.#objectTreeElement;
1167
- }
1053
+ const classes = classMap({
1054
+ 'object-value-function': true,
1055
+ linkified: Boolean(linkify && location),
1056
+ });
1057
+ const title = description ? Platform.StringUtilities.trimEndWithMaxLength(description, 500) : undefined;
1168
1058
 
1169
- enableContextMenu(): void {
1170
- this.element.addEventListener('contextmenu', this.contextMenuEventFired.bind(this), false);
1059
+ return html`<span
1060
+ class=${classes}
1061
+ @click=${clickHandler || nothing}
1062
+ title=${ifDefined(title)}>${prefix && html`<span class=object-value-function-prefix>${prefix} </span>`}${
1063
+ includePreview ? Platform.StringUtilities.trimEndWithMaxLength(body.trim(), maxFunctionBodyLength) :
1064
+ abbreviation.replace(/\n/g, ' ')}</span>`;
1065
+
1066
+ function nameAndArguments(contents: string): string {
1067
+ const startOfArgumentsIndex = contents.indexOf('(');
1068
+ const endOfArgumentsMatch = contents.match(/\)\s*{/);
1069
+ if (startOfArgumentsIndex !== -1 && endOfArgumentsMatch?.index !== undefined &&
1070
+ endOfArgumentsMatch.index > startOfArgumentsIndex) {
1071
+ const name = contents.substring(0, startOfArgumentsIndex).trim() || (defaultName ?? '');
1072
+ const args = contents.substring(startOfArgumentsIndex, endOfArgumentsMatch.index + 1);
1073
+ return name + args;
1074
+ }
1075
+ return defaultName + '()';
1171
1076
  }
1077
+ }
1172
1078
 
1173
- private contextMenuEventFired(event: Event): void {
1174
- const contextMenu = new UI.ContextMenu.ContextMenu(event);
1175
- contextMenu.appendApplicableItems(this.root);
1176
- if (this.root.object instanceof SDK.RemoteObject.LocalJSONObject) {
1177
- contextMenu.viewSection().appendItem(
1178
- i18nString(UIStrings.expandRecursively),
1179
- this.#objectTreeElement.expandRecursively.bind(this.#objectTreeElement, EXPANDABLE_MAX_DEPTH),
1180
- {jslogContext: 'expand-recursively'});
1181
- contextMenu.viewSection().appendItem(i18nString(UIStrings.collapseChildren),
1182
- this.#objectTreeElement.collapseChildren.bind(this.#objectTreeElement),
1183
- {jslogContext: 'collapse-children'});
1184
- }
1185
- void contextMenu.show();
1186
- }
1079
+ export function getMemoryIcon(object: SDK.RemoteObject.RemoteObject, expression?: string): LitTemplate {
1080
+ // Directly set styles on memory icon, so that the memory icon is also
1081
+ // styled within the context of code mirror.
1082
+ // clang-format off
1083
+ return !object.isLinearMemoryInspectable() ? nothing : html`<devtools-icon
1084
+ name=memory
1085
+ style="width: var(--sys-size-8); height: 13px; vertical-align: sub; cursor: pointer;"
1086
+ @click=${(event: Event) => {
1087
+ event.consume();
1088
+ void Common.Revealer.reveal(new SDK.RemoteObject.LinearMemoryInspectable(object, expression));
1089
+ }}
1090
+ jslog=${VisualLogging.action('open-memory-inspector').track({click: true})}
1091
+ title=${i18nString(UIStrings.openInMemoryInpector)}
1092
+ aria-label=${i18nString(UIStrings.openInMemoryInpector)}></devtools-icon>`;
1093
+ // clang-format on
1094
+ }
1187
1095
 
1188
- titleLessMode(): void {
1189
- this.#objectTreeElement.listItemElement.classList.add('hidden');
1190
- this.#objectTreeElement.childrenListElement.classList.add('title-less-mode');
1191
- this.#objectTreeElement.expand();
1096
+ function isDisplayableProperty(property: SDK.RemoteObject.RemoteObjectProperty,
1097
+ parentProperty?: SDK.RemoteObject.RemoteObjectProperty): boolean {
1098
+ if (!parentProperty?.synthetic) {
1099
+ return true;
1192
1100
  }
1101
+ const name = property.name;
1102
+ const useless = (parentProperty.name === '[[Entries]]' && (name === 'length' || name === '__proto__'));
1103
+ return !useless;
1193
1104
  }
1194
1105
 
1195
1106
  export class ObjectPropertiesSectionWidget extends UI.Widget.Widget {
@@ -1611,74 +1522,6 @@ export const OBJECT_PROPERTIES_SECTION_DEFAULT_VIEW: ObjectPropertiesSectionView
1611
1522
  target);
1612
1523
  };
1613
1524
 
1614
- class RootElement extends UI.TreeOutline.TreeElement {
1615
- private readonly object: ObjectTree;
1616
- private readonly linkifier: Components.Linkifier.Linkifier|undefined;
1617
- private readonly emptyPlaceholder: string|null|undefined;
1618
- override toggleOnClick: boolean;
1619
- constructor(object: ObjectTree, linkifier?: Components.Linkifier.Linkifier, emptyPlaceholder?: string|null) {
1620
- const contentElement = document.createElement('slot');
1621
- super(contentElement);
1622
-
1623
- this.object = object;
1624
- this.object.addEventListener(ObjectTreeNodeBase.Events.CHILDREN_CHANGED, this.onpopulate, this);
1625
- this.linkifier = linkifier;
1626
- this.emptyPlaceholder = emptyPlaceholder;
1627
-
1628
- this.setExpandable(true);
1629
- this.selectable = true;
1630
- this.toggleOnClick = true;
1631
- this.listItemElement.classList.add('object-properties-section-root-element');
1632
- this.listItemElement.addEventListener('contextmenu', this.onContextMenu.bind(this), false);
1633
- if (object.expanded) {
1634
- this.expand();
1635
- }
1636
- }
1637
-
1638
- override onexpand(): void {
1639
- this.object.expanded = true;
1640
- if (this.treeOutline) {
1641
- this.treeOutline.element.classList.add('expanded');
1642
- }
1643
- }
1644
-
1645
- override oncollapse(): void {
1646
- this.object.expanded = false;
1647
- if (this.treeOutline) {
1648
- this.treeOutline.element.classList.remove('expanded');
1649
- }
1650
- }
1651
-
1652
- override ondblclick(_e: Event): boolean {
1653
- return true;
1654
- }
1655
-
1656
- private onContextMenu(event: Event): void {
1657
- const contextMenu = new UI.ContextMenu.ContextMenu(event);
1658
- populateObjectTreeContextMenu(
1659
- contextMenu,
1660
- this.object,
1661
- this.expandRecursively.bind(this, EXPANDABLE_MAX_DEPTH),
1662
- this.collapseChildren.bind(this),
1663
- () => {
1664
- this.object.sortPropertiesAlphabetically = !this.object.sortPropertiesAlphabetically;
1665
- },
1666
- () => {
1667
- this.object.includeNullOrUndefinedValues = !this.object.includeNullOrUndefinedValues;
1668
- },
1669
- );
1670
- void contextMenu.show();
1671
- }
1672
-
1673
- override async onpopulate(): Promise<void> {
1674
- this.removeChildren();
1675
- const treeOutline = (this.treeOutline as ObjectPropertiesSection | null);
1676
- const skipProto = treeOutline ? Boolean(treeOutline.skipProtoInternal) : false;
1677
- return await ObjectPropertyTreeElement.populate(this, this.object, skipProto, false, this.linkifier,
1678
- this.emptyPlaceholder);
1679
- }
1680
- }
1681
-
1682
1525
  export function renderPropertyName(name: string|null, isPrivate?: boolean, title?: string): TemplateResult {
1683
1526
  if (name === null) {
1684
1527
  return html`<span class="name" title=${ifDefined(title)}></span>`;
@@ -1701,8 +1544,7 @@ export async function formatObjectAsFunction(func: SDK.RemoteObject.RemoteObject
1701
1544
  // The includePreview flag is false for formats such as console.dir().
1702
1545
  const defaultName = details?.functionName ?? (includePreview ? '' : 'anonymous');
1703
1546
 
1704
- return ObjectPropertiesSection.valueElementForFunctionDescription(func.description, includePreview, defaultName,
1705
- details, linkify);
1547
+ return valueElementForFunctionDescription(func.description, includePreview, defaultName, details, linkify);
1706
1548
  }
1707
1549
 
1708
1550
  export function renderPropertyValue(value: SDK.RemoteObject.RemoteObject, wasThrown: boolean, showPreview: boolean,
@@ -1770,7 +1612,7 @@ export function renderPropertyValue(value: SDK.RemoteObject.RemoteObject, wasThr
1770
1612
  title = tooLong ? undefined : text;
1771
1613
  content = tooLong ? widget(ExpandableTextPropertyValue, {text}) : renderTrustedType(description, className);
1772
1614
  } else if (isFunction) {
1773
- content = ObjectPropertiesSection.valueElementForFunctionDescription(description);
1615
+ content = valueElementForFunctionDescription(description);
1774
1616
  } else if (description.length > maxRenderableStringLength) {
1775
1617
  title = description;
1776
1618
  content = widget(ExpandableTextPropertyValue, {text: description});
@@ -1780,8 +1622,7 @@ export function renderPropertyValue(value: SDK.RemoteObject.RemoteObject, wasThr
1780
1622
  const previewContent = hasPreview ?
1781
1623
  new RemoteObjectPreviewFormatter().renderObjectPreview(value.preview, includeNullOrUndefined) :
1782
1624
  description;
1783
- content = html`${previewContent}${
1784
- isSyntheticProperty ? nothing : ObjectPropertiesSection.getMemoryIcon(value, variableName)}`;
1625
+ content = html`${previewContent}${isSyntheticProperty ? nothing : getMemoryIcon(value, variableName)}`;
1785
1626
  }
1786
1627
 
1787
1628
  if (wasThrown) {
@@ -1951,7 +1792,7 @@ export const OBJECT_PROPERTY_DEFAULT_VIEW: ObjectPropertyView = (input, output,
1951
1792
  Platform.StringUtilities.trimMiddle(property.value.description ?? '',
1952
1793
  maxRenderableStringLength)}${
1953
1794
  property.synthetic ? nothing :
1954
- ObjectPropertiesSection.getMemoryIcon(property.value)}</span>` :
1795
+ getMemoryIcon(property.value)}</span>` :
1955
1796
  value()
1956
1797
  }</devtools-highlight>
1957
1798
  <datalist id=${completionsId}>${repeat(input.completions, c => html`<option>${c}</option>`)}</datalist>
@@ -2184,7 +2025,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2184
2025
  for (const childNode of ObjectPropertyTreeElement.createNodes(
2185
2026
  value, skipProto, skipGettersAndSetters, linkifier, emptyPlaceholder,
2186
2027
  property => treeElement instanceof ObjectPropertyTreeElement &&
2187
- !ObjectPropertiesSection.isDisplayableProperty(property, treeElement.property?.property))) {
2028
+ !isDisplayableProperty(property, treeElement.property?.property))) {
2188
2029
  treeElement.appendChild(childNode);
2189
2030
  }
2190
2031
  }
@@ -2224,7 +2065,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2224
2065
  empty = false;
2225
2066
  }
2226
2067
  const sortPropertiesAlphabetically = properties?.[0]?.parent?.sortPropertiesAlphabetically ?? true;
2227
- properties?.sort((a, b) => ObjectPropertiesSection.compareProperties(a, b, sortPropertiesAlphabetically));
2068
+ properties?.sort((a, b) => compareProperties(a, b, sortPropertiesAlphabetically));
2228
2069
 
2229
2070
  const entriesProperty = internalProperties?.find(({property}) => property.name === '[[Entries]]');
2230
2071
  if (entriesProperty) {
@@ -2285,7 +2126,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2285
2126
  for (const childNode of this.createPropertyNodes(
2286
2127
  children, skipProto, skipGettersAndSetters, linkifier, emptyPlaceholder,
2287
2128
  property => treeNode instanceof ObjectPropertyTreeElement &&
2288
- !ObjectPropertiesSection.isDisplayableProperty(property, treeNode.property?.property))) {
2129
+ !isDisplayableProperty(property, treeNode.property?.property))) {
2289
2130
  treeNode.appendChild(childNode);
2290
2131
  }
2291
2132
  }
@@ -2344,12 +2185,10 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2344
2185
  }
2345
2186
 
2346
2187
  override async onpopulate(): Promise<void> {
2347
- const treeOutline = (this.treeOutline as ObjectPropertiesSection | null);
2348
- const skipProto = treeOutline ? Boolean(treeOutline.skipProtoInternal) : false;
2349
2188
  this.removeChildren();
2350
2189
 
2351
2190
  if (this.property.object) {
2352
- await ObjectPropertyTreeElement.populate(this, this.property, skipProto, false, this.linkifier);
2191
+ await ObjectPropertyTreeElement.populate(this, this.property, false, false, this.linkifier);
2353
2192
  if (this.childCount() > this.maxNumPropertiesToShow) {
2354
2193
  this.createShowAllPropertiesButton();
2355
2194
  }
@@ -350,11 +350,16 @@ export const knownContextValues = new Set([
350
350
  'adorner-settings',
351
351
  'ads',
352
352
  'af',
353
+ 'affected-cookie',
353
354
  'affected-cookies',
354
355
  'affected-documents',
356
+ 'affected-element',
355
357
  'affected-elements',
358
+ 'affected-raw-cookie',
356
359
  'affected-raw-cookies',
360
+ 'affected-request',
357
361
  'affected-requests',
362
+ 'affected-resources',
358
363
  'affected-sources',
359
364
  'ai-annotations-enabled',
360
365
  'ai-assistance-enabled',
@@ -2181,6 +2186,7 @@ export const knownContextValues = new Set([
2181
2186
  'isolates',
2182
2187
  'isolation',
2183
2188
  'issue',
2189
+ 'issue-description',
2184
2190
  'issuer',
2185
2191
  'issues',
2186
2192
  'issues-pane',
@@ -2344,6 +2350,8 @@ export const knownContextValues = new Set([
2344
2350
  'latency',
2345
2351
  'latitude',
2346
2352
  'layer',
2353
+ 'layer-details',
2354
+ 'layer-item',
2347
2355
  'layers',
2348
2356
  'layers-3d-view',
2349
2357
  'layers-details',
@@ -3680,6 +3688,7 @@ export const knownContextValues = new Set([
3680
3688
  'serious',
3681
3689
  'server',
3682
3690
  'server-timing-api',
3691
+ 'service-worker',
3683
3692
  'service-worker-update-on-reload',
3684
3693
  'service-workers',
3685
3694
  'session',
@@ -3996,6 +4005,7 @@ export const knownContextValues = new Set([
3996
4005
  'storage-items-view.delete-selected',
3997
4006
  'storage-items-view.refresh',
3998
4007
  'storage-key',
4008
+ 'storage-usage',
3999
4009
  'storage.clear-site-data',
4000
4010
  'store-as-global-variable',
4001
4011
  'stroke',
@@ -4479,6 +4489,7 @@ export const knownContextValues = new Set([
4479
4489
  'url-pattern',
4480
4490
  'url-pattern-warning',
4481
4491
  'usage',
4492
+ 'usage-breakdown',
4482
4493
  'usb',
4483
4494
  'use-code-with-caution',
4484
4495
  'use-custom-accepted-encodings',
package/mcp/mcp.ts CHANGED
@@ -5,11 +5,8 @@
5
5
  // Instantiating a DevTools universe requires settings from these meta files.
6
6
  // Until settings registration is handled differently, the easiest solution is to
7
7
  // just import relevant meta files (as long as they don't contain any UI related code)
8
- import '../front_end/core/sdk/sdk-meta.js';
9
8
  import '../front_end/models/workspace/workspace-meta.js';
10
- import '../front_end/models/persistence/persistence-meta.js';
11
9
  import '../front_end/models/logs/logs-meta.js';
12
- import '../front_end/models/badges/badges-meta.js';
13
10
 
14
11
  /**
15
12
  * IMPORTANT! Make sure that any class that is exported here has related unit