chrome-devtools-frontend 1.0.1654411 → 1.0.1656291

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 (196) hide show
  1. package/.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md +116 -0
  2. package/.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md +82 -0
  3. package/.agents/skills/ui-eng-vision-orchestrator/SKILL.md +123 -0
  4. package/.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md +125 -0
  5. package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +75 -0
  6. package/AUTHORS +1 -0
  7. package/config/owner/COMMON_OWNERS +0 -4
  8. package/docs/playbook.md +1 -1
  9. package/front_end/Tests.js +1 -0
  10. package/front_end/core/common/Settings.ts +47 -30
  11. package/front_end/core/sdk/CPUThrottlingManager.ts +10 -159
  12. package/front_end/core/sdk/ConsoleModel.ts +13 -11
  13. package/front_end/core/sdk/DOMDebuggerModel.ts +11 -5
  14. package/front_end/core/sdk/EventBreakpointsModel.ts +9 -5
  15. package/front_end/core/sdk/IsolateManager.ts +6 -6
  16. package/front_end/core/sdk/ResourceTreeModel.ts +5 -3
  17. package/front_end/core/sdk/TargetManager.ts +17 -0
  18. package/front_end/entrypoints/devtools_app/devtools_app.ts +0 -1
  19. package/front_end/entrypoints/main/MainImpl.ts +12 -36
  20. package/front_end/foundation/Universe.ts +98 -3
  21. package/front_end/generated/InspectorBackendCommands.ts +5 -1
  22. package/front_end/generated/SupportedCSSProperties.js +2 -6
  23. package/front_end/generated/protocol-mapping.d.ts +8 -0
  24. package/front_end/generated/protocol-proxy-api.d.ts +15 -0
  25. package/front_end/generated/protocol.ts +36 -1
  26. package/front_end/models/ai_assistance/AiConversation.ts +0 -6
  27. package/front_end/models/ai_assistance/agents/NetworkAgent.snapshot.txt +1 -1
  28. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +2 -156
  29. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +0 -24
  30. package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -358
  31. package/front_end/models/ai_assistance/ai_assistance.ts +0 -6
  32. package/front_end/models/ai_assistance/contexts/RequestContext.snapshot.txt +0 -1
  33. package/front_end/models/ai_assistance/data_formatters/NetworkRequestFormatter.ts +0 -2
  34. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +1 -14
  35. package/front_end/models/autofill_manager/AutofillManager.ts +1 -2
  36. package/front_end/models/javascript_metadata/NativeFunctions.js +1 -1
  37. package/front_end/models/persistence/AutomaticFileSystemManager.ts +14 -13
  38. package/front_end/models/persistence/AutomaticFileSystemWorkspaceBinding.ts +12 -9
  39. package/front_end/models/persistence/IsolatedFileSystemManager.ts +18 -9
  40. package/front_end/models/project_settings/ProjectSettingsModel.ts +12 -11
  41. package/front_end/models/trace/handlers/ScreenshotsHandler.ts +14 -59
  42. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +3 -29
  43. package/front_end/panels/application/DeviceBoundSessionsView.ts +15 -3
  44. package/front_end/panels/application/FrameDetailsView.ts +2 -1
  45. package/front_end/panels/application/ServiceWorkersView.ts +23 -16
  46. package/front_end/panels/common/CPUThrottlingOption.ts +142 -0
  47. package/front_end/panels/common/ThrottlingUtils.ts +9 -4
  48. package/front_end/panels/common/common.ts +1 -1
  49. package/front_end/panels/console/ConsoleViewMessage.ts +45 -0
  50. package/front_end/panels/elements/ElementsPanel.ts +0 -74
  51. package/front_end/panels/elements/ElementsTreeOutline.ts +0 -4
  52. package/front_end/panels/emulation/DeviceModeToolbar.ts +46 -45
  53. package/front_end/panels/mobile_throttling/CalibrationController.ts +6 -5
  54. package/front_end/panels/mobile_throttling/MobileThrottlingSelector.ts +1 -1
  55. package/front_end/panels/mobile_throttling/ThrottlingManager.ts +40 -13
  56. package/front_end/panels/mobile_throttling/ThrottlingPresets.ts +13 -17
  57. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +15 -13
  58. package/front_end/panels/network/NetworkLogView.ts +0 -9
  59. package/front_end/panels/network/NetworkPanel.ts +1 -63
  60. package/front_end/panels/network/RequestInitiatorView.ts +29 -4
  61. package/front_end/panels/network/components/HeaderSectionRow.css +9 -7
  62. package/front_end/panels/network/components/HeaderSectionRow.ts +20 -1
  63. package/front_end/panels/network/components/RequestHeaderSection.css +5 -3
  64. package/front_end/panels/network/components/RequestHeaderSection.ts +1 -2
  65. package/front_end/panels/network/components/RequestHeadersView.css +1 -1
  66. package/front_end/panels/security/SecurityPanel.ts +36 -23
  67. package/front_end/panels/settings/SettingsScreen.ts +18 -103
  68. package/front_end/panels/settings/settings-meta.ts +0 -24
  69. package/front_end/panels/timeline/TimelineController.ts +3 -2
  70. package/front_end/panels/timeline/TimelinePanel.ts +20 -3
  71. package/front_end/panels/timeline/components/CPUThrottlingSelector.ts +15 -14
  72. package/front_end/panels/timeline/timelineFlamechartPopover.css +2 -0
  73. package/front_end/panels/utils/utils.ts +25 -24
  74. package/front_end/third_party/chromium/README.chromium +1 -1
  75. package/front_end/third_party/puppeteer/README.chromium +2 -2
  76. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +34 -55
  77. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +96 -83
  78. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Browser.d.ts +10 -1
  79. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Browser.d.ts.map +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Browser.js.map +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/BrowserContext.d.ts.map +1 -1
  82. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/BrowserContext.js +1 -1
  83. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/BrowserContext.js.map +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/CDPSession.d.ts.map +1 -1
  85. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/CDPSession.js.map +1 -1
  86. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/HTTPResponse.d.ts +3 -2
  87. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/HTTPResponse.d.ts.map +1 -1
  88. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/HTTPResponse.js.map +1 -1
  89. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Realm.d.ts.map +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Realm.js.map +1 -1
  91. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Target.d.ts +1 -1
  92. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Target.js +1 -1
  93. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/locators/locators.d.ts.map +1 -1
  94. package/front_end/third_party/puppeteer/package/lib/puppeteer/api/locators/locators.js.map +1 -1
  95. package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/HTTPResponse.d.ts.map +1 -1
  96. package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/HTTPResponse.js +2 -1
  97. package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/HTTPResponse.js.map +1 -1
  98. package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/core/Realm.d.ts.map +1 -1
  99. package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/core/Realm.js.map +1 -1
  100. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.d.ts +2 -2
  101. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.d.ts.map +1 -1
  102. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.js +5 -2
  103. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.js.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Frame.js +1 -1
  105. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Frame.js.map +1 -1
  106. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/FrameManager.d.ts.map +1 -1
  107. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/FrameManager.js +23 -13
  108. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/FrameManager.js.map +1 -1
  109. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/HTTPResponse.d.ts.map +1 -1
  110. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/HTTPResponse.js +4 -1
  111. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/HTTPResponse.js.map +1 -1
  112. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Input.js +1 -1
  113. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/LifecycleWatcher.d.ts.map +1 -1
  114. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/LifecycleWatcher.js.map +1 -1
  115. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Target.d.ts.map +1 -1
  116. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Target.js.map +1 -1
  117. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/WebMCP.d.ts +3 -41
  118. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/WebMCP.d.ts.map +1 -1
  119. package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/WebMCP.js.map +1 -1
  120. package/front_end/third_party/puppeteer/package/lib/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  121. package/front_end/third_party/puppeteer/package/lib/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  122. package/front_end/third_party/puppeteer/package/lib/puppeteer/node/BrowserLauncher.js +4 -2
  123. package/front_end/third_party/puppeteer/package/lib/puppeteer/node/BrowserLauncher.js.map +1 -1
  124. package/front_end/third_party/puppeteer/package/lib/puppeteer/node/LaunchOptions.d.ts +5 -0
  125. package/front_end/third_party/puppeteer/package/lib/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  126. package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.d.ts +1 -1
  127. package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.js +1 -1
  128. package/front_end/third_party/puppeteer/package/lib/puppeteer/util/httpUtils.d.ts +1 -1
  129. package/front_end/third_party/puppeteer/package/lib/puppeteer/util/httpUtils.d.ts.map +1 -1
  130. package/front_end/third_party/puppeteer/package/lib/puppeteer/util/httpUtils.js +5 -5
  131. package/front_end/third_party/puppeteer/package/lib/puppeteer/util/httpUtils.js.map +1 -1
  132. package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.d.ts +1 -1
  133. package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.js +1 -1
  134. package/front_end/third_party/puppeteer/package/lib/types.d.ts +34 -55
  135. package/front_end/third_party/puppeteer/package/package.json +4 -4
  136. package/front_end/third_party/puppeteer/package/src/api/Browser.ts +13 -1
  137. package/front_end/third_party/puppeteer/package/src/api/BrowserContext.ts +2 -3
  138. package/front_end/third_party/puppeteer/package/src/api/CDPSession.ts +3 -1
  139. package/front_end/third_party/puppeteer/package/src/api/HTTPResponse.ts +3 -2
  140. package/front_end/third_party/puppeteer/package/src/api/Realm.ts +1 -2
  141. package/front_end/third_party/puppeteer/package/src/api/Target.ts +1 -1
  142. package/front_end/third_party/puppeteer/package/src/api/locators/locators.ts +1 -2
  143. package/front_end/third_party/puppeteer/package/src/bidi/HTTPResponse.ts +3 -1
  144. package/front_end/third_party/puppeteer/package/src/bidi/core/Realm.ts +1 -3
  145. package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +13 -3
  146. package/front_end/third_party/puppeteer/package/src/cdp/Frame.ts +1 -1
  147. package/front_end/third_party/puppeteer/package/src/cdp/FrameManager.ts +24 -13
  148. package/front_end/third_party/puppeteer/package/src/cdp/HTTPResponse.ts +4 -1
  149. package/front_end/third_party/puppeteer/package/src/cdp/Input.ts +1 -1
  150. package/front_end/third_party/puppeteer/package/src/cdp/LifecycleWatcher.ts +1 -4
  151. package/front_end/third_party/puppeteer/package/src/cdp/Target.ts +2 -4
  152. package/front_end/third_party/puppeteer/package/src/cdp/WebMCP.ts +7 -76
  153. package/front_end/third_party/puppeteer/package/src/common/ConnectOptions.ts +1 -4
  154. package/front_end/third_party/puppeteer/package/src/node/BrowserLauncher.ts +4 -1
  155. package/front_end/third_party/puppeteer/package/src/node/LaunchOptions.ts +5 -0
  156. package/front_end/third_party/puppeteer/package/src/revisions.ts +1 -1
  157. package/front_end/third_party/puppeteer/package/src/util/httpUtils.ts +5 -5
  158. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  159. package/front_end/third_party/puppeteer/third_party/parsel/README.chromium +1 -1
  160. package/front_end/ui/components/dialogs/Dialog.ts +3 -0
  161. package/front_end/ui/components/markdown_view/MarkdownLinksMap.ts +0 -7
  162. package/front_end/ui/helpers/OpenInNewTab.ts +15 -7
  163. package/front_end/ui/legacy/TabbedPane.ts +1 -108
  164. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +9 -0
  165. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +172 -123
  166. package/front_end/ui/legacy/components/data_grid/DataGridExporter.ts +89 -0
  167. package/front_end/ui/legacy/components/data_grid/dataGrid.css +10 -0
  168. package/front_end/ui/legacy/components/data_grid/data_grid.ts +3 -1
  169. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +89 -40
  170. package/front_end/ui/visual_logging/KnownContextValues.ts +2 -0
  171. package/package.json +1 -1
  172. package/front_end/Images/navigationControls.png +0 -0
  173. package/front_end/Images/navigationControls_2x.png +0 -0
  174. package/front_end/Images/popoverArrows.png +0 -0
  175. package/front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts +0 -746
  176. package/front_end/entrypoints/greendev_floaty/floaty.css +0 -301
  177. package/front_end/entrypoints/greendev_floaty/floaty.html +0 -38
  178. package/front_end/entrypoints/greendev_floaty/greendev_floaty.ts +0 -415
  179. package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +0 -834
  180. package/front_end/models/ai_assistance/agents/GreenDevAgentAntigravityCliSocketClient.ts +0 -53
  181. package/front_end/models/ai_assistance/agents/GreenDevAgentGeminiCliSocketClient.ts +0 -117
  182. package/front_end/models/annotations/AnnotationRepository.ts +0 -238
  183. package/front_end/models/annotations/AnnotationType.ts +0 -10
  184. package/front_end/models/annotations/README.md +0 -7
  185. package/front_end/models/annotations/annotations.ts +0 -6
  186. package/front_end/models/greendev/Prototypes.ts +0 -68
  187. package/front_end/models/greendev/README.md +0 -5
  188. package/front_end/models/greendev/greendev.ts +0 -5
  189. package/front_end/panels/common/Annotation.ts +0 -184
  190. package/front_end/panels/common/AnnotationManager.ts +0 -208
  191. package/front_end/panels/common/annotation.css +0 -40
  192. package/front_end/panels/greendev/GreenDevPanel.css +0 -282
  193. package/front_end/panels/greendev/GreenDevPanel.ts +0 -364
  194. package/front_end/panels/greendev/GreenDevShared.ts +0 -13
  195. package/front_end/panels/greendev/greendev-meta.ts +0 -52
  196. package/front_end/panels/greendev/greendev.ts +0 -9
