chrome-devtools-frontend 1.0.1656291 → 1.0.1657110

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 (63) hide show
  1. package/AUTHORS +2 -0
  2. package/docs/get_the_code.md +6 -6
  3. package/front_end/Tests.js +1 -1
  4. package/front_end/core/common/Settings.ts +0 -8
  5. package/front_end/core/host/Platform.ts +4 -0
  6. package/front_end/core/sdk/CSSMetadata.ts +11 -0
  7. package/front_end/core/sdk/CSSModel.ts +3 -0
  8. package/front_end/core/sdk/DOMModel.ts +44 -13
  9. package/front_end/core/sdk/DebuggerModel.ts +5 -4
  10. package/front_end/core/sdk/EmulationModel.ts +6 -4
  11. package/front_end/core/sdk/NetworkManager.ts +21 -14
  12. package/front_end/core/sdk/RuntimeModel.ts +1 -1
  13. package/front_end/core/sdk/SourceMapCache.ts +2 -4
  14. package/front_end/core/sdk/SourceMapManager.ts +8 -7
  15. package/front_end/core/sdk/TargetManager.ts +10 -0
  16. package/front_end/design_system_tokens.css +6 -0
  17. package/front_end/entrypoints/inspector_main/InspectorMain.ts +1 -11
  18. package/front_end/entrypoints/inspector_main/inspector_main-meta.ts +1 -1
  19. package/front_end/entrypoints/main/GlobalAiButton.ts +29 -35
  20. package/front_end/entrypoints/main/MainImpl.ts +1 -1
  21. package/front_end/entrypoints/main/SimpleApp.ts +0 -13
  22. package/front_end/entrypoints/main/main-meta.ts +2 -2
  23. package/front_end/entrypoints/node_app/app/NodeConnectionsPanel.ts +2 -3
  24. package/front_end/foundation/Universe.ts +44 -0
  25. package/front_end/generated/InspectorBackendCommands.ts +2 -2
  26. package/front_end/generated/protocol.ts +5 -5
  27. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +2 -1
  28. package/front_end/models/crux-manager/CrUXManager.ts +16 -11
  29. package/front_end/models/emulation/DeviceModeModel.ts +43 -24
  30. package/front_end/models/live-metrics/LiveMetrics.ts +47 -23
  31. package/front_end/models/project_settings/ProjectSettingsModel.ts +2 -37
  32. package/front_end/models/workspace/FileManager.ts +9 -6
  33. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +2 -1
  34. package/front_end/panels/application/ServiceWorkersView.ts +177 -163
  35. package/front_end/panels/application/components/StorageMetadataView.ts +7 -2
  36. package/front_end/panels/application/serviceWorkersView.css +8 -0
  37. package/front_end/panels/common/BadgeNotification.ts +1 -1
  38. package/front_end/panels/console/ConsoleInsightTeaser.ts +2 -1
  39. package/front_end/panels/elements/ElementsPanel.ts +35 -28
  40. package/front_end/panels/elements/ElementsTreeElement.ts +208 -143
  41. package/front_end/panels/elements/ElementsTreeOutline.ts +3 -2
  42. package/front_end/panels/elements/components/AdornerManager.ts +1 -0
  43. package/front_end/panels/elements/elements-meta.ts +3 -2
  44. package/front_end/panels/emulation/DeviceModeToolbar.ts +19 -19
  45. package/front_end/panels/explain/components/ConsoleInsight.ts +2 -1
  46. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +13 -12
  47. package/front_end/panels/mobile_throttling/ThrottlingManager.ts +8 -7
  48. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +6 -7
  49. package/front_end/panels/mobile_throttling/mobile_throttling-meta.ts +3 -2
  50. package/front_end/panels/settings/components/SyncSection.ts +2 -1
  51. package/front_end/panels/timeline/AppenderUtils.ts +12 -4
  52. package/front_end/panels/timeline/ThreadAppender.ts +3 -3
  53. package/front_end/panels/timeline/TimelinePanel.ts +5 -5
  54. package/front_end/panels/timeline/timelineFlameChartView.css +2 -1
  55. package/front_end/third_party/chromium/README.chromium +1 -1
  56. package/front_end/third_party/chromium/ahem/ahem.js +792 -0
  57. package/front_end/tsconfig.json +7 -1
  58. package/front_end/ui/legacy/ActionRegistration.ts +1 -1
  59. package/front_end/ui/legacy/InspectorView.ts +1 -1
  60. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +109 -23
  61. package/front_end/ui/legacy/theme_support/ThemeSupport.ts +2 -2
  62. package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
  63. package/package.json +1 -1
@@ -38,13 +38,12 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
38
38
  const DELAY_BEFORE_PROMOTION_COLLAPSE_IN_MS = 5000;
39
39
  const PROMOTION_END_DATE = new Date('2026-09-30');
40
40
 
41
- function getClickCountSetting(): Common.Settings.Setting<number> {
42
- return Common.Settings.Settings.instance().createSetting<number>(
43
- 'global-ai-button-click-count', 0, Common.Settings.SettingStorageType.SYNCED);
41
+ function getClickCountSetting(settings: Common.Settings.Settings): Common.Settings.Setting<number> {
42
+ return settings.createSetting<number>('global-ai-button-click-count', 0, Common.Settings.SettingStorageType.SYNCED);
44
43
  }
45
44
 
46
- function incrementClickCountSetting(): void {
47
- const setting = getClickCountSetting();
45
+ function incrementClickCountSetting(settings: Common.Settings.Settings): void {
46
+ const setting = getClickCountSetting(settings);
48
47
  setting.set(setting.get() + 1);
49
48
  }
50
49
 
@@ -89,10 +88,19 @@ export class GlobalAiButton extends UI.Widget.Widget {
89
88
  #buttonState: GlobalAiButtonState = GlobalAiButtonState.DEFAULT;
90
89
  #mouseOnMainToolbar = false;
91
90
  #returnToDefaultStateTimeout?: number;
92
-
93
- constructor(element?: HTMLElement, view?: View) {
91
+ readonly #settings: Common.Settings.Settings;
92
+ readonly #inspectorView: UI.InspectorView.InspectorView;
93
+ readonly #viewManager: UI.ViewManager.ViewManager;
94
+
95
+ constructor(element?: HTMLElement, view?: View,
96
+ settings: Common.Settings.Settings = Common.Settings.Settings.instance(),
97
+ inspectorView: UI.InspectorView.InspectorView = UI.InspectorView.InspectorView.instance(),
98
+ viewManager: UI.ViewManager.ViewManager = UI.ViewManager.ViewManager.instance()) {
94
99
  super(element);
95
100
  this.#view = view ?? DEFAULT_VIEW;
101
+ this.#settings = settings;
102
+ this.#inspectorView = inspectorView;
103
+ this.#viewManager = viewManager;
96
104
  this.requestUpdate();
97
105
 
98
106
  if (this.#shouldTriggerPromotion()) {
@@ -118,17 +126,13 @@ export class GlobalAiButton extends UI.Widget.Widget {
118
126
  };
119
127
 
120
128
  #addHoverEventListeners(): void {
121
- UI.InspectorView.InspectorView.instance().tabbedPane.headerElement().addEventListener(
122
- 'mouseenter', this.#handleMainToolbarMouseEnter);
123
- UI.InspectorView.InspectorView.instance().tabbedPane.headerElement().addEventListener(
124
- 'mouseleave', this.#handleMainToolbarMouseLeave);
129
+ this.#inspectorView.tabbedPane.headerElement().addEventListener('mouseenter', this.#handleMainToolbarMouseEnter);
130
+ this.#inspectorView.tabbedPane.headerElement().addEventListener('mouseleave', this.#handleMainToolbarMouseLeave);
125
131
  }
126
132
 
127
133
  #removeHoverEventListeners(): void {
128
- UI.InspectorView.InspectorView.instance().tabbedPane.headerElement().removeEventListener(
129
- 'mouseenter', this.#handleMainToolbarMouseEnter);
130
- UI.InspectorView.InspectorView.instance().tabbedPane.headerElement().removeEventListener(
131
- 'mouseleave', this.#handleMainToolbarMouseLeave);
134
+ this.#inspectorView.tabbedPane.headerElement().removeEventListener('mouseenter', this.#handleMainToolbarMouseEnter);
135
+ this.#inspectorView.tabbedPane.headerElement().removeEventListener('mouseleave', this.#handleMainToolbarMouseLeave);
132
136
  }
133
137
 
134
138
  // We only want to enable promotion when:
@@ -138,7 +142,7 @@ export class GlobalAiButton extends UI.Widget.Widget {
138
142
  #shouldTriggerPromotion(): boolean {
139
143
  const isFlagEnabled = Boolean(Root.Runtime.hostConfig.devToolsGlobalAiButton?.promotionEnabled);
140
144
  const isBeforeEndDate = (new Date()) < PROMOTION_END_DATE;
141
- return isFlagEnabled && isBeforeEndDate && getClickCountSetting().get() < 2;
145
+ return isFlagEnabled && isBeforeEndDate && getClickCountSetting(this.#settings).get() < 2;
142
146
  }
143
147
 
144
148
  #triggerPromotion(): void {
@@ -173,23 +177,21 @@ export class GlobalAiButton extends UI.Widget.Widget {
173
177
  }
174
178
 
175
179
  #onClick(): void {
176
- UI.ViewManager.ViewManager.instance().showViewInLocation('freestyler', 'drawer-view');
177
- incrementClickCountSetting();
180
+ this.#viewManager.showViewInLocation('freestyler', 'drawer-view');
181
+ incrementClickCountSetting(this.#settings);
178
182
 
179
- const hasExplicitUserPreference =
180
- UI.InspectorView.InspectorView.instance().isUserExplicitlyUpdatedDrawerOrientation();
183
+ const hasExplicitUserPreference = this.#inspectorView.isUserExplicitlyUpdatedDrawerOrientation();
181
184
  const isVerticalDrawerFeatureEnabled =
182
185
  Boolean(Root.Runtime.hostConfig.devToolsFlexibleLayout?.verticalDrawerEnabled);
183
186
  if (isVerticalDrawerFeatureEnabled && !hasExplicitUserPreference) {
184
187
  // This mimics what we're doing while showing the drawer via `ESC`.
185
188
  // There is a bug where opening the sidebar directly for the first time,
186
189
  // and triggering a drawer rotation without calling `showDrawer({focus: true})` makes the drawer disappear.
187
- UI.InspectorView.InspectorView.instance().showDrawer({
190
+ this.#inspectorView.showDrawer({
188
191
  focus: true,
189
192
  hasTargetDrawer: false,
190
193
  });
191
- UI.InspectorView.InspectorView.instance().toggleDrawerOrientation(
192
- {force: UI.InspectorView.DrawerOrientation.VERTICAL});
194
+ this.#inspectorView.toggleDrawerOrientation({force: UI.InspectorView.DrawerOrientation.VERTICAL});
193
195
  }
194
196
  }
195
197
 
@@ -203,14 +205,15 @@ export class GlobalAiButton extends UI.Widget.Widget {
203
205
  }
204
206
  }
205
207
 
206
- let globalAiButtonToolbarProviderInstance: GlobalAiButtonToolbarProvider;
207
208
  export class GlobalAiButtonToolbarProvider implements UI.Toolbar.Provider {
208
209
  #toolbarItem: UI.Toolbar.ToolbarItemWithCompactLayout;
209
210
  #widgetElement: UI.Widget.WidgetElement<GlobalAiButton>;
210
211
 
211
- private constructor() {
212
+ constructor(settings: Common.Settings.Settings = Common.Settings.Settings.instance(),
213
+ inspectorView: UI.InspectorView.InspectorView = UI.InspectorView.InspectorView.instance(),
214
+ viewManager: UI.ViewManager.ViewManager = UI.ViewManager.ViewManager.instance()) {
212
215
  this.#widgetElement = document.createElement('devtools-widget') as UI.Widget.WidgetElement<GlobalAiButton>;
213
- new GlobalAiButton(this.#widgetElement);
216
+ new GlobalAiButton(this.#widgetElement, undefined, settings, inspectorView, viewManager);
214
217
 
215
218
  this.#toolbarItem = new UI.Toolbar.ToolbarItemWithCompactLayout(this.#widgetElement);
216
219
  this.#toolbarItem.setVisible(false);
@@ -219,13 +222,4 @@ export class GlobalAiButtonToolbarProvider implements UI.Toolbar.Provider {
219
222
  item(): UI.Toolbar.ToolbarItem|null {
220
223
  return this.#toolbarItem;
221
224
  }
222
-
223
- static instance(opts: {forceNew: boolean|null} = {forceNew: null}): GlobalAiButtonToolbarProvider {
224
- const {forceNew} = opts;
225
- if (!globalAiButtonToolbarProviderInstance || forceNew) {
226
- globalAiButtonToolbarProviderInstance = new GlobalAiButtonToolbarProvider();
227
- }
228
-
229
- return globalAiButtonToolbarProviderInstance;
230
- }
231
225
  }
@@ -477,7 +477,7 @@ export class MainImpl {
477
477
 
478
478
  new ExecutionContextSelector(targetManager, UI.Context.Context.instance());
479
479
 
480
- LiveMetrics.LiveMetrics.instance();
480
+ void LiveMetrics.LiveMetrics.instance().enable();
481
481
  CrUXManager.CrUXManager.instance();
482
482
 
483
483
  const builtInAi = AiAssistanceModel.BuiltInAi.BuiltInAi.instance();
@@ -13,20 +13,7 @@ export class SimpleApp implements UI.App.App {
13
13
  }
14
14
  }
15
15
 
16
- let simpleAppProviderInstance: SimpleAppProvider;
17
-
18
16
  export class SimpleAppProvider implements UI.AppProvider.AppProvider {
19
- static instance(opts: {
20
- forceNew: boolean|null,
21
- } = {forceNew: null}): SimpleAppProvider {
22
- const {forceNew} = opts;
23
- if (!simpleAppProviderInstance || forceNew) {
24
- simpleAppProviderInstance = new SimpleAppProvider();
25
- }
26
-
27
- return simpleAppProviderInstance;
28
- }
29
-
30
17
  createApp(): UI.App.App {
31
18
  return new SimpleApp();
32
19
  }
@@ -913,7 +913,7 @@ UI.Toolbar.registerToolbarItem({
913
913
  },
914
914
  async loadItem() {
915
915
  const Main = await loadMainModule();
916
- return Main.GlobalAiButton.GlobalAiButtonToolbarProvider.instance();
916
+ return new Main.GlobalAiButton.GlobalAiButtonToolbarProvider();
917
917
  },
918
918
  order: 98,
919
919
  location: UI.Toolbar.ToolbarItemLocation.MAIN_TOOLBAR_RIGHT,
@@ -949,7 +949,7 @@ UI.Toolbar.registerToolbarItem({
949
949
  UI.AppProvider.registerAppProvider({
950
950
  async loadAppProvider() {
951
951
  const Main = await loadMainModule();
952
- return Main.SimpleApp.SimpleAppProvider.instance();
952
+ return new Main.SimpleApp.SimpleAppProvider();
953
953
  },
954
954
  order: 10,
955
955
  });
@@ -95,9 +95,8 @@ export class NodeConnectionsView extends UI.Widget.VBox implements UI.ListWidget
95
95
  this.element.classList.add('network-discovery-view');
96
96
 
97
97
  const networkDiscoveryFooter = this.element.createChild('div', 'network-discovery-footer');
98
- const documentationLink = Link.create(
99
- 'https://nodejs.org/en/docs/inspector/', i18nString(UIStrings.nodejsDebuggingGuide), undefined,
100
- 'node-js-debugging');
98
+ const documentationLink = Link.create('https://nodejs.org/learn/getting-started/debugging',
99
+ i18nString(UIStrings.nodejsDebuggingGuide), undefined, 'node-js-debugging');
101
100
  networkDiscoveryFooter.appendChild(
102
101
  uiI18n.getFormatLocalizedString(str_, UIStrings.specifyNetworkEndpointAnd, {PH1: documentationLink}));
103
102
 
@@ -9,6 +9,8 @@ import * as SDK from '../core/sdk/sdk.js';
9
9
  import * as AutofillManager from '../models/autofill_manager/autofill_manager.js';
10
10
  import * as Bindings from '../models/bindings/bindings.js';
11
11
  import * as Breakpoints from '../models/breakpoints/breakpoints.js';
12
+ import * as CrUXManager from '../models/crux-manager/crux-manager.js';
13
+ import * as Emulation from '../models/emulation/emulation.js';
12
14
  import * as JavaScriptMetadata from '../models/javascript_metadata/javascript_metadata.js';
13
15
  import * as Logs from '../models/logs/logs.js';
14
16
  import * as Persistence from '../models/persistence/persistence.js';
@@ -59,6 +61,10 @@ export class Universe {
59
61
  const multitargetNetworkManager = new SDK.NetworkManager.MultitargetNetworkManager(targetManager);
60
62
  context.set(SDK.NetworkManager.MultitargetNetworkManager, multitargetNetworkManager);
61
63
 
64
+ const deviceModeModel =
65
+ new Emulation.DeviceModeModel.DeviceModeModel(targetManager, settings, multitargetNetworkManager);
66
+ context.set(Emulation.DeviceModeModel.DeviceModeModel, deviceModeModel);
67
+
62
68
  const pageResourceLoader =
63
69
  new SDK.PageResourceLoader.PageResourceLoader(targetManager, settings, multitargetNetworkManager, null);
64
70
  context.set(SDK.PageResourceLoader.PageResourceLoader, pageResourceLoader);
@@ -80,6 +86,17 @@ export class Universe {
80
86
  const domDebuggerManager = new SDK.DOMDebuggerModel.DOMDebuggerManager(targetManager);
81
87
  context.set(SDK.DOMDebuggerModel.DOMDebuggerManager, domDebuggerManager);
82
88
 
89
+ const cruxManager = new CrUXManager.CrUXManager(targetManager, settings);
90
+ context.set(CrUXManager.CrUXManager, cruxManager);
91
+
92
+ const isolateManager = new SDK.IsolateManager.IsolateManager(targetManager);
93
+ context.set(SDK.IsolateManager.IsolateManager, isolateManager);
94
+ const eventBreakpointsManager = new SDK.EventBreakpointsModel.EventBreakpointsManager(targetManager);
95
+ context.set(SDK.EventBreakpointsModel.EventBreakpointsManager, eventBreakpointsManager);
96
+
97
+ const domModelUndoStack = new SDK.DOMModel.DOMModelUndoStack();
98
+ context.set(SDK.DOMModel.DOMModelUndoStack, domModelUndoStack);
99
+
83
100
  const workspace = new Workspace.Workspace.WorkspaceImpl();
84
101
  context.set(Workspace.Workspace.WorkspaceImpl, workspace);
85
102
 
@@ -151,15 +168,34 @@ export class Universe {
151
168
  get cpuThrottlingManager(): SDK.CPUThrottlingManager.CPUThrottlingManager {
152
169
  return this.context.get(SDK.CPUThrottlingManager.CPUThrottlingManager);
153
170
  }
171
+ get cruxManager(): CrUXManager.CrUXManager {
172
+ return this.context.get(CrUXManager.CrUXManager);
173
+ }
174
+
175
+ get deviceModeModel(): Emulation.DeviceModeModel.DeviceModeModel {
176
+ return this.context.get(Emulation.DeviceModeModel.DeviceModeModel);
177
+ }
154
178
 
155
179
  get domDebuggerManager(): SDK.DOMDebuggerModel.DOMDebuggerManager {
156
180
  return this.context.get(SDK.DOMDebuggerModel.DOMDebuggerManager);
157
181
  }
158
182
 
183
+ get domModelUndoStack(): SDK.DOMModel.DOMModelUndoStack {
184
+ return this.context.get(SDK.DOMModel.DOMModelUndoStack);
185
+ }
186
+
187
+ get eventBreakpointsManager(): SDK.EventBreakpointsModel.EventBreakpointsManager {
188
+ return this.context.get(SDK.EventBreakpointsModel.EventBreakpointsManager);
189
+ }
190
+
159
191
  get isolatedFileSystemManager(): Persistence.IsolatedFileSystemManager.IsolatedFileSystemManager {
160
192
  return this.context.get(Persistence.IsolatedFileSystemManager.IsolatedFileSystemManager);
161
193
  }
162
194
 
195
+ get isolateManager(): SDK.IsolateManager.IsolateManager {
196
+ return this.context.get(SDK.IsolateManager.IsolateManager);
197
+ }
198
+
163
199
  get networkPersistenceManager(): Persistence.NetworkPersistenceManager.NetworkPersistenceManager {
164
200
  return this.context.get(Persistence.NetworkPersistenceManager.NetworkPersistenceManager);
165
201
  }
@@ -179,4 +215,12 @@ export class Universe {
179
215
  get settings(): Common.Settings.Settings {
180
216
  return this.context.get(Common.Settings.Settings);
181
217
  }
218
+
219
+ get targetManager(): SDK.TargetManager.TargetManager {
220
+ return this.context.get(SDK.TargetManager.TargetManager);
221
+ }
222
+
223
+ get workspace(): Workspace.Workspace.WorkspaceImpl {
224
+ return this.context.get(Workspace.Workspace.WorkspaceImpl);
225
+ }
182
226
  }
@@ -510,8 +510,8 @@ inspectorBackend.registerCommand("DeviceOrientation.clearDeviceOrientationOverri
510
510
  inspectorBackend.registerCommand("DeviceOrientation.setDeviceOrientationOverride", [{"name": "alpha", "type": "number", "optional": false, "description": "Mock alpha", "typeRef": null}, {"name": "beta", "type": "number", "optional": false, "description": "Mock beta", "typeRef": null}, {"name": "gamma", "type": "number", "optional": false, "description": "Mock gamma", "typeRef": null}], [], "Overrides the Device Orientation.");
511
511
 
512
512
  // DigitalCredentials.
513
- inspectorBackend.registerEnum("DigitalCredentials.VirtualWalletBehavior", {Respond: "respond", Decline: "decline", Wait: "wait", Clear: "clear"});
514
- inspectorBackend.registerCommand("DigitalCredentials.setVirtualWalletBehavior", [{"name": "behavior", "type": "string", "optional": false, "description": "The behavior of the virtual wallet.", "typeRef": "DigitalCredentials.VirtualWalletBehavior"}, {"name": "protocol", "type": "string", "optional": true, "description": "The protocol identifier (e.g. \\\"openid4vp\\\"). Required when |behavior| is \\\"respond\\\", forbidden otherwise.", "typeRef": null}, {"name": "response", "type": "object", "optional": true, "description": "The response data object returned by the wallet. Required when |behavior| is \\\"respond\\\", forbidden otherwise.", "typeRef": null}], [], "Sets the behavior of the virtual wallet for digital credential requests issued from this frame.");
513
+ inspectorBackend.registerEnum("DigitalCredentials.VirtualWalletAction", {Respond: "respond", Decline: "decline", Wait: "wait", Clear: "clear"});
514
+ inspectorBackend.registerCommand("DigitalCredentials.setVirtualWalletBehavior", [{"name": "action", "type": "string", "optional": false, "description": "The action of the virtual wallet.", "typeRef": "DigitalCredentials.VirtualWalletAction"}, {"name": "protocol", "type": "string", "optional": true, "description": "The protocol identifier (e.g. \\\"openid4vp\\\"). Required when |action| is \\\"respond\\\", forbidden otherwise.", "typeRef": null}, {"name": "response", "type": "object", "optional": true, "description": "The response data object returned by the wallet. Required when |action| is \\\"respond\\\", forbidden otherwise.", "typeRef": null}], [], "Sets the behavior of the virtual wallet for digital credential requests issued from this frame.");
515
515
 
516
516
  // Emulation.
517
517
  inspectorBackend.registerEnum("Emulation.ScreenOrientationType", {PortraitPrimary: "portraitPrimary", PortraitSecondary: "portraitSecondary", LandscapePrimary: "landscapePrimary", LandscapeSecondary: "landscapeSecondary"});
@@ -7018,7 +7018,7 @@ export namespace DigitalCredentials {
7018
7018
  /**
7019
7019
  * The type of virtual wallet action.
7020
7020
  */
7021
- export const enum VirtualWalletBehavior {
7021
+ export const enum VirtualWalletAction {
7022
7022
  Respond = 'respond',
7023
7023
  Decline = 'decline',
7024
7024
  Wait = 'wait',
@@ -7027,17 +7027,17 @@ export namespace DigitalCredentials {
7027
7027
 
7028
7028
  export interface SetVirtualWalletBehaviorRequest {
7029
7029
  /**
7030
- * The behavior of the virtual wallet.
7030
+ * The action of the virtual wallet.
7031
7031
  */
7032
- behavior: VirtualWalletBehavior;
7032
+ action: VirtualWalletAction;
7033
7033
  /**
7034
- * The protocol identifier (e.g. "openid4vp"). Required when |behavior| is
7034
+ * The protocol identifier (e.g. "openid4vp"). Required when |action| is
7035
7035
  * "respond", forbidden otherwise.
7036
7036
  */
7037
7037
  protocol?: string;
7038
7038
  /**
7039
7039
  * The response data object returned by the wallet.
7040
- * Required when |behavior| is "respond", forbidden otherwise.
7040
+ * Required when |action| is "respond", forbidden otherwise.
7041
7041
  */
7042
7042
  response?: any;
7043
7043
  }
@@ -489,7 +489,8 @@ export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObser
489
489
  }
490
490
  const functionLocation = frame.functionLocation();
491
491
  if (!autoSteppingContext || debuggerPausedDetails.reason !== Protocol.Debugger.PausedEventReason.Step ||
492
- !functionLocation || !frame.script.isWasm() || !Common.Settings.moduleSetting('wasm-auto-stepping').get() ||
492
+ !functionLocation || !frame.script.isWasm() ||
493
+ !Common.Settings.Settings.instance().moduleSetting('wasm-auto-stepping').get() ||
493
494
  !this.pluginManager.hasPluginForScript(frame.script)) {
494
495
  return true;
495
496
  }
@@ -102,8 +102,6 @@ export interface ConfigSetting {
102
102
  originMappings?: OriginMapping[];
103
103
  }
104
104
 
105
- let cruxManagerInstance: CrUXManager;
106
-
107
105
  /** TODO: Potentially support `TABLET`. Tablet field data will always be `null` until then. **/
108
106
  export const DEVICE_SCOPE_LIST: DeviceScope[] = ['ALL', 'DESKTOP', 'PHONE'];
109
107
 
@@ -128,11 +126,13 @@ export class CrUXManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
128
126
  #configSetting: Common.Settings.Setting<ConfigSetting>;
129
127
  #endpoint = DEFAULT_ENDPOINT;
130
128
  #pageResult?: PageResult;
129
+ readonly #targetManager: SDK.TargetManager.TargetManager;
131
130
  fieldDeviceOption: DeviceOption = 'AUTO';
132
131
  fieldPageScope: PageScope = 'url';
133
132
 
134
- private constructor() {
133
+ constructor(targetManager: SDK.TargetManager.TargetManager, settings: Common.Settings.Settings) {
135
134
  super();
135
+ this.#targetManager = targetManager;
136
136
 
137
137
  /**
138
138
  * In an incognito or guest window - which is called an "OffTheRecord"
@@ -149,7 +149,7 @@ export class CrUXManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
149
149
  const storageTypeForConsent =
150
150
  useSessionStorage ? Common.Settings.SettingStorageType.SESSION : Common.Settings.SettingStorageType.GLOBAL;
151
151
 
152
- this.#configSetting = Common.Settings.Settings.instance().createSetting<ConfigSetting>(
152
+ this.#configSetting = settings.createSetting<ConfigSetting>(
153
153
  'field-data', {enabled: false, override: '', originMappings: [], overrideEnabled: false},
154
154
  storageTypeForConsent);
155
155
 
@@ -157,18 +157,23 @@ export class CrUXManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
157
157
  void this.refresh();
158
158
  });
159
159
 
160
- SDK.TargetManager.TargetManager.instance().addModelListener(
161
- SDK.ResourceTreeModel.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this.#onFrameNavigated,
162
- this);
160
+ this.#targetManager.addModelListener(SDK.ResourceTreeModel.ResourceTreeModel,
161
+ SDK.ResourceTreeModel.Events.FrameNavigated, this.#onFrameNavigated, this);
163
162
  }
164
163
 
165
164
  static instance(opts: {forceNew: boolean|null} = {forceNew: null}): CrUXManager {
166
165
  const {forceNew} = opts;
167
- if (!cruxManagerInstance || forceNew) {
168
- cruxManagerInstance = new CrUXManager();
166
+ if (!Root.DevToolsContext.globalInstance().has(CrUXManager) || forceNew) {
167
+ Root.DevToolsContext.globalInstance().set(
168
+ CrUXManager,
169
+ new CrUXManager(SDK.TargetManager.TargetManager.instance(), Common.Settings.Settings.instance()));
169
170
  }
170
171
 
171
- return cruxManagerInstance;
172
+ return Root.DevToolsContext.globalInstance().get(CrUXManager);
173
+ }
174
+
175
+ static removeInstance(): void {
176
+ Root.DevToolsContext.globalInstance().delete(CrUXManager);
172
177
  }
173
178
 
174
179
  /** The most recent page result from the CrUX service. */
@@ -264,7 +269,7 @@ export class CrUXManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
264
269
  }
265
270
 
266
271
  async #getInspectedURL(): Promise<string> {
267
- const targetManager = SDK.TargetManager.TargetManager.instance();
272
+ const targetManager = this.#targetManager;
268
273
  let inspectedURL = targetManager.inspectedURL();
269
274
  if (!inspectedURL) {
270
275
  inspectedURL = await new Promise(resolve => {
@@ -5,6 +5,7 @@
5
5
  import * as Common from '../../core/common/common.js';
6
6
  import * as Host from '../../core/host/host.js';
7
7
  import * as i18n from '../../core/i18n/i18n.js';
8
+ import * as Root from '../../core/root/root.js';
8
9
  import * as SDK from '../../core/sdk/sdk.js';
9
10
  import * as Protocol from '../../generated/protocol.js';
10
11
  import * as Geometry from '../geometry/geometry.js';
@@ -84,8 +85,6 @@ const UIStrings = {
84
85
  const str_ = i18n.i18n.registerUIStrings('models/emulation/DeviceModeModel.ts', UIStrings);
85
86
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
86
87
 
87
- let deviceModeModelInstance: DeviceModeModel|null;
88
-
89
88
  export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTypes> implements
90
89
  SDK.TargetManager.SDKModelObserver<SDK.EmulationModel.EmulationModel> {
91
90
  #screenRect: Rect;
@@ -114,9 +113,19 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
114
113
  #onModelAvailable: (() => void)|null;
115
114
  #outlineRect?: Rect;
116
115
  #screenOrientationLocked: boolean;
117
-
118
- private constructor() {
116
+ readonly #targetManager: SDK.TargetManager.TargetManager;
117
+ readonly #settings: Common.Settings.Settings;
118
+ readonly #multitargetNetworkManager: SDK.NetworkManager.MultitargetNetworkManager;
119
+
120
+ constructor(
121
+ targetManager: SDK.TargetManager.TargetManager,
122
+ settings: Common.Settings.Settings,
123
+ multitargetNetworkManager: SDK.NetworkManager.MultitargetNetworkManager,
124
+ ) {
119
125
  super();
126
+ this.#targetManager = targetManager;
127
+ this.#settings = settings;
128
+ this.#multitargetNetworkManager = multitargetNetworkManager;
120
129
  this.#screenRect = new Rect(0, 0, 1, 1);
121
130
  this.#visiblePageRect = new Rect(0, 0, 1, 1);
122
131
  this.#availableSize = new Geometry.Size(1, 1);
@@ -126,7 +135,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
126
135
  this.#appliedDeviceScaleFactor = globalThis.devicePixelRatio;
127
136
  this.#appliedUserAgentType = UA.DESKTOP;
128
137
 
129
- this.#scaleSetting = Common.Settings.Settings.instance().createSetting('emulation.device-scale', 1);
138
+ this.#scaleSetting = this.#settings.createSetting('emulation.device-scale', 1);
130
139
  // We've used to allow zero before.
131
140
  if (!this.#scaleSetting.get()) {
132
141
  this.#scaleSetting.set(1);
@@ -134,7 +143,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
134
143
  this.#scaleSetting.addChangeListener(this.scaleSettingChanged, this);
135
144
  this.#scale = 1;
136
145
 
137
- this.#widthSetting = Common.Settings.Settings.instance().createSetting('emulation.device-width', 400);
146
+ this.#widthSetting = this.#settings.createSetting('emulation.device-width', 400);
138
147
  if (this.#widthSetting.get() < MinDeviceSize) {
139
148
  this.#widthSetting.set(MinDeviceSize);
140
149
  }
@@ -143,7 +152,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
143
152
  }
144
153
  this.#widthSetting.addChangeListener(this.widthSettingChanged, this);
145
154
 
146
- this.#heightSetting = Common.Settings.Settings.instance().createSetting('emulation.device-height', 0);
155
+ this.#heightSetting = this.#settings.createSetting('emulation.device-height', 0);
147
156
  if (this.#heightSetting.get() && this.#heightSetting.get() < MinDeviceSize) {
148
157
  this.#heightSetting.set(MinDeviceSize);
149
158
  }
@@ -152,17 +161,16 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
152
161
  }
153
162
  this.#heightSetting.addChangeListener(this.heightSettingChanged, this);
154
163
 
155
- this.#uaSetting = Common.Settings.Settings.instance().createSetting('emulation.device-ua', UA.MOBILE);
164
+ this.#uaSetting = this.#settings.createSetting('emulation.device-ua', UA.MOBILE);
156
165
  this.#uaSetting.addChangeListener(this.uaSettingChanged, this);
157
- this.#deviceScaleFactorSetting =
158
- Common.Settings.Settings.instance().createSetting('emulation.device-scale-factor', 0);
166
+ this.#deviceScaleFactorSetting = this.#settings.createSetting('emulation.device-scale-factor', 0);
159
167
  this.#deviceScaleFactorSetting.addChangeListener(this.deviceScaleFactorSettingChanged, this);
160
168
 
161
- this.#deviceOutlineSetting = Common.Settings.Settings.instance().moduleSetting('emulation.show-device-outline');
169
+ this.#deviceOutlineSetting = this.#settings.createSetting('emulation.show-device-outline', false);
162
170
  this.#deviceOutlineSetting.addChangeListener(this.deviceOutlineSettingChanged, this);
163
171
 
164
- this.#toolbarControlsEnabledSetting = Common.Settings.Settings.instance().createSetting(
165
- 'emulation.toolbar-controls-enabled', true, Common.Settings.SettingStorageType.SESSION);
172
+ this.#toolbarControlsEnabledSetting = this.#settings.createSetting('emulation.toolbar-controls-enabled', true,
173
+ Common.Settings.SettingStorageType.SESSION);
166
174
 
167
175
  this.#type = Type.None;
168
176
  this.#device = null;
@@ -174,15 +182,20 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
174
182
  this.#emulationModel = null;
175
183
  this.#onModelAvailable = null;
176
184
  this.#screenOrientationLocked = false;
177
- SDK.TargetManager.TargetManager.instance().observeModels(SDK.EmulationModel.EmulationModel, this);
185
+ this.#targetManager.observeModels(SDK.EmulationModel.EmulationModel, this);
178
186
  }
179
187
 
180
188
  static instance(opts?: {forceNew: boolean}): DeviceModeModel {
181
- if (!deviceModeModelInstance || opts?.forceNew) {
182
- deviceModeModelInstance = new DeviceModeModel();
189
+ if (!Root.DevToolsContext.globalInstance().has(DeviceModeModel) || opts?.forceNew) {
190
+ Root.DevToolsContext.globalInstance().set(DeviceModeModel,
191
+ new DeviceModeModel(
192
+ SDK.TargetManager.TargetManager.instance(),
193
+ Common.Settings.Settings.instance(),
194
+ SDK.NetworkManager.MultitargetNetworkManager.instance(),
195
+ ));
183
196
  }
184
197
 
185
- return deviceModeModelInstance;
198
+ return Root.DevToolsContext.globalInstance().get(DeviceModeModel);
186
199
  }
187
200
 
188
201
  /**
@@ -201,11 +214,14 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
201
214
  }
202
215
 
203
216
  static removeInstance(): void {
204
- deviceModeModelInstance = null;
217
+ if (Root.DevToolsContext.globalInstance().has(DeviceModeModel)) {
218
+ Root.DevToolsContext.globalInstance().get(DeviceModeModel).dispose();
219
+ }
220
+ Root.DevToolsContext.globalInstance().delete(DeviceModeModel);
205
221
  }
206
222
 
207
223
  dispose(): void {
208
- SDK.TargetManager.TargetManager.instance().unobserveModels(SDK.EmulationModel.EmulationModel, this);
224
+ this.#targetManager.unobserveModels(SDK.EmulationModel.EmulationModel, this);
209
225
  }
210
226
 
211
227
  static widthValidator(value: string): {
@@ -363,6 +379,10 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
363
379
  '';
364
380
  }
365
381
 
382
+ canShowDeviceFrame(): boolean {
383
+ return Boolean(this.#device && this.#mode && this.#device.outlineImage(this.#mode));
384
+ }
385
+
366
386
  outlineRect(): Rect|null {
367
387
  return this.#outlineRect || null;
368
388
  }
@@ -412,7 +432,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
412
432
  }
413
433
 
414
434
  enabledSetting(): Common.Settings.Setting<boolean> {
415
- return Common.Settings.Settings.instance().createSetting('emulation.show-device-mode', false);
435
+ return this.#settings.createSetting('emulation.show-device-mode', false);
416
436
  }
417
437
 
418
438
  scaleSetting(): Common.Settings.Setting<number> {
@@ -444,7 +464,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
444
464
  }
445
465
 
446
466
  modelAdded(emulationModel: SDK.EmulationModel.EmulationModel): void {
447
- if (emulationModel.target() === SDK.TargetManager.TargetManager.instance().primaryPageTarget() &&
467
+ if (emulationModel.target() === this.#targetManager.primaryPageTarget() &&
448
468
  emulationModel.supportsDeviceEmulation()) {
449
469
  this.#emulationModel = emulationModel;
450
470
  if (this.#onModelAvailable) {
@@ -713,8 +733,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
713
733
  // When the user agent string is empty (e.g. custom desktop device without
714
734
  // a UA override), metadata must also be cleared. The backend rejects
715
735
  // setUserAgentOverride calls that provide metadata without a UA string.
716
- SDK.NetworkManager.MultitargetNetworkManager.instance().setUserAgentOverride(
717
- userAgent, userAgent ? userAgentMetadata : null);
736
+ this.#multitargetNetworkManager.setUserAgentOverride(userAgent, userAgent ? userAgentMetadata : null);
718
737
  }
719
738
 
720
739
  private applyDeviceMetrics(
@@ -854,7 +873,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
854
873
  private applyTouch(touchEnabled: boolean, mobile: boolean): void {
855
874
  this.#touchEnabled = touchEnabled;
856
875
  this.#touchMobile = mobile;
857
- for (const emulationModel of SDK.TargetManager.TargetManager.instance().models(SDK.EmulationModel.EmulationModel)) {
876
+ for (const emulationModel of this.#targetManager.models(SDK.EmulationModel.EmulationModel)) {
858
877
  void emulationModel.emulateTouch(touchEnabled, mobile);
859
878
  }
860
879
  }