chrome-devtools-frontend 1.0.1730971 → 1.0.1732418

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 (153) hide show
  1. package/front_end/Tests.js +20 -0
  2. package/front_end/core/host/AidaClient.ts +47 -3
  3. package/front_end/core/host/AidaClientTypes.ts +8 -1
  4. package/front_end/core/host/AidaGcaTranslation.ts +1 -1
  5. package/front_end/core/sdk/NetworkManager.ts +2 -1
  6. package/front_end/generated/Deprecation.ts +0 -8
  7. package/front_end/generated/InspectorBackendCommands.ts +2 -1
  8. package/front_end/generated/protocol.ts +9 -0
  9. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +1 -1
  10. package/front_end/models/ai_assistance/contexts/LighthouseContext.snapshot.txt +6 -1
  11. package/front_end/models/ai_assistance/contexts/LighthouseContext.ts +4 -3
  12. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +91 -11
  13. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +90 -43
  14. package/front_end/models/ai_assistance/skills/styling.md +4 -2
  15. package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +31 -36
  16. package/front_end/models/bindings/CompilerScriptMapping.ts +0 -1
  17. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +0 -1
  18. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -1
  19. package/front_end/models/har/HARFormat.ts +1 -0
  20. package/front_end/models/har/Importer.ts +7 -1
  21. package/front_end/models/har/Log.snapshot.txt +2 -0
  22. package/front_end/models/har/Log.ts +2 -0
  23. package/front_end/models/javascript_metadata/NativeFunctions.ts +0 -4
  24. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -1
  25. package/front_end/panels/ai_assistance/components/ChatInput.ts +2 -0
  26. package/front_end/panels/ai_assistance/components/chatInput.css +1 -1
  27. package/front_end/panels/ai_assistance/components/exploreWidget.css +1 -1
  28. package/front_end/panels/animation/animationTimeline.css +11 -9
  29. package/front_end/panels/application/IndexedDBViews.ts +2 -2
  30. package/front_end/panels/application/PrivateVerificationTokensView.ts +217 -9
  31. package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -1
  32. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  33. package/front_end/panels/application/StorageView.ts +1 -1
  34. package/front_end/panels/application/appManifestView.css +0 -6
  35. package/front_end/panels/application/backgroundServiceView.css +0 -21
  36. package/front_end/panels/application/components/backForwardCacheView.css +1 -9
  37. package/front_end/panels/application/components/endpointsGrid.css +1 -1
  38. package/front_end/panels/application/components/permissionsPolicySection.css +1 -1
  39. package/front_end/panels/application/cookieItemsView.css +0 -1
  40. package/front_end/panels/application/frameDetailsReportView.css +0 -10
  41. package/front_end/panels/application/indexedDBViews.css +0 -6
  42. package/front_end/panels/application/privateVerificationTokensView.css +12 -0
  43. package/front_end/panels/application/resourcesPanel.css +0 -14
  44. package/front_end/panels/application/serviceWorkerUpdateCycleView.css +4 -4
  45. package/front_end/panels/application/serviceWorkersView.css +1 -1
  46. package/front_end/panels/changes/CombinedDiffView.ts +1 -1
  47. package/front_end/panels/comments/CommentsPane.ts +5 -0
  48. package/front_end/panels/common/CommentsOverlayWidget.ts +337 -117
  49. package/front_end/panels/console/consoleView.css +5 -3
  50. package/front_end/panels/coverage/CoverageView.ts +0 -1
  51. package/front_end/panels/coverage/coverageView.css +4 -3
  52. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +0 -1
  53. package/front_end/panels/elements/AccessibilityTreeView.ts +1 -1
  54. package/front_end/panels/elements/CSSValueTraceView.ts +2 -4
  55. package/front_end/panels/elements/DOMTreeContextMenu.ts +1 -1
  56. package/front_end/panels/elements/DOMTreeWidget.ts +14 -0
  57. package/front_end/panels/elements/MetricsSidebarPane.ts +1 -1
  58. package/front_end/panels/elements/PlatformFontsWidget.ts +0 -1
  59. package/front_end/panels/elements/PropertiesWidget.ts +1 -1
  60. package/front_end/panels/elements/StylesSidebarPane.ts +2 -0
  61. package/front_end/panels/elements/WebCustomData.ts +1 -1
  62. package/front_end/panels/elements/components/cssHintDetailsView.css +1 -1
  63. package/front_end/panels/elements/components/cssVariableValueView.css +3 -1
  64. package/front_end/panels/elements/components/elementsTreeExpandButton.css +3 -2
  65. package/front_end/panels/elements/components/stylePropertyEditor.css +2 -2
  66. package/front_end/panels/elements/layoutPane.css +1 -1
  67. package/front_end/panels/elements/metricsSidebarPane.css +4 -4
  68. package/front_end/panels/elements/platformFontsWidget.css +1 -1
  69. package/front_end/panels/elements/stylesSidebarPane.css +1 -1
  70. package/front_end/panels/emulation/DeviceModeView.ts +4 -3
  71. package/front_end/panels/emulation/deviceModeView.css +6 -7
  72. package/front_end/panels/event_listeners/eventListenersView.css +4 -4
  73. package/front_end/panels/explain/components/consoleInsight.css +3 -18
  74. package/front_end/panels/issues/issuesTree.css +5 -6
  75. package/front_end/panels/layer_viewer/LayerDetailsView.ts +4 -2
  76. package/front_end/panels/layer_viewer/TransformController.ts +106 -54
  77. package/front_end/panels/lighthouse/lighthousePanel.css +4 -7
  78. package/front_end/panels/lighthouse/lighthouseStartView.css +1 -2
  79. package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +4 -4
  80. package/front_end/panels/media/EventTimelineView.ts +1 -4
  81. package/front_end/panels/media/TickingFlameChart.ts +3 -2
  82. package/front_end/panels/media/playerListView.css +6 -3
  83. package/front_end/panels/media/playerMessagesView.css +2 -2
  84. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +1 -1
  85. package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +5 -7
  86. package/front_end/panels/network/NetworkConfigView.ts +1 -1
  87. package/front_end/panels/network/binaryResourceView.css +0 -7
  88. package/front_end/panels/network/networkLogView.css +0 -7
  89. package/front_end/panels/network/networkTimingTable.css +2 -2
  90. package/front_end/panels/network/requestConditionsDrawer.css +1 -24
  91. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +1 -1
  92. package/front_end/panels/performance_monitor/performanceMonitor.css +1 -1
  93. package/front_end/panels/protocol_monitor/JSONEditor.ts +1 -1
  94. package/front_end/panels/protocol_monitor/protocolMonitor.css +1 -1
  95. package/front_end/panels/recorder/extensionView.css +1 -1
  96. package/front_end/panels/recorder/recorderPanel.css +3 -3
  97. package/front_end/panels/recorder/recordingListView.css +1 -1
  98. package/front_end/panels/recorder/stepEditor.css +2 -2
  99. package/front_end/panels/recorder/stepView.css +0 -24
  100. package/front_end/panels/screencast/screencastView.css +2 -1
  101. package/front_end/panels/search/searchView.css +4 -3
  102. package/front_end/panels/security/SecurityPanelSidebar.ts +0 -1
  103. package/front_end/panels/security/mainView.css +1 -1
  104. package/front_end/panels/security/originView.css +0 -4
  105. package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +2 -1
  106. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +1 -2
  107. package/front_end/panels/sources/breakpointsView.css +0 -1
  108. package/front_end/panels/sources/tabbedEditorContainer.css +1 -1
  109. package/front_end/panels/sources/watchExpressionsSidebarPane.css +2 -2
  110. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +1 -1
  111. package/front_end/panels/timeline/components/OriginMap.ts +1 -1
  112. package/front_end/panels/timeline/components/fieldSettingsDialog.css +1 -1
  113. package/front_end/panels/timeline/components/metricCard.css +1 -1
  114. package/front_end/panels/timeline/components/networkRequestDetails.css +0 -1
  115. package/front_end/panels/timeline/components/networkRequestTooltip.css +2 -2
  116. package/front_end/panels/timeline/timelineFlamechartPopover.css +1 -1
  117. package/front_end/panels/timeline/timelineHistoryManager.css +1 -1
  118. package/front_end/panels/timeline/timelineMiniMap.css +1 -1
  119. package/front_end/panels/timeline/timelineStatusDialog.css +1 -1
  120. package/front_end/panels/web_audio/webAudio.css +0 -20
  121. package/front_end/third_party/chromium/README.chromium +1 -1
  122. package/front_end/ui/comments/CommentAnchorResolver.ts +166 -8
  123. package/front_end/ui/comments/CommentOverlayManager.ts +17 -2
  124. package/front_end/ui/components/diff_view/diffView.css +1 -1
  125. package/front_end/ui/components/markdown_view/markdownView.css +1 -1
  126. package/front_end/ui/components/menus/Menu.ts +1 -1
  127. package/front_end/ui/components/menus/menuItem.css +1 -1
  128. package/front_end/ui/components/panel_feedback/panelFeedback.css +2 -2
  129. package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +1 -1
  130. package/front_end/ui/components/report_view/reportValue.css +5 -2
  131. package/front_end/ui/components/suggestion_input/suggestionInput.css +4 -4
  132. package/front_end/ui/legacy/ContextMenu.ts +3 -0
  133. package/front_end/ui/legacy/GlassPane.ts +3 -3
  134. package/front_end/ui/legacy/SoftContextMenu.ts +7 -1
  135. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +2 -0
  136. package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +7 -6
  137. package/front_end/ui/legacy/components/inline_editor/cssAngleEditor.css +3 -3
  138. package/front_end/ui/legacy/components/perf_ui/flameChart.css +7 -6
  139. package/front_end/ui/legacy/components/perf_ui/overviewGrid.css +4 -3
  140. package/front_end/ui/legacy/components/perf_ui/pieChart.css +3 -3
  141. package/front_end/ui/legacy/components/source_frame/imageView.css +4 -4
  142. package/front_end/ui/legacy/components/utils/jsUtils.css +2 -1
  143. package/front_end/ui/legacy/dropTarget.css +1 -1
  144. package/front_end/ui/legacy/filter.css +4 -3
  145. package/front_end/ui/legacy/inspectorCommon.css +8 -23
  146. package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +1 -1
  147. package/front_end/ui/legacy/suggestBox.css +2 -1
  148. package/front_end/ui/legacy/toolbar.css +2 -1
  149. package/front_end/ui/legacy/treeoutline.css +5 -4
  150. package/front_end/ui/legacy/viewContainers.css +2 -1
  151. package/front_end/ui/visual_logging/KnownContextValues.ts +7 -0
  152. package/inspector_overlay/highlight_anchor.ts +8 -11
  153. package/package.json +1 -1
@@ -20,10 +20,12 @@ The user selected a DOM element in DevTools and asks a query about the element o
20
20
  - Geometry & layout inspection example:
21
21
  ```javascript
22
22
  const rect = $0.getBoundingClientRect();
23
+ const style = window.getComputedStyle($0);
24
+ const parentStyle = $0.parentElement ? window.getComputedStyle($0.parentElement) : null;
23
25
  const data = {
24
26
  rect: {width: rect.width, height: rect.height, top: rect.top, left: rect.left},
25
- computedDisplay: window.getComputedStyle($0).display,
26
- parentDisplay: $0.parentElement ? window.getComputedStyle($0.parentElement).display : null,
27
+ computedDisplay: style.display,
28
+ parentDisplay: parentStyle?.display ?? null,
27
29
  };
28
30
  ```
29
31
  - Style modification example (ALWAYS use `setElementStyles`):
@@ -6,7 +6,6 @@ import * as Host from '../../../core/host/host.js';
6
6
  import * as i18n from '../../../core/i18n/i18n.js';
7
7
  import * as Platform from '../../../core/platform/platform.js';
8
8
  import * as Root from '../../../core/root/root.js';
9
- import * as Formatter from '../../formatter/formatter.js';
10
9
  import type {FunctionHandlerOptions} from '../agents/AiAgent.js';
11
10
  import {JavascriptExecutor} from '../agents/ExecuteJavascript.js';
12
11
 
@@ -25,7 +24,7 @@ import {
25
24
 
26
25
  const lockedString = i18n.i18n.lockedString;
27
26
 
28
- const MAX_FORMATTED_LINES = 40;
27
+ const MAX_LINES = 40;
29
28
  const MAX_LINE_LENGTH = 120;
30
29
  const MAX_TOTAL_CHARACTERS = 2500;
31
30
  const MAX_LONG_LINES_REPORTED = 3;
@@ -50,16 +49,16 @@ const NETWORK_TOOLS_HINT =
50
49
  'To inspect the page\'s network requests, load the `network` skill with `learnSkills` if it is not loaded yet, then use `listNetworkRequests` and `getNetworkRequestDetails`.';
51
50
 
52
51
  /**
53
- * Returns one message per size limit that the formatted code exceeds. Each
54
- * message states the actual value, the limit, and how to fix it, so the model
55
- * can correct every problem in a single retry.
52
+ * Returns one message per size limit that the code exceeds. Each message states
53
+ * the actual value, the limit, and how to fix it, so the model can correct
54
+ * every problem in a single retry.
56
55
  */
57
- function describeSizeLimitViolations(formattedCode: string): string[] {
56
+ function describeSizeLimitViolations(code: string): string[] {
58
57
  const violations: string[] = [];
59
- const lines = formattedCode.split('\n');
58
+ const lines = code.split('\n');
60
59
 
61
- if (lines.length > MAX_FORMATTED_LINES) {
62
- violations.push(`- The code is ${lines.length} lines (max ${MAX_FORMATTED_LINES}). ` +
60
+ if (lines.length > MAX_LINES) {
61
+ violations.push(`- The code is ${lines.length} lines (max ${MAX_LINES}). ` +
63
62
  'Split the logic into smaller calls and return intermediate results in `data`.');
64
63
  }
65
64
 
@@ -79,8 +78,8 @@ function describeSizeLimitViolations(formattedCode: string): string[] {
79
78
  }
80
79
  }
81
80
 
82
- if (formattedCode.length > MAX_TOTAL_CHARACTERS) {
83
- violations.push(`- The code is ${formattedCode.length} characters (max ${MAX_TOTAL_CHARACTERS}). ` +
81
+ if (code.length > MAX_TOTAL_CHARACTERS) {
82
+ violations.push(`- The code is ${code.length} characters (max ${MAX_TOTAL_CHARACTERS}). ` +
84
83
  'Remove unneeded code or split the logic into smaller calls.');
85
84
  }
86
85
 
@@ -105,27 +104,22 @@ export class ExecuteJavaScriptTool implements
105
104
  'This function allows you to run JavaScript code on the inspected page to access the element styles and page content.\nCall this function to gather additional information or modify the page state. Call this function enough times to investigate the user request. Note: You cannot make network requests using this function.';
106
105
 
107
106
  /**
108
- * Formats the code and checks it against the size limits. This method does
109
- * not check syntax: if formatting fails, the formatter returns the original
110
- * code, and running it on the page reports any SyntaxError to the model.
107
+ * Checks the raw AI-generated code against the size limits and returns an
108
+ * error message if any limit is exceeded.
109
+ *
110
+ * Validation runs directly on the unformatted input string so that line-length
111
+ * checks match what `PermissionPrompt` displays and avoid false rejections
112
+ * from formatter line collapsing.
111
113
  */
112
- static async validateAndFormatCode(code: string): Promise<{formattedCode?: string, error?: string}> {
113
- const formatted = await Formatter.ScriptFormatter.formatScriptContent(
114
- 'text/javascript',
115
- code,
116
- ' ',
117
- );
118
- const formattedCode = formatted.formattedContent;
119
- const violations = describeSizeLimitViolations(formattedCode);
114
+ static validateCode(code: string): string|undefined {
115
+ const violations = describeSizeLimitViolations(code);
120
116
  if (violations.length > 0) {
121
- return {
122
- error: [
123
- 'Error: The code was not run because it exceeds size limits after formatting (indented with 2 spaces):',
124
- ...violations,
125
- ].join('\n'),
126
- };
117
+ return [
118
+ 'Error: The code was not run because it exceeds size limits:',
119
+ ...violations,
120
+ ].join('\n');
127
121
  }
128
- return {formattedCode};
122
+ return undefined;
129
123
  }
130
124
 
131
125
  readonly parameters: Host.AidaClient.FunctionObjectParam<keyof ExecuteJavaScriptArgs> = {
@@ -145,7 +139,11 @@ export class ExecuteJavaScriptTool implements
145
139
  * **CRITICAL** Do not call \`console\` methods (e.g., \`console.log\`, \`console.warn\`, \`console.error\`) by default when returning data via \`data\`.
146
140
  * **CRITICAL** Never assume a selector for the elements unless you verified your knowledge.
147
141
  * **CRITICAL** Variables from previous function calls are not available in subsequent calls.
148
- * **CRITICAL** Keep code concise (max 40 lines, 120 characters per line, and 2,500 characters). Split complex logic into multiple steps.
142
+ * **CRITICAL** Keep code concise (max 40 lines, max 120 characters per line, and max 2,500 total characters). To stay well under 120 characters per line:
143
+ - Put each statement, object property, array item, and \`&&\`/\`||\` condition on its own line.
144
+ - Extract long CSS selectors or strings into a variable (or \`.join(', ')\` array) before calling \`querySelectorAll\`.
145
+ - Store intermediate DOM lookups (\`getComputedStyle\`, \`getAttribute\`) in short local variables instead of chaining them on one line.
146
+ - Split complex logic into multiple steps.
149
147
  * **CRITICAL** Network requests (e.g., fetch, XMLHttpRequest) are disabled and cannot be made.
150
148
 
151
149
  For example, to query DOM elements:
@@ -201,12 +199,9 @@ const data = {
201
199
 
202
200
  const isV2Architecture = Root.Runtime.hostConfig.devToolsAiV2Architecture?.enabled;
203
201
  if (isV2Architecture) {
204
- const validationResult = await ExecuteJavaScriptTool.validateAndFormatCode(params.code);
205
- if (validationResult.error) {
206
- return {error: validationResult.error};
207
- }
208
- if (validationResult.formattedCode) {
209
- params.code = validationResult.formattedCode;
202
+ const validationError = ExecuteJavaScriptTool.validateCode(params.code);
203
+ if (validationError) {
204
+ return {error: validationError};
210
205
  }
211
206
  }
212
207
 
@@ -6,7 +6,6 @@ import * as Common from '../../core/common/common.js';
6
6
  import * as Platform from '../../core/platform/platform.js';
7
7
  import * as SDK from '../../core/sdk/sdk.js';
8
8
  import * as TextUtils from '../../core/text_utils/text_utils.js';
9
- // eslint-disable-next-line @devtools/es-modules-import
10
9
  import * as StackTraceImpl from '../stack_trace/stack_trace_impl.js';
11
10
  import * as Workspace from '../workspace/workspace.js';
12
11
 
@@ -11,7 +11,6 @@ import * as SDK from '../../core/sdk/sdk.js';
11
11
  import * as TextUtils from '../../core/text_utils/text_utils.js';
12
12
  import * as Protocol from '../../generated/protocol.js';
13
13
  import * as StackTrace from '../stack_trace/stack_trace.js';
14
- // eslint-disable-next-line @devtools/es-modules-import
15
14
  import * as StackTraceImpl from '../stack_trace/stack_trace_impl.js';
16
15
  import * as Workspace from '../workspace/workspace.js';
17
16
 
@@ -9,7 +9,6 @@ import * as SDK from '../../core/sdk/sdk.js';
9
9
  import type * as TextUtils from '../../core/text_utils/text_utils.js';
10
10
  import * as Protocol from '../../generated/protocol.js';
11
11
  import type * as StackTrace from '../stack_trace/stack_trace.js';
12
- // eslint-disable-next-line @devtools/es-modules-import
13
12
  import * as StackTraceImpl from '../stack_trace/stack_trace_impl.js';
14
13
  import * as Workspace from '../workspace/workspace.js';
15
14
 
@@ -168,6 +168,7 @@ export class HAREntry extends HARBase {
168
168
  // Chrome specific.
169
169
  this.custom.set('connectionId', HARBase.optionalString(data['_connectionId']));
170
170
  this.custom.set('fromCache', HARBase.optionalString(data['_fromCache']));
171
+ this.custom.set('initialPriority', HARBase.optionalString(data['_initialPriority']));
171
172
  this.custom.set('initiator', this.#importInitiator(data['_initiator']));
172
173
  this.custom.set('priority', HARBase.optionalString(data['_priority']));
173
174
  this.custom.set('resourceType', HARBase.optionalString(data['_resourceType']));
@@ -182,8 +182,14 @@ export class Importer {
182
182
  entry.response.cookies.map(this.fillCookieFromHARCookie.bind(this, SDK.Cookie.Type.RESPONSE));
183
183
  request.responseCookies = responseCookies;
184
184
 
185
+ const initialPriority = entry.customAsString('initialPriority');
186
+ // @ts-expect-error This accesses globalThis['Protocol'] where the enum is a JS object, not a TS const enum.
187
+ if (initialPriority && Protocol.Network.ResourcePriority.hasOwnProperty(initialPriority)) {
188
+ request.setInitialPriority(initialPriority as Protocol.Network.ResourcePriority);
189
+ }
190
+
185
191
  const priority = entry.customAsString('priority');
186
- // @ts-expect-error This accesses the globalThis['Protocol'] where the enum is an actual JS object and not just a TS const enum.
192
+ // @ts-expect-error This accesses globalThis['Protocol'] where the enum is a JS object, not a TS const enum.
187
193
  if (priority && Protocol.Network.ResourcePriority.hasOwnProperty(priority)) {
188
194
  request.setPriority((priority as Protocol.Network.ResourcePriority));
189
195
  }
@@ -19,6 +19,7 @@ Content:
19
19
  ],
20
20
  "entries": [
21
21
  {
22
+ "_initialPriority": null,
22
23
  "_initiator": null,
23
24
  "_priority": null,
24
25
  "_resourceType": "document",
@@ -133,6 +134,7 @@ Content:
133
134
  "pageref": "page_1"
134
135
  },
135
136
  {
137
+ "_initialPriority": null,
136
138
  "_initiator": null,
137
139
  "_priority": null,
138
140
  "_resourceType": "xhr",
@@ -121,6 +121,7 @@ export class Entry {
121
121
  }
122
122
 
123
123
  const entry: EntryDTO = {
124
+ _initialPriority: harEntry.request.initialPriority(),
124
125
  _initiator: exportedInitiator,
125
126
  _priority: harEntry.request.priority(),
126
127
  _resourceType: harEntry.request.resourceType().name(),
@@ -507,6 +508,7 @@ export interface Response {
507
508
  export interface EntryDTO {
508
509
  _connectionId?: string;
509
510
  _fromCache?: string;
511
+ _initialPriority: Protocol.Network.ResourcePriority|null;
510
512
  _initiator: Protocol.Network.Initiator|null;
511
513
  _priority: Protocol.Network.ResourcePriority|null;
512
514
  _resourceType: string;
@@ -8301,10 +8301,6 @@ export const NativeFunctions: readonly NativeFunctionValue[] = [
8301
8301
  name: "embed",
8302
8302
  signatures: [["input","?options"]]
8303
8303
  },
8304
- {
8305
- name: "queryFeatureSupport",
8306
- signatures: [["feature"]]
8307
- },
8308
8304
  {
8309
8305
  name: "setPrivateToken",
8310
8306
  signatures: [["privateToken"]]
@@ -480,6 +480,7 @@ function defaultView(input: ViewInput, output: PanelViewOutput, target: HTMLElem
480
480
  }
481
481
 
482
482
  Lit.render(html`
483
+ <style>${aiAssistancePanelStyles}</style>
483
484
  ${toolbarView(input)}
484
485
  <div class="ai-assistance-view-container">
485
486
  <devtools-split-view
@@ -638,7 +639,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
638
639
  }) {
639
640
  super(AiAssistancePanel.panelName);
640
641
  this.view = view;
641
- this.registerRequiredCSS(aiAssistancePanelStyles);
642
642
  this.#aiAssistanceEnabledSetting = this.#getAiAssistanceEnabledSetting();
643
643
 
644
644
  this.#aidaClient = aidaClient;
@@ -225,6 +225,7 @@ export const DEFAULT_VIEW = (input: ViewInput, _output: ViewOutput, target: HTML
225
225
  aria-label=${lockedString(UIStringsNotTranslate.startNewChat)}
226
226
  class="chat-inline-button"
227
227
  @click=${input.onNewConversation}
228
+ .reducedFocusRing=${true}
228
229
  .data=${{
229
230
  variant: Buttons.Button.Variant.TEXT,
230
231
  title: lockedString(UIStringsNotTranslate.startNewChat),
@@ -430,6 +431,7 @@ export const DEFAULT_VIEW = (input: ViewInput, _output: ViewOutput, target: HTML
430
431
  class="start-new-chat-button"
431
432
  aria-label=${lockedString(UIStringsNotTranslate.startNewChat)}
432
433
  @click=${input.onNewConversation}
434
+ .reducedFocusRing=${true}
433
435
  .data=${{
434
436
  variant: Buttons.Button.Variant.OUTLINED,
435
437
  size: Buttons.Button.Size.SMALL,
@@ -210,7 +210,7 @@
210
210
  }
211
211
 
212
212
  .chat-inline-button {
213
- padding-left: 3px;
213
+ padding-left: var(--sys-size-3);
214
214
  }
215
215
 
216
216
  .select-element {
@@ -27,7 +27,7 @@
27
27
 
28
28
  .link {
29
29
  padding: 0;
30
- margin: 0 3px;
30
+ margin: 0 var(--sys-size-3);
31
31
  }
32
32
 
33
33
  .header {
@@ -146,7 +146,7 @@ circle.animation-keyframe-point:active {
146
146
 
147
147
  .animation-timeline-current-time {
148
148
  flex: 0 0 auto;
149
- margin-right: 5px;
149
+ margin-right: var(--sys-size-3);
150
150
  }
151
151
 
152
152
  .animation-grid-header {
@@ -199,11 +199,13 @@ circle.animation-keyframe-point:active {
199
199
  }
200
200
 
201
201
  .animation-scrubber-line {
202
- width: 11px;
202
+ /* 11px width: 2 * 6px left inset (--sys-size-4) - 1px line (--sys-size-1). */
203
+ width: calc(2 * var(--sys-size-4) - var(--sys-size-1));
204
+ /* 6px inset (--sys-size-4) - 1px border (--sys-size-1) aligns the 1px stem. */
203
205
  background: linear-gradient(
204
206
  to right,
205
- transparent 5px,
206
- var(--sys-color-error) 5px,
207
+ transparent calc(var(--sys-size-4) - var(--sys-size-1)),
208
+ var(--sys-color-error) calc(var(--sys-size-4) - var(--sys-size-1)),
207
209
  var(--sys-color-error) var(--sys-size-4),
208
210
  transparent var(--sys-size-4)
209
211
  );
@@ -211,7 +213,8 @@ circle.animation-keyframe-point:active {
211
213
  top: calc(-1 * var(--sys-size-12));
212
214
  height: var(--sys-size-12);
213
215
  left: calc(-1 * var(--sys-size-4));
214
- padding: 0 5px;
216
+ /* 5px side hit padding: 6px (--sys-size-4) - 1px line width (--sys-size-1). */
217
+ padding: 0 calc(var(--sys-size-4) - var(--sys-size-1));
215
218
  z-index: 3;
216
219
  }
217
220
 
@@ -330,7 +333,7 @@ text.animation-timeline-grid-label {
330
333
  align-items: center;
331
334
  justify-content: center;
332
335
  margin-left: var(--timeline-controls-width);
333
- padding: 10px;
336
+ padding: var(--sys-size-5);
334
337
  }
335
338
 
336
339
  .animation-controls-toolbar {
@@ -384,7 +387,7 @@ text.animation-timeline-grid-label {
384
387
  }
385
388
 
386
389
  .animation-buffer-preview:focus-visible {
387
- outline: -webkit-focus-ring-color auto 5px;
390
+ outline: var(--sys-size-2) solid var(--sys-color-state-focus-ring);
388
391
  }
389
392
 
390
393
  .animation-buffer-preview.selected .preview-icon {
@@ -448,7 +451,6 @@ text.animation-timeline-grid-label {
448
451
  .animation-playback-rate-control {
449
452
  margin: var(--sys-size-3) 0 var(--sys-size-3) var(--sys-size-2);
450
453
  display: flex;
451
- width: 120px;
452
454
  }
453
455
 
454
456
  .animation-playback-rate-button {
@@ -461,7 +463,7 @@ text.animation-timeline-grid-label {
461
463
  margin-right: calc(-1 * var(--sys-size-1));
462
464
  padding: var(--sys-size-1) var(--sys-size-3);
463
465
  background-color: transparent;
464
- flex: 1 0 auto;
466
+ width: var(--sys-size-14);
465
467
  text-align: center;
466
468
  }
467
469
 
@@ -442,6 +442,8 @@ export type IDBDataViewView = (input: IndexedDBDataViewInput, output: undefined,
442
442
  // clang-format off
443
443
  export const IDB_DATA_VIEW_DEFAULT_VIEW: IDBDataViewView = (input, _output, target) => {
444
444
  render(html`
445
+ <style>${indexedDBViewsStyles}</style>
446
+ <style>${DataGrid.dataGridStyles}</style>
445
447
  ${renderToolbar(input)}
446
448
  <div class="data-grid-container">
447
449
  ${renderDataGrid(input)}
@@ -488,8 +490,6 @@ export class IDBDataView extends UI.View.SimpleView {
488
490
  viewId: 'idb',
489
491
  });
490
492
  this.#view = view;
491
- this.registerRequiredCSS(indexedDBViewsStyles);
492
- this.registerRequiredCSS(DataGrid.dataGridStyles);
493
493
 
494
494
  this.model = model;
495
495
  this.databaseId = databaseId;
@@ -2,39 +2,145 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
+ import '../../ui/legacy/components/data_grid/data_grid.js';
6
+
7
+ import * as Common from '../../core/common/common.js';
5
8
  import * as i18n from '../../core/i18n/i18n.js';
9
+ import * as Platform from '../../core/platform/platform.js';
10
+ import * as SDK from '../../core/sdk/sdk.js';
11
+ import type * as Protocol from '../../generated/protocol.js';
6
12
  import * as UI from '../../ui/legacy/legacy.js';
7
- import {html, render} from '../../ui/lit/lit.js';
13
+ import {Directives, html, render, type TemplateResult} from '../../ui/lit/lit.js';
8
14
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
9
15
 
10
16
  import privateVerificationTokensViewStyles from './privateVerificationTokensView.css.js';
11
17
 
18
+ const {repeat} = Directives;
19
+
12
20
  const UIStrings = {
21
+ /**
22
+ * @description Text for the issuer of an item.
23
+ */
24
+ issuer: 'Issuer',
25
+ /**
26
+ * @description Column header indicating whether the current origin is the issuer of the token.
27
+ */
28
+ isIssuer: 'Is issuer',
29
+ /**
30
+ * @description Column header indicating whether the current origin is authorized to redeem the token.
31
+ */
32
+ isRedeemer: 'Is redeemer',
13
33
  /**
14
34
  * @description Empty state message when no private verification tokens match the current origin.
15
35
  */
16
36
  noPrivateVerificationTokens: 'No private verification tokens for this origin',
37
+ /**
38
+ * @description Column header for Token ID.
39
+ */
40
+ tokenId: 'Token ID',
41
+ /**
42
+ * @description Column header for Public Key ID.
43
+ */
44
+ keyId: 'Key ID',
45
+ /**
46
+ * @description Column header for token expiration date.
47
+ */
48
+ expiration: 'Expiration',
49
+ /**
50
+ * @description Column header for token creation time.
51
+ */
52
+ creationTime: 'Created',
53
+ /**
54
+ * @description Column header for token protocol version.
55
+ */
56
+ version: 'Version',
57
+ /**
58
+ * @description Column header for base64 encoded token payload.
59
+ */
60
+ tokenPayload: 'Token (Base64)',
17
61
  } as const;
18
62
  const str_ = i18n.i18n.registerUIStrings('panels/application/PrivateVerificationTokensView.ts', UIStrings);
19
63
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
20
64
 
21
- export type ViewInput = Record<string, never>;
65
+ /**
66
+ * Presentation model for a single token row. All values are pre-formatted by
67
+ * the presenter so that the view is a pure projection of its input.
68
+ */
69
+ export interface TokenRow {
70
+ id: string;
71
+ issuerOrigin: Platform.DevToolsPath.UrlString;
72
+ isIssuer: boolean;
73
+ isRedeemer: boolean;
74
+ keyId: number;
75
+ expiration: string;
76
+ creationTime: string;
77
+ version: number;
78
+ token: string;
79
+ }
80
+
81
+ export interface ViewInput {
82
+ tokens: TokenRow[];
83
+ }
84
+
85
+ function renderView(input: ViewInput): TemplateResult {
86
+ const hasTokens = input.tokens.length > 0;
87
+ // clang-format off
88
+ return html`
89
+ <div class="pvt-view" jslog=${VisualLogging.pane('private-verification-tokens')}>
90
+ <div class="table-container">
91
+ ${hasTokens ? html`
92
+ <devtools-data-grid striped inline>
93
+ <table>
94
+ <tr>
95
+ <th id="issuer" weight="6" sortable>${i18nString(UIStrings.issuer)}</th>
96
+ <th id="is-issuer" type="boolean" align="center" weight="3" sortable>${i18nString(UIStrings.isIssuer)}</th>
97
+ <th id="is-redeemer" type="boolean" align="center" weight="3" sortable>${i18nString(UIStrings.isRedeemer)}</th>
98
+ <th id="id" weight="3" sortable>${i18nString(UIStrings.tokenId)}</th>
99
+ <th id="key-id" weight="2" sortable>${i18nString(UIStrings.keyId)}</th>
100
+ <th id="expiration" weight="5" sortable>${i18nString(UIStrings.expiration)}</th>
101
+ <th id="creation-time" weight="5" sortable>${i18nString(UIStrings.creationTime)}</th>
102
+ <th id="version" weight="2" sortable>${i18nString(UIStrings.version)}</th>
103
+ <th id="token" weight="2">${i18nString(UIStrings.tokenPayload)}</th>
104
+ </tr>
105
+ ${repeat(input.tokens, token => token.id, token => html`
106
+ <tr>
107
+ <td>${token.issuerOrigin}</td>
108
+ <td>${token.isIssuer}</td>
109
+ <td>${token.isRedeemer}</td>
110
+ <td>${token.id}</td>
111
+ <td>${token.keyId}</td>
112
+ <td>${token.expiration}</td>
113
+ <td>${token.creationTime}</td>
114
+ <td>${token.version}</td>
115
+ <td class="monospace" title=${token.token}>${token.token}</td>
116
+ </tr>
117
+ `)}
118
+ </table>
119
+ </devtools-data-grid>
120
+ ` : html`
121
+ ${UI.Widget.widget(UI.EmptyWidget.EmptyWidget, {header: i18nString(UIStrings.noPrivateVerificationTokens)})}
122
+ `}
123
+ </div>
124
+ </div>
125
+ `;
126
+ // clang-format on
127
+ }
22
128
 
23
129
  type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
24
130
 
25
- export const DEFAULT_VIEW: View = (_input, _output, target) => {
131
+ export const DEFAULT_VIEW: View = (input, _output, target) => {
26
132
  // clang-format off
27
133
  render(html`
28
134
  <style>${privateVerificationTokensViewStyles}</style>
29
135
  <style>${UI.inspectorCommonStyles}</style>
30
- <div class="pvt-view" jslog=${VisualLogging.pane('private-verification-tokens')}>
31
- ${UI.Widget.widget(UI.EmptyWidget.EmptyWidget, {header: i18nString(UIStrings.noPrivateVerificationTokens)})}
32
- </div>
136
+ ${renderView(input)}
33
137
  `, target);
34
138
  // clang-format on
35
139
  };
36
140
 
37
- export class PrivateVerificationTokensView extends UI.Widget.VBox {
141
+ export class PrivateVerificationTokensView extends UI.Widget.VBox implements
142
+ SDK.TargetManager.SDKModelObserver<SDK.PrivateVerificationTokensModel.PrivateVerificationTokensModel> {
143
+ #model: SDK.PrivateVerificationTokensModel.PrivateVerificationTokensModel|null = null;
38
144
  #view: View;
39
145
 
40
146
  constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
@@ -44,10 +150,112 @@ export class PrivateVerificationTokensView extends UI.Widget.VBox {
44
150
 
45
151
  override wasShown(): void {
46
152
  super.wasShown();
153
+ const targetManager = SDK.TargetManager.TargetManager.instance();
154
+ targetManager.observeModels(SDK.PrivateVerificationTokensModel.PrivateVerificationTokensModel, this,
155
+ {scoped: true});
156
+ targetManager.addEventListener(SDK.TargetManager.Events.INSPECTED_URL_CHANGED, this.requestUpdate, this);
157
+ targetManager.addModelListener(SDK.SecurityOriginManager.SecurityOriginManager,
158
+ SDK.SecurityOriginManager.Events.MainSecurityOriginChanged, this.requestUpdate, this,
159
+ {scoped: true});
160
+ this.requestUpdate();
161
+ }
162
+
163
+ override willHide(): void {
164
+ super.willHide();
165
+ const targetManager = SDK.TargetManager.TargetManager.instance();
166
+ targetManager.unobserveModels(SDK.PrivateVerificationTokensModel.PrivateVerificationTokensModel, this);
167
+ targetManager.removeEventListener(SDK.TargetManager.Events.INSPECTED_URL_CHANGED, this.requestUpdate, this);
168
+ targetManager.removeModelListener(SDK.SecurityOriginManager.SecurityOriginManager,
169
+ SDK.SecurityOriginManager.Events.MainSecurityOriginChanged, this.requestUpdate,
170
+ this);
171
+ if (this.#model) {
172
+ this.modelRemoved(this.#model);
173
+ }
174
+ }
175
+
176
+ modelAdded(model: SDK.PrivateVerificationTokensModel.PrivateVerificationTokensModel): void {
177
+ if (model.target() !== SDK.TargetManager.TargetManager.instance().primaryPageTarget() || model === this.#model) {
178
+ return;
179
+ }
180
+ if (this.#model) {
181
+ this.modelRemoved(this.#model);
182
+ }
183
+ this.#model = model;
184
+ model.setTracking(true);
185
+ model.addEventListener(SDK.PrivateVerificationTokensModel.Events.TOKENS_UPDATED, this.requestUpdate, this);
47
186
  this.requestUpdate();
48
187
  }
49
188
 
50
- override performUpdate(): void {
51
- this.#view({}, undefined, this.contentElement);
189
+ modelRemoved(model: SDK.PrivateVerificationTokensModel.PrivateVerificationTokensModel): void {
190
+ if (model !== this.#model) {
191
+ return;
192
+ }
193
+ model.setTracking(false);
194
+ model.removeEventListener(SDK.PrivateVerificationTokensModel.Events.TOKENS_UPDATED, this.requestUpdate, this);
195
+ this.#model = null;
196
+ }
197
+
198
+ override async performUpdate(signal?: AbortSignal): Promise<void> {
199
+ const model = this.#model;
200
+ let tokens: TokenRow[] = [];
201
+ if (model) {
202
+ const currentOrigin = getInspectedOrigin(model.target());
203
+ if (currentOrigin) {
204
+ const [rawTokens, configs] = await Promise.all([model.getTokens(), model.getIssuerConfigs()]);
205
+ // The widget may have been hidden, the model swapped, or a newer update
206
+ // requested while the CDP calls were in flight.
207
+ if (signal?.aborted || this.#model !== model) {
208
+ return;
209
+ }
210
+ tokens = toTokenRows(rawTokens, configs, currentOrigin);
211
+ }
212
+ }
213
+
214
+ if (signal?.aborted) {
215
+ return;
216
+ }
217
+ this.#view({tokens}, undefined, this.contentElement);
218
+ }
219
+ }
220
+
221
+ function toTokenRows(rawTokens: Protocol.Storage.PrivateVerificationToken[],
222
+ configs: Protocol.Storage.PrivateVerificationTokensIssuerConfig[],
223
+ currentOrigin: Platform.DevToolsPath.UrlString): TokenRow[] {
224
+ const redeemersByIssuer =
225
+ new Map(configs.map(config => [extractOrigin(config.issuerOrigin), config.redeemerOrigins.map(extractOrigin)]));
226
+ return rawTokens
227
+ .map(token => {
228
+ const issuerOrigin = extractOrigin(token.issuerOrigin);
229
+ return {
230
+ id: token.id,
231
+ issuerOrigin,
232
+ isIssuer: issuerOrigin === currentOrigin,
233
+ isRedeemer: Boolean(redeemersByIssuer.get(issuerOrigin)?.includes(currentOrigin)),
234
+ keyId: token.keyId,
235
+ expiration: formatEpochTime(token.expiration),
236
+ creationTime: formatEpochTime(token.creationTime),
237
+ version: token.version,
238
+ token: token.token,
239
+ };
240
+ })
241
+ .filter(token => token.isIssuer || token.isRedeemer)
242
+ .sort((a, b) => a.issuerOrigin.localeCompare(b.issuerOrigin) ||
243
+ Platform.StringUtilities.naturalOrderComparator(a.id, b.id));
244
+ }
245
+
246
+ function getInspectedOrigin(target: SDK.Target.Target): Platform.DevToolsPath.UrlString {
247
+ const securityOriginManager = target.model(SDK.SecurityOriginManager.SecurityOriginManager);
248
+ return extractOrigin(securityOriginManager?.mainSecurityOrigin() || target.inspectedURL());
249
+ }
250
+
251
+ function extractOrigin(url: string): Platform.DevToolsPath.UrlString {
252
+ return Common.ParsedURL.ParsedURL.extractOrigin(url as Platform.DevToolsPath.UrlString);
253
+ }
254
+
255
+ function formatEpochTime(seconds: number): string {
256
+ if (!Number.isFinite(seconds) || seconds <= 0) {
257
+ return '—';
52
258
  }
259
+ const date = new Date(seconds * 1000);
260
+ return Number.isNaN(date.getTime()) ? '—' : date.toISOString();
53
261
  }
@@ -110,6 +110,7 @@ export type View = (input: ViewInput, output: undefined, target: HTMLElement) =>
110
110
  export const DEFAULT_VIEW: View = (input, _output, target) => {
111
111
  // clang-format off
112
112
  render(html`
113
+ <style>${serviceWorkerCacheViewsStyles}</style>
113
114
  <devtools-toolbar class="data-view-toolbar" jslog=${VisualLogging.toolbar()}>
114
115
  <devtools-button
115
116
  title=${i18nString(UIStrings.refresh)}
@@ -244,7 +245,6 @@ export class ServiceWorkerCacheView extends UI.View.SimpleView {
244
245
  viewId: 'cache',
245
246
  });
246
247
  this.#view = view;
247
- this.registerRequiredCSS(serviceWorkerCacheViewsStyles);
248
248
 
249
249
  this.model = model;
250
250
  this.cache = cache;