@@ -220,6 +220,15 @@ export class ServiceWorkersView extends UI.Widget.VBox implements
220
220
 
221
221
  this.sectionToRegistration = new WeakMap();
222
222
 
223
+ this.createOthersOriginView();
224
+ this.setupToolbar();
225
+
226
+ this.eventListeners = new Map();
227
+ SDK.TargetManager.TargetManager.instance().observeModels(SDK.ServiceWorkerManager.ServiceWorkerManager, this);
228
+ this.updateListVisibility();
229
+ }
230
+
231
+ private createOthersOriginView(): void {
223
232
  const othersDiv = this.contentElement.createChild('div', 'service-workers-other-origin');
224
233
  othersDiv.setAttribute('jslog', `${VisualLogging.section('other-origin')}`);
225
234
  // TODO(crbug.com/1156978): Replace UI.ReportView.ReportView with ReportView.ts web component.
@@ -231,7 +240,9 @@ export class ServiceWorkersView extends UI.Widget.VBox implements
231
240
  const seeOthers = Link.create('chrome://serviceworker-internals', i18nString(UIStrings.seeAllRegistrations),
232
241
  undefined, 'view-all', 0, /* allowPrivileged=*/ true);
233
242
  othersSectionRow.appendChild(seeOthers);
243
+ }
234
244
 
245
+ private setupToolbar(): void {
235
246
  this.toolbar.appendToolbarItem(
236
247
  MobileThrottling.ThrottlingManager.throttlingManager().createOfflineToolbarCheckbox());
237
248
  const updateOnReloadSetting =
@@ -246,10 +257,6 @@ export class ServiceWorkersView extends UI.Widget.VBox implements
246
257
  const fallbackToNetwork = new UI.Toolbar.ToolbarSettingCheckbox(
247
258
  bypassServiceWorkerSetting, i18nString(UIStrings.bypassTheServiceWorkerAndLoad));
248
259
  this.toolbar.appendToolbarItem(fallbackToNetwork);
249
-
250
- this.eventListeners = new Map();
251
- SDK.TargetManager.TargetManager.instance().observeModels(SDK.ServiceWorkerManager.ServiceWorkerManager, this);
252
- this.updateListVisibility();
253
260
  }
254
261
 
255
262
  modelAdded(serviceWorkerManager: SDK.ServiceWorkerManager.ServiceWorkerManager): void {
@@ -453,13 +460,13 @@ export class Section {
453
460
  private readonly networkRequests: Buttons.Button.Button;
454
461
  private readonly updateButton: Buttons.Button.Button;
455
462
  private readonly deleteButton: Buttons.Button.Button;
456
- private sourceField: Element;
457
- private readonly statusField: Element;
458
- private readonly clientsField: Element;
463
+ private sourceField: HTMLElement;
464
+ private readonly statusField: HTMLElement;
465
+ private readonly clientsField: HTMLElement;
459
466
  private readonly clientInfoCache: Map<string, Protocol.Target.TargetInfo>;
460
467
  private readonly throttler: Common.Throttler.Throttler;
461
- private updateCycleField?: Element;
462
- private routerField?: Element;
468
+ private updateCycleField?: HTMLElement;
469
+ private routerField?: HTMLElement;
463
470
 
464
471
  constructor(
465
472
  manager: SDK.ServiceWorkerManager.ServiceWorkerManager, section: UI.ReportView.Section,
@@ -542,10 +549,10 @@ export class Section {
542
549
 
543
550
  scheduleUpdate(): void {
544
551
  if (throttleDisabledForDebugging) {
545
- void this.update();
552
+ void this.performUpdate();
546
553
  return;
547
554
  }
548
- void this.throttler.schedule(this.update.bind(this));
555
+ void this.throttler.schedule(this.performUpdate.bind(this));
549
556
  }
550
557
 
551
558
  private addVersion(versionsStack: Element, icon: string, label: string): Element {
@@ -561,7 +568,7 @@ export class Section {
561
568
  this.clientsField.removeChildren();
562
569
  this.section.setFieldVisible(i18nString(UIStrings.clients), Boolean(version.controlledClients.length));
563
570
  for (const client of version.controlledClients) {
564
- const clientLabelText = this.clientsField.createChild('div', 'service-worker-client');
571
+ const clientLabelText = this.clientsField.createChild('div', 'service-worker-client') as HTMLElement;
565
572
  const info = this.clientInfoCache.get(client);
566
573
  if (info) {
567
574
  this.updateClientInfo(clientLabelText, info);
@@ -601,7 +608,7 @@ export class Section {
601
608
  }
602
609
  }
603
610
 
604
- private update(): Promise<void> {
611
+ private performUpdate(): Promise<void> {
605
612
  const fingerprint = this.registration.fingerprint();
606
613
  if (fingerprint === this.fingerprint) {
607
614
  return Promise.resolve();
@@ -740,7 +747,7 @@ export class Section {
740
747
  void this.manager.dispatchPeriodicSyncEvent(this.registration.id, tag);
741
748
  }
742
749
 
743
- private onClientInfo(element: Element, targetInfoResponse: Protocol.Target.GetTargetInfoResponse): void {
750
+ private onClientInfo(element: HTMLElement, targetInfoResponse: Protocol.Target.GetTargetInfoResponse): void {
744
751
  const targetInfo = targetInfoResponse.targetInfo;
745
752
  if (!targetInfo) {
746
753
  return;
@@ -749,7 +756,7 @@ export class Section {
749
756
  this.updateClientInfo(element, targetInfo);
750
757
  }
751
758
 
752
- private updateClientInfo(element: Element, targetInfo: Protocol.Target.TargetInfo): void {
759
+ private updateClientInfo(element: HTMLElement, targetInfo: Protocol.Target.TargetInfo): void {
753
760
  if (targetInfo.type !== 'page' && targetInfo.type === 'iframe') {
754
761
  const clientString = element.createChild('span', 'service-worker-client-string');
755
762
  UI.UIUtils.createTextChild(clientString, i18nString(UIStrings.workerS, {PH1: targetInfo.url}));
@@ -788,7 +795,7 @@ export class Section {
788
795
  void this.manager.stopWorker(versionId);
789
796
  }
790
797
 
791
- private wrapWidget(container: Element): Element {
798
+ private wrapWidget(container: Element): HTMLElement {
792
799
  const shadowRoot = UI.UIUtils.createShadowRootWithCoreStyles(container, {
793
800
  cssFile: [
794
801
  serviceWorkersViewStyles,
@@ -0,0 +1,142 @@
1
+ // Copyright 2026 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Common from '../../core/common/common.js';
6
+ import * as i18n from '../../core/i18n/i18n.js';
7
+
8
+ const UIStrings = {
9
+ /**
10
+ * @description Text label for a menu item indicating that no throttling is applied.
11
+ */
12
+ noThrottling: 'No throttling',
13
+ /**
14
+ * @description Text label for a menu item indicating that a specific slowdown multiplier is applied.
15
+ * @example {2} PH1
16
+ */
17
+ dSlowdown: '{PH1}× slowdown',
18
+ /**
19
+ * @description Text label for a menu item indicating an average mobile device.
20
+ */
21
+ calibratedMidTierMobile: 'Mid-tier mobile',
22
+ /**
23
+ * @description Text label for a menu item indicating a below-average mobile device.
24
+ */
25
+ calibratedLowTierMobile: 'Low-tier mobile',
26
+ /**
27
+ * @description Text label indicating why an option is not available, because the user's device is not fast enough to emulate a device.
28
+ */
29
+ calibrationErrorDeviceTooWeak: 'Device is not powerful enough',
30
+ } as const;
31
+ const str_ = i18n.i18n.registerUIStrings('panels/common/CPUThrottlingOption.ts', UIStrings);
32
+ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
33
+ const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
34
+
35
+ export enum CPUThrottlingRates {
36
+ NO_THROTTLING = 1,
37
+ MID_TIER_MOBILE = 4,
38
+ LOW_TIER_MOBILE = 6,
39
+ EXTRA_SLOW = 20,
40
+
41
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Used by web_tests.
42
+ MidTierMobile = MID_TIER_MOBILE,
43
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- Used by web_tests.
44
+ LowEndMobile = LOW_TIER_MOBILE,
45
+ }
46
+
47
+ export type CalibratedDeviceType = 'low-tier-mobile'|'mid-tier-mobile';
48
+
49
+ export interface CPUThrottlingOption {
50
+ title: () => string;
51
+ rate: () => number;
52
+ calibratedDeviceType?: CalibratedDeviceType;
53
+ jslogContext: string;
54
+ }
55
+
56
+ function makeFixedPresetThrottlingOption(rate: CPUThrottlingRates): CPUThrottlingOption {
57
+ return {
58
+ title: rate === 1 ? i18nLazyString(UIStrings.noThrottling) : i18nLazyString(UIStrings.dSlowdown, {PH1: rate}),
59
+ rate: () => rate,
60
+ jslogContext: rate === 1 ? 'cpu-no-throttling' : `cpu-throttled-${rate}`,
61
+ };
62
+ }
63
+
64
+ export const NoThrottlingOption = makeFixedPresetThrottlingOption(CPUThrottlingRates.NO_THROTTLING);
65
+ export const MidTierThrottlingOption = makeFixedPresetThrottlingOption(CPUThrottlingRates.MID_TIER_MOBILE);
66
+ export const LowTierThrottlingOption = makeFixedPresetThrottlingOption(CPUThrottlingRates.LOW_TIER_MOBILE);
67
+ export const ExtraSlowThrottlingOption = makeFixedPresetThrottlingOption(CPUThrottlingRates.EXTRA_SLOW);
68
+
69
+ function makeCalibratedThrottlingOption(calibratedDeviceType: CalibratedDeviceType): CPUThrottlingOption {
70
+ const getSettingValue = (): number|CalibrationError|null => {
71
+ const setting = Common.Settings.Settings.instance().createSetting<CalibratedCPUThrottling>(
72
+ 'calibrated-cpu-throttling', {}, Common.Settings.SettingStorageType.GLOBAL);
73
+ const value = setting.get();
74
+ if (calibratedDeviceType === 'low-tier-mobile') {
75
+ return value.low ?? null;
76
+ }
77
+ if (calibratedDeviceType === 'mid-tier-mobile') {
78
+ return value.mid ?? null;
79
+ }
80
+ return null;
81
+ };
82
+
83
+ return {
84
+ title(): string {
85
+ const typeString = calibratedDeviceType === 'low-tier-mobile' ? i18nString(UIStrings.calibratedLowTierMobile) :
86
+ i18nString(UIStrings.calibratedMidTierMobile);
87
+
88
+ const value = getSettingValue();
89
+ if (typeof value === 'number') {
90
+ return `${typeString} – ${value.toFixed(1)}×`;
91
+ }
92
+
93
+ return typeString;
94
+ },
95
+ rate(): number {
96
+ const value = getSettingValue();
97
+ if (typeof value === 'number') {
98
+ return value;
99
+ }
100
+ return 0;
101
+ },
102
+ calibratedDeviceType,
103
+ jslogContext: `cpu-throttled-calibrated-${calibratedDeviceType}`,
104
+ };
105
+ }
106
+
107
+ export const CalibratedLowTierMobileThrottlingOption = makeCalibratedThrottlingOption('low-tier-mobile');
108
+ export const CalibratedMidTierMobileThrottlingOption = makeCalibratedThrottlingOption('mid-tier-mobile');
109
+
110
+ export interface CalibratedCPUThrottling {
111
+ /** Either the CPU multiplier, or an error code for why it could not be determined. */
112
+ low?: number|CalibrationError;
113
+ mid?: number|CalibrationError;
114
+ }
115
+
116
+ export enum CalibrationError {
117
+ DEVICE_TOO_WEAK = 'DEVICE_TOO_WEAK',
118
+ }
119
+
120
+ export function calibrationErrorToString(error: CalibrationError): string {
121
+ if (error === CalibrationError.DEVICE_TOO_WEAK) {
122
+ return i18nString(UIStrings.calibrationErrorDeviceTooWeak);
123
+ }
124
+
125
+ return error;
126
+ }
127
+
128
+ export const cpuThrottlingPresets: CPUThrottlingOption[] = [
129
+ NoThrottlingOption,
130
+ MidTierThrottlingOption,
131
+ LowTierThrottlingOption,
132
+ ExtraSlowThrottlingOption,
133
+ CalibratedLowTierMobileThrottlingOption,
134
+ CalibratedMidTierMobileThrottlingOption,
135
+ ];
136
+
137
+ export function determineOptionFromRate(rate: number, currentOption?: CPUThrottlingOption): CPUThrottlingOption {
138
+ if (currentOption && currentOption.rate() === rate) {
139
+ return currentOption;
140
+ }
141
+ return cpuThrottlingPresets.find(o => o.rate() === rate) || NoThrottlingOption;
142
+ }
@@ -5,8 +5,14 @@
5
5
  import * as SDK from '../../core/sdk/sdk.js';
6
6
  import * as CrUXManager from '../../models/crux-manager/crux-manager.js';
7
7
 
8
+ import {
9
+ CalibratedMidTierMobileThrottlingOption,
10
+ type CPUThrottlingOption,
11
+ MidTierThrottlingOption,
12
+ } from './CPUThrottlingOption.js';
13
+
8
14
  export interface ThrottlingRecommendations {
9
- cpuOption: SDK.CPUThrottlingManager.CPUThrottlingOption|null;
15
+ cpuOption: CPUThrottlingOption|null;
10
16
  networkConditions: SDK.NetworkManager.Conditions|null;
11
17
  }
12
18
 
@@ -18,10 +24,9 @@ export function getThrottlingRecommendations(): ThrottlingRecommendations {
18
24
  const cruxManager = CrUXManager.CrUXManager.instance();
19
25
  const roundTripTimeMetricData = cruxManager.getSelectedFieldMetricData('round_trip_time');
20
26
 
21
- let cpuOption: SDK.CPUThrottlingManager.CPUThrottlingOption =
22
- SDK.CPUThrottlingManager.CalibratedMidTierMobileThrottlingOption;
27
+ let cpuOption: CPUThrottlingOption = CalibratedMidTierMobileThrottlingOption;
23
28
  if (cpuOption.rate() === 0) {
24
- cpuOption = SDK.CPUThrottlingManager.MidTierThrottlingOption;
29
+ cpuOption = MidTierThrottlingOption;
25
30
  }
26
31
 
27
32
  const networkConditions = getRecommendedNetworkConditions(roundTripTimeMetricData);
@@ -97,13 +97,13 @@ export class TypeToAllowDialog {
97
97
  export {AiCodeCompletionTeaser} from './AiCodeCompletionTeaser.js';
98
98
  export * as AiCodeGenerationTeaser from './AiCodeGenerationTeaser.js';
99
99
  export {AiCodeGenerationUpgradeDialog} from './AiCodeGenerationUpgradeDialog.js';
100
- export {AnnotationManager} from './AnnotationManager.js';
101
100
  export {FreDialog} from './FreDialog.js';
102
101
  export {GdpSignUpDialog} from './GdpSignUpDialog.js';
103
102
  export {GeminiRebrandPromoDialog} from './GeminiRebrandPromoDialog.js';
104
103
  export {AiCodeCompletionDisclaimer} from './AiCodeCompletionDisclaimer.js';
105
104
  export * as AiCodeCompletionSummaryToolbar from './AiCodeCompletionSummaryToolbar.js';
106
105
  export * from './BadgeNotification.js';
106
+ export * as CPUThrottlingOption from './CPUThrottlingOption.js';
107
107
  export * as ExtensionPanel from './ExtensionPanel.js';
108
108
  export * as ExtensionServer from './ExtensionServer.js';
109
109
  export * as ExtensionView from './ExtensionView.js';
@@ -225,6 +225,18 @@ const UIStrings = {
225
225
  * @description Element title in Object Properties Section
226
226
  */
227
227
  invokePropertyGetter: 'Invoke property getter',
228
+ /**
229
+ * @description Context menu item to copy table data
230
+ */
231
+ copyTableAs: 'Copy table as',
232
+ /**
233
+ * @description Submenu item to copy table as Markdown
234
+ */
235
+ copyAsMarkdown: 'Copy as Markdown',
236
+ /**
237
+ * @description Submenu item to copy table as CSV
238
+ */
239
+ copyAsCsv: 'Copy as CSV',
228
240
  } as const;
229
241
  const str_ = i18n.i18n.registerUIStrings('panels/console/ConsoleViewMessage.ts', UIStrings);
230
242
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -2180,6 +2192,7 @@ export class ConsoleTableMessageView extends ConsoleViewMessage {
2180
2192
  if (this.dataGrid) {
2181
2193
  this.dataGrid.setStriped(true);
2182
2194
  this.dataGrid.setFocusable(false);
2195
+ this.dataGrid.setTableContextMenuCallback(this.populateTableContextMenu.bind(this));
2183
2196
 
2184
2197
  const formattedResult = document.createElement('span');
2185
2198
  formattedResult.classList.add('console-message-text');
@@ -2205,6 +2218,38 @@ export class ConsoleTableMessageView extends ConsoleViewMessage {
2205
2218
  }
2206
2219
  return defaultConsoleRowHeight;
2207
2220
  }
2221
+
2222
+ private populateTableContextMenu(contextMenu: UI.ContextMenu.ContextMenu): void {
2223
+ const copySubMenu = contextMenu.clipboardSection().appendSubMenuItem(i18nString(UIStrings.copyTableAs));
2224
+ copySubMenu.defaultSection().appendItem(i18nString(UIStrings.copyAsMarkdown), this.copyTableAsMarkdown.bind(this),
2225
+ {jslogContext: 'copy-as-markdown'});
2226
+ copySubMenu.defaultSection().appendItem(i18nString(UIStrings.copyAsCsv), this.copyTableAsCSV.bind(this),
2227
+ {jslogContext: 'copy-as-csv'});
2228
+ }
2229
+
2230
+ private copyTableAsMarkdown(): void {
2231
+ if (!this.dataGrid) {
2232
+ return;
2233
+ }
2234
+ const markdown = DataGrid.DataGridExporter.exportToMarkdown(this.dataGrid);
2235
+ UI.UIUtils.copyTextToClipboard(markdown);
2236
+ }
2237
+
2238
+ private copyTableAsCSV(): void {
2239
+ if (!this.dataGrid) {
2240
+ return;
2241
+ }
2242
+ const csv = DataGrid.DataGridExporter.exportToCSV(this.dataGrid);
2243
+ UI.UIUtils.copyTextToClipboard(csv);
2244
+ }
2245
+
2246
+ getDataGridForTest(): DataGrid.SortableDataGrid.SortableDataGrid<unknown>|null {
2247
+ return this.dataGrid;
2248
+ }
2249
+
2250
+ populateTableContextMenuForTest(contextMenu: UI.ContextMenu.ContextMenu): void {
2251
+ this.populateTableContextMenu(contextMenu);
2252
+ }
2208
2253
  }
2209
2254
 
2210
2255
  /**
@@ -40,7 +40,6 @@ import * as Platform from '../../core/platform/platform.js';
40
40
  import * as Root from '../../core/root/root.js';
41
41
  import * as SDK from '../../core/sdk/sdk.js';
42
42
  import type * as Protocol from '../../generated/protocol.js';
43
- import * as Annotations from '../../models/annotations/annotations.js';
44
43
  import * as ComputedStyle from '../../models/computed_style/computed_style.js';
45
44
  import * as PanelCommon from '../../panels/common/common.js';
46
45
  import type * as Adorners from '../../ui/components/adorners/adorners.js';
@@ -307,8 +306,6 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
307
306
  this.#domTreeWidget.onSelectedNodeChanged = this.selectedNodeChanged.bind(this);
308
307
  this.#domTreeWidget.onElementsTreeUpdated = this.updateBreadcrumbIfNeeded.bind(this);
309
308
  this.#domTreeWidget.onDocumentUpdated = this.documentUpdated.bind(this);
310
- this.#domTreeWidget.onElementExpanded = this.handleElementExpanded.bind(this);
311
- this.#domTreeWidget.onElementCollapsed = this.handleElementCollapsed.bind(this);
312
309
  this.#domTreeWidget.setWordWrap(Common.Settings.Settings.instance().moduleSetting('dom-word-wrap').get());
313
310
 
314
311
  SDK.TargetManager.TargetManager.instance().observeModels(SDK.DOMModel.DOMModel, this, {scoped: true});
@@ -319,11 +316,6 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
319
316
  .addChangeListener(this.showUAShadowDOMChanged.bind(this));
320
317
  PanelCommon.ExtensionServer.ExtensionServer.instance().addEventListener(
321
318
  PanelCommon.ExtensionServer.Events.SidebarPaneAdded, this.extensionSidebarPaneAdded, this);
322
-
323
- if (Annotations.AnnotationRepository.annotationsEnabled()) {
324
- PanelCommon.AnnotationManager.instance().initializePlacementForAnnotationType(
325
- Annotations.AnnotationType.ELEMENT_NODE, this.resolveInitialState.bind(this), this.#domTreeWidget.element);
326
- }
327
319
  }
328
320
 
329
321
  // This is a debounced method because the user might be navigated from Styles tab to Computed Style tab and vice versa.
@@ -353,18 +345,6 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
353
345
  }
354
346
  }
355
347
 
356
- private handleElementExpanded(): void {
357
- if (Annotations.AnnotationRepository.annotationsEnabled()) {
358
- void PanelCommon.AnnotationManager.instance().resolveAnnotationsOfType(Annotations.AnnotationType.ELEMENT_NODE);
359
- }
360
- }
361
-
362
- private handleElementCollapsed(): void {
363
- if (Annotations.AnnotationRepository.annotationsEnabled()) {
364
- void PanelCommon.AnnotationManager.instance().resolveAnnotationsOfType(Annotations.AnnotationType.ELEMENT_NODE);
365
- }
366
- }
367
-
368
348
  private showAccessibilityTree(): void {
369
349
  if (this.accessibilityTreeView) {
370
350
  this.splitWidget.setMainWidget(this.accessibilityTreeView);
@@ -511,10 +491,6 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
511
491
  UI.Context.Context.instance().setFlavor(ElementsPanel, this);
512
492
  this.#domTreeWidget.show(this.domTreeContainer);
513
493
  this.evaluateTrackingComputedStyleUpdatesForNode();
514
-
515
- if (Annotations.AnnotationRepository.annotationsEnabled()) {
516
- void PanelCommon.AnnotationManager.instance().resolveAnnotationsOfType(Annotations.AnnotationType.ELEMENT_NODE);
517
- }
518
494
  }
519
495
 
520
496
  override willHide(): void {
@@ -1321,56 +1297,6 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
1321
1297
  this.#domTreeWidget.copyStyles(node);
1322
1298
  }
1323
1299
 
1324
- async resolveInitialState(
1325
- parentElement: Element, reveal: boolean, lookupId: string,
1326
- anchor?: SDK.DOMModel.DOMNode|SDK.NetworkRequest.NetworkRequest): Promise<{x: number, y: number}|null> {
1327
- if (!this.isShowing()) {
1328
- return null;
1329
- }
1330
-
1331
- if (!anchor) {
1332
- const backendNodeId = Number(lookupId) as Protocol.DOM.BackendNodeId;
1333
- if (isNaN(backendNodeId)) {
1334
- return null;
1335
- }
1336
- const rootDOMNode = this.#domTreeWidget.rootDOMNode;
1337
- if (!rootDOMNode) {
1338
- return null;
1339
- }
1340
- const domModel = rootDOMNode.domModel();
1341
- const nodes = await domModel.pushNodesByBackendIdsToFrontend(new Set([backendNodeId]));
1342
- if (!nodes) {
1343
- return null;
1344
- }
1345
- const foundNode = nodes.get(backendNodeId);
1346
- if (!foundNode) {
1347
- return null;
1348
- }
1349
- anchor = foundNode;
1350
- }
1351
-
1352
- const element = this.#domTreeWidget.treeElementForNode(anchor as SDK.DOMModel.DOMNode);
1353
- if (!element) {
1354
- return null;
1355
- }
1356
-
1357
- if (reveal) {
1358
- // The node must have been revealed in order to calculate its position.
1359
- await Common.Revealer.reveal(anchor);
1360
- }
1361
-
1362
- // The tree element element starts at the top-left of the expand/collapse arrow). We
1363
- // want to aim for the tagname instead.
1364
- const offsetToTagName = 22;
1365
- const yPadding = 5;
1366
-
1367
- const targetRect = element.listItemElement.getBoundingClientRect();
1368
- const parentRect = parentElement.getBoundingClientRect();
1369
- const relativeX = targetRect.x - parentRect.x + offsetToTagName;
1370
- const relativeY = targetRect.y - parentRect.y + yPadding;
1371
- return {x: relativeX, y: relativeY};
1372
- }
1373
-
1374
1300
  protected static firstInspectElementCompletedForTest = function(): void {};
1375
1301
  protected static firstInspectElementNodeNameForTest = '';
1376
1302
  }
@@ -235,8 +235,6 @@ export class DOMTreeWidget extends UI.Widget.Widget {
235
235
  Common.EventTarget.EventTargetEvent<{node: SDK.DOMModel.DOMNode | null, focus: boolean}>) => void = () => {};
236
236
  onElementsTreeUpdated: (event: Common.EventTarget.EventTargetEvent<SDK.DOMModel.DOMNode[]>) => void = () => {};
237
237
  onDocumentUpdated: (domModel: SDK.DOMModel.DOMModel) => void = () => {};
238
- onElementExpanded: () => void = () => {};
239
- onElementCollapsed: () => void = () => {};
240
238
 
241
239
  #maxTreeDepth?: number;
242
240
  #enableContextMenu = true;
@@ -455,11 +453,9 @@ export class DOMTreeWidget extends UI.Widget.Widget {
455
453
  },
456
454
  onElementCollapsed: () => {
457
455
  this.#clearHighlightedNode();
458
- this.onElementCollapsed();
459
456
  },
460
457
  onElementExpanded: () => {
461
458
  this.#clearHighlightedNode();
462
- this.onElementExpanded();
463
459
  },
464
460
  },
465
461
  this.#viewOutput, this.contentElement);
@@ -108,16 +108,9 @@ const UIStrings = {
108
108
  moreOptions: 'More options',
109
109
  /**
110
110
  * @description A menu item in the drop-down box that allows the user to select the zoom level.
111
- * Labels the value which corresponds to the 'fit to window' zoom level, represented by the
112
- * placeholder, which is a number. In the Device Mode Toolbar.
113
- * @example {30.0} PH1
114
- */
115
- fitToWindowPercentage: '{PH1}% (fit to window)',
116
- /**
117
- * @description A checkbox setting that appears in the context menu for the zoom level, in the
118
- * Device Mode Toolbar.
111
+ * Labels the option to automatically fit the preview to the available window space. In the Device Mode Toolbar.
119
112
  */
120
- autoadjustZoom: 'Auto-adjust zoom',
113
+ fitToWindow: 'Fit to window',
121
114
  /**
122
115
  * @description A menu item in the drop-down box that allows the user to select the device pixel
123
116
  * ratio. Labels the default value which varies between device types, represented by the
@@ -236,7 +229,6 @@ const str_ = i18n.i18n.registerUIStrings('panels/emulation/DeviceModeToolbar.ts'
236
229
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
237
230
  const {ifDefined, live} = Directives;
238
231
  const {widget} = UI.Widget;
239
- const {bindToSetting} = UI.UIUtils;
240
232
 
241
233
  export interface DeviceModeOption {
242
234
  device: EmulationModel.EmulatedDevices.EmulatedDevice;
@@ -359,17 +351,11 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
359
351
  title=${i18nString(UIStrings.zoom)}
360
352
  aria-label=${i18nString(UIStrings.zoom)}
361
353
  @change=${input.onScaleChange}
362
- .value=${String(input.scaleOptions.find(o => o.selected)?.value || '')}
354
+ .value=${String(input.scaleOptions.find(o => o.selected)?.value ?? '')}
363
355
  jslog=${VisualLogging.dropDown().track({change: true}).context('scale')}>
364
356
  ${input.scaleOptions.map(o => html`<option value=${o.value} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
365
357
  </select>
366
358
 
367
- <devtools-button .data=${{variant: Buttons.Button.Variant.TOOLBAR, iconName: 'center-focus-weak',
368
- toggledIconName: 'center-focus-weak', toggleType: Buttons.Button.ToggleType.PRIMARY} as Buttons.Button.ButtonData}
369
- class="toolbar-button" title=${i18nString(UIStrings.autoadjustZoom)}
370
- ${bindToSetting(input.autoAdjustScaleSetting)}>
371
- </devtools-button>
372
-
373
359
  <div class="device-mode-empty-toolbar-element"></div>
374
360
 
375
361
  ${input.showDeviceScaleFactorSetting.get() ? html`
@@ -381,7 +367,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
381
367
  title=${i18nString(UIStrings.devicePixelRatio)}
382
368
  aria-label=${i18nString(UIStrings.devicePixelRatio)}
383
369
  @change=${input.onDeviceScaleChange}
384
- .value=${String(input.dprOptions.find(o => o.selected)?.value || '')}
370
+ .value=${String(input.dprOptions.find(o => o.selected)?.value ?? '')}
385
371
  jslog=${VisualLogging.dropDown().track({change: true}).context('device-pixel-ratio')}
386
372
  ?disabled=${!input.isResponsive}>
387
373
  ${input.dprOptions.map(o => html`<option value=${o.value} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
@@ -488,6 +474,7 @@ export class DeviceModeToolbar extends UI.Widget.Widget {
488
474
 
489
475
  this.autoAdjustScaleSetting =
490
476
  Common.Settings.Settings.instance().createSetting('emulation.auto-adjust-scale', true);
477
+ this.autoAdjustScaleSetting.addChangeListener(this.requestUpdate, this);
491
478
 
492
479
  this.lastMode = new Map();
493
480
 
@@ -665,39 +652,53 @@ export class DeviceModeToolbar extends UI.Widget.Widget {
665
652
 
666
653
  private getScaleOptions(): Array<{title: string, value: number, selected: boolean, jslogContext: string}> {
667
654
  const values = [0.5, 0.75, 1, 1.25, 1.5, 2];
668
- let fitValue: number|null = null;
669
- if (this.model.type() === EmulationModel.DeviceModeModel.Type.Device) {
670
- fitValue = this.model.fitScale();
671
- const fitValuePct = (fitValue * 100).toFixed(0);
672
- let found = false;
673
- for (let i = 0; i < values.length; ++i) {
674
- if ((values[i] * 100).toFixed(0) === fitValuePct) {
675
- found = true;
676
- values[i] = fitValue;
677
- break;
678
- }
679
- }
680
- if (!found) {
681
- values.push(fitValue);
682
- values.sort((a, b) => a - b);
683
- }
655
+ const isAutoAdjusting = this.autoAdjustScaleSetting.get();
656
+ const currentScale = this.model.scaleSetting().get();
657
+
658
+ if (!isAutoAdjusting && !values.includes(currentScale)) {
659
+ values.push(currentScale);
660
+ values.sort((a, b) => a - b);
684
661
  }
685
662
 
686
- const currentScale = this.model.scaleSetting().get();
687
- return values.map(value => {
688
- let title = (value * 100).toFixed(0) + '%';
689
- let jslogContext = title;
690
- if (value === fitValue) {
691
- title = i18nString(UIStrings.fitToWindowPercentage, {PH1: (value * 100).toFixed(0)});
692
- jslogContext = 'fit-to-window';
693
- }
694
- return {title, value, selected: currentScale === value, jslogContext};
695
- });
663
+ const options: Array<{title: string, value: number, selected: boolean, jslogContext: string}> = [
664
+ {
665
+ title: i18nString(UIStrings.fitToWindow),
666
+ value: 0,
667
+ selected: isAutoAdjusting,
668
+ jslogContext: 'fit-to-window',
669
+ },
670
+ ];
671
+
672
+ for (const value of values) {
673
+ const title = (value * 100).toFixed(0) + '%';
674
+ options.push({
675
+ title,
676
+ value,
677
+ selected: !isAutoAdjusting && currentScale === value,
678
+ jslogContext: title,
679
+ });
680
+ }
681
+ return options;
696
682
  }
697
683
 
698
684
  private onScaleChange(event: Event): void {
699
685
  const value = Number((event.target as HTMLSelectElement).value);
700
- this.model.scaleSetting().set(value);
686
+ if (value === 0) {
687
+ this.autoAdjustScaleSetting.set(true);
688
+ if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
689
+ const appliedSize = this.model.appliedDeviceSize();
690
+ this.model.setSizeAndScaleToFit(appliedSize.width, appliedSize.height);
691
+ } else {
692
+ const device = this.model.device();
693
+ const mode = this.model.mode();
694
+ if (device && mode) {
695
+ this.model.emulate(EmulationModel.DeviceModeModel.Type.Device, device, mode, undefined);
696
+ }
697
+ }
698
+ } else {
699
+ this.autoAdjustScaleSetting.set(false);
700
+ this.model.scaleSetting().set(value);
701
+ }
701
702
  }
702
703
 
703
704
  private getDeviceScaleFactorOptions():