chrome-devtools-frontend 1.0.970539 → 1.0.972865

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 (115) hide show
  1. package/config/gni/devtools_grd_files.gni +12 -7
  2. package/config/gni/devtools_image_files.gni +1 -0
  3. package/front_end/Images/src/ic_changes.svg +5 -0
  4. package/front_end/core/common/ParsedURL.ts +11 -5
  5. package/front_end/core/host/UserMetrics.ts +4 -1
  6. package/front_end/core/i18n/locales/en-US.json +45 -0
  7. package/front_end/core/i18n/locales/en-XL.json +45 -0
  8. package/front_end/core/platform/UserVisibleError.ts +28 -0
  9. package/front_end/core/platform/platform.ts +2 -0
  10. package/front_end/core/sdk/CSSModel.ts +21 -0
  11. package/front_end/core/sdk/CSSStyleSheetHeader.ts +10 -10
  12. package/front_end/core/sdk/ChildTargetManager.ts +0 -1
  13. package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +6 -4
  14. package/front_end/core/sdk/DOMDebuggerModel.ts +4 -3
  15. package/front_end/core/sdk/DebuggerModel.ts +17 -16
  16. package/front_end/core/sdk/NetworkManager.ts +32 -10
  17. package/front_end/core/sdk/NetworkRequest.ts +29 -16
  18. package/front_end/core/sdk/Resource.ts +10 -10
  19. package/front_end/core/sdk/ResourceTreeModel.ts +16 -13
  20. package/front_end/core/sdk/Script.ts +10 -10
  21. package/front_end/core/sdk/SourceMap.ts +8 -6
  22. package/front_end/entrypoints/lighthouse_worker/LighthouseService.ts +35 -12
  23. package/front_end/entrypoints/main/MainImpl.ts +8 -0
  24. package/front_end/generated/InspectorBackendCommands.js +14 -8
  25. package/front_end/generated/SupportedCSSProperties.js +2 -0
  26. package/front_end/generated/protocol-mapping.d.ts +5 -0
  27. package/front_end/generated/protocol-proxy-api.d.ts +5 -0
  28. package/front_end/generated/protocol.ts +20 -12
  29. package/front_end/models/bindings/BreakpointManager.ts +7 -5
  30. package/front_end/models/bindings/CSSWorkspaceBinding.ts +10 -3
  31. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +2 -1
  32. package/front_end/models/bindings/ResourceMapping.ts +2 -1
  33. package/front_end/models/bindings/ResourceScriptMapping.ts +2 -1
  34. package/front_end/models/bindings/SASSSourceMapping.ts +4 -3
  35. package/front_end/models/bindings/StylesSourceMapping.ts +2 -1
  36. package/front_end/models/har/HARFormat.ts +4 -2
  37. package/front_end/models/har/Importer.ts +0 -1
  38. package/front_end/models/issues_manager/FederatedAuthRequestIssue.ts +12 -12
  39. package/front_end/models/issues_manager/descriptions/{federatedAuthRequestClientIdMetadataHttpNotFound.md → federatedAuthRequestClientMetadataHttpNotFound.md} +0 -0
  40. package/front_end/models/issues_manager/descriptions/{federatedAuthRequestClientIdMetadataInvalidResponse.md → federatedAuthRequestClientMetadataInvalidResponse.md} +0 -0
  41. package/front_end/models/issues_manager/descriptions/{federatedAuthRequestClientIdMetadataNoResponse.md → federatedAuthRequestClientMetadataNoResponse.md} +0 -0
  42. package/front_end/models/issues_manager/descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
  43. package/front_end/models/issues_manager/descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
  44. package/front_end/models/issues_manager/descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
  45. package/front_end/models/persistence/Automapping.ts +1 -1
  46. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +7 -7
  47. package/front_end/models/persistence/IsolatedFileSystem.ts +10 -13
  48. package/front_end/models/persistence/PersistenceActions.ts +1 -4
  49. package/front_end/models/persistence/PlatformFileSystem.ts +3 -3
  50. package/front_end/{panels/sources/SourceMapNamesResolver.ts → models/source_map_scopes/NamesResolver.ts} +5 -5
  51. package/front_end/models/source_map_scopes/source_map_scopes.ts +7 -0
  52. package/front_end/models/text_utils/ContentProvider.ts +2 -1
  53. package/front_end/models/text_utils/StaticContentProvider.ts +7 -5
  54. package/front_end/models/workspace/UISourceCode.ts +7 -7
  55. package/front_end/models/workspace/WorkspaceImpl.ts +1 -3
  56. package/front_end/models/workspace_diff/WorkspaceDiff.ts +20 -8
  57. package/front_end/panels/application/ServiceWorkerCacheViews.ts +3 -2
  58. package/front_end/panels/browser_debugger/categorizedBreakpointsSidebarPane.css +0 -1
  59. package/front_end/panels/changes/ChangesView.ts +4 -4
  60. package/front_end/panels/console/ConsolePrompt.ts +25 -2
  61. package/front_end/panels/console/ConsoleViewMessage.ts +41 -8
  62. package/front_end/panels/coverage/CoverageModel.ts +1 -1
  63. package/front_end/panels/elements/ElementsPanel.ts +25 -11
  64. package/front_end/panels/elements/ElementsTreeElement.ts +0 -6
  65. package/front_end/panels/elements/StylesSidebarPane.ts +236 -51
  66. package/front_end/panels/elements/elementsTreeOutline.css +0 -1
  67. package/front_end/panels/issues/AffectedResourcesView.ts +1 -1
  68. package/front_end/panels/issues/AffectedSourcesView.ts +1 -1
  69. package/front_end/panels/lighthouse/LighthouseController.ts +41 -0
  70. package/front_end/panels/lighthouse/LighthousePanel.ts +64 -9
  71. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +32 -4
  72. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +0 -5
  73. package/front_end/panels/lighthouse/LighthouseStartView.ts +8 -4
  74. package/front_end/panels/lighthouse/LighthouseStartViewFR.ts +100 -0
  75. package/front_end/panels/lighthouse/LighthouseTimespanView.ts +99 -0
  76. package/front_end/panels/network/NetworkDataGridNode.ts +1 -1
  77. package/front_end/panels/profiler/CPUProfileView.ts +1 -1
  78. package/front_end/panels/profiler/HeapProfileView.ts +0 -2
  79. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +0 -1
  80. package/front_end/panels/profiler/HeapSnapshotView.ts +2 -3
  81. package/front_end/panels/sensors/sensors.css +0 -1
  82. package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
  83. package/front_end/panels/sources/DebuggerPlugin.ts +5 -4
  84. package/front_end/panels/sources/NavigatorView.ts +14 -10
  85. package/front_end/panels/sources/ScopeChainSidebarPane.ts +6 -3
  86. package/front_end/panels/sources/SourcesNavigator.ts +7 -1
  87. package/front_end/panels/sources/sources-legacy.ts +5 -16
  88. package/front_end/panels/sources/sources.ts +0 -2
  89. package/front_end/panels/sources/sourcesView.css +0 -4
  90. package/front_end/panels/timeline/TimelineUIUtils.ts +4 -47
  91. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  92. package/front_end/third_party/codemirror.next/chunk/json.js +2 -1
  93. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +3 -1
  94. package/front_end/third_party/codemirror.next/package.json +9 -9
  95. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1047 -1158
  96. package/front_end/third_party/lighthouse/locales/en-US.json +7 -1
  97. package/front_end/third_party/lighthouse/locales/en-XL.json +7 -1
  98. package/front_end/third_party/lighthouse/report/bundle.d.ts +0 -3
  99. package/front_end/third_party/lighthouse/report/bundle.js +38 -24
  100. package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
  101. package/front_end/ui/legacy/ViewManager.ts +2 -1
  102. package/front_end/ui/legacy/closeButton.css +0 -1
  103. package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +7 -4
  104. package/front_end/ui/legacy/components/source_frame/FontView.ts +1 -1
  105. package/front_end/ui/legacy/components/source_frame/ImageView.ts +1 -1
  106. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +2 -3
  107. package/front_end/ui/legacy/components/utils/Linkifier.ts +20 -59
  108. package/front_end/ui/legacy/tabbedPane.css +0 -2
  109. package/front_end/ui/legacy/toolbar.css +28 -3
  110. package/package.json +1 -1
  111. package/scripts/hosted_mode/server.js +13 -0
  112. package/scripts/npm_test.js +1 -1
  113. package/front_end/models/issues_manager/descriptions/federatedAuthRequestWellKnownHttpNotFound.md +0 -1
  114. package/front_end/models/issues_manager/descriptions/federatedAuthRequestWellKnownInvalidResponse.md +0 -1
  115. package/front_end/models/issues_manager/descriptions/federatedAuthRequestWellKnownNoResponse.md +0 -1
@@ -412,6 +412,16 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
412
412
  * once it is created in `requestWillBeSent`.
413
413
  */
414
414
  this.#requestIdToTrustTokenEvent = new Map();
415
+
416
+ MultitargetNetworkManager.instance().addEventListener(
417
+ MultitargetNetworkManager.Events.RequestIntercepted, this.#markAsIntercepted.bind(this));
418
+ }
419
+
420
+ #markAsIntercepted(event: Common.EventTarget.EventTargetEvent<string>): void {
421
+ const request = this.requestForURL(event.data);
422
+ if (request) {
423
+ request.setWasIntercepted(true);
424
+ }
415
425
  }
416
426
 
417
427
  private headersMapToHeadersArray(headersMap: Protocol.Network.Headers): NameValue[] {
@@ -437,7 +447,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
437
447
 
438
448
  private updateNetworkRequestWithResponse(networkRequest: NetworkRequest, response: Protocol.Network.Response): void {
439
449
  if (response.url && networkRequest.url() !== response.url) {
440
- networkRequest.setUrl(response.url);
450
+ networkRequest.setUrl(response.url as Platform.DevToolsPath.UrlString);
441
451
  }
442
452
  networkRequest.mimeType = (response.mimeType as MIME_TYPE);
443
453
  if (!networkRequest.statusCode) {
@@ -446,7 +456,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
446
456
  if (!networkRequest.statusText) {
447
457
  networkRequest.statusText = response.statusText;
448
458
  }
449
- if (!networkRequest.hasExtraResponseInfo()) {
459
+ if (!networkRequest.hasExtraResponseInfo() || networkRequest.wasIntercepted()) {
450
460
  networkRequest.responseHeaders = this.headersMapToHeadersArray(response.headers);
451
461
  }
452
462
 
@@ -578,10 +588,12 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
578
588
  frameId,
579
589
  });
580
590
  }
581
- networkRequest = this.appendRedirect(requestId, timestamp, request.url);
591
+ networkRequest = this.appendRedirect(requestId, timestamp, request.url as Platform.DevToolsPath.UrlString);
582
592
  this.#manager.dispatchEventToListeners(Events.RequestRedirected, networkRequest);
583
593
  } else {
584
- networkRequest = NetworkRequest.create(requestId, request.url, documentURL, frameId ?? null, loaderId, initiator);
594
+ networkRequest = NetworkRequest.create(
595
+ requestId, request.url as Platform.DevToolsPath.UrlString, documentURL as Platform.DevToolsPath.UrlString,
596
+ frameId ?? null, loaderId, initiator);
585
597
  requestToManagerMap.set(networkRequest, this.#manager);
586
598
  }
587
599
  networkRequest.hasNetworkData = true;
@@ -620,7 +632,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
620
632
  const lastModifiedHeader = lowercaseHeaders['last-modified'];
621
633
  // We missed the requestWillBeSent.
622
634
  const eventData: RequestUpdateDroppedEventData = {
623
- url: response.url,
635
+ url: response.url as Platform.DevToolsPath.UrlString,
624
636
  frameId: frameId ?? null,
625
637
  loaderId: loaderId,
626
638
  resourceType: type,
@@ -706,7 +718,8 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
706
718
  }
707
719
 
708
720
  webSocketCreated({requestId, url: requestURL, initiator}: Protocol.Network.WebSocketCreatedEvent): void {
709
- const networkRequest = NetworkRequest.createForWebSocket(requestId, requestURL, initiator);
721
+ const networkRequest =
722
+ NetworkRequest.createForWebSocket(requestId, requestURL as Platform.DevToolsPath.UrlString, initiator);
710
723
  requestToManagerMap.set(networkRequest, this.#manager);
711
724
  networkRequest.setResourceType(Common.ResourceType.resourceTypes.WebSocket);
712
725
  this.startNetworkRequest(networkRequest, null);
@@ -855,7 +868,9 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
855
868
  return builder;
856
869
  }
857
870
 
858
- private appendRedirect(requestId: Protocol.Network.RequestId, time: number, redirectURL: string): NetworkRequest {
871
+ private appendRedirect(
872
+ requestId: Protocol.Network.RequestId, time: number,
873
+ redirectURL: Platform.DevToolsPath.UrlString): NetworkRequest {
859
874
  const originalNetworkRequest = this.#requestsById.get(requestId);
860
875
  if (!originalNetworkRequest) {
861
876
  throw new Error(`Could not find original network request for ${requestId}`);
@@ -958,7 +973,8 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
958
973
 
959
974
  webTransportCreated({transportId, url: requestURL, timestamp: time, initiator}:
960
975
  Protocol.Network.WebTransportCreatedEvent): void {
961
- const networkRequest = NetworkRequest.createForWebSocket(transportId, requestURL, initiator);
976
+ const networkRequest =
977
+ NetworkRequest.createForWebSocket(transportId, requestURL as Platform.DevToolsPath.UrlString, initiator);
962
978
  networkRequest.hasNetworkData = true;
963
979
  requestToManagerMap.set(networkRequest, this.#manager);
964
980
  networkRequest.setResourceType(Common.ResourceType.resourceTypes.WebTransport);
@@ -1061,7 +1077,9 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
1061
1077
  private createNetworkRequest(
1062
1078
  requestId: Protocol.Network.RequestId, frameId: Protocol.Page.FrameId, loaderId: Protocol.Network.LoaderId,
1063
1079
  url: string, documentURL: string, initiator: Protocol.Network.Initiator|null): NetworkRequest {
1064
- const request = NetworkRequest.create(requestId, url, documentURL, frameId, loaderId, initiator);
1080
+ const request = NetworkRequest.create(
1081
+ requestId, url as Platform.DevToolsPath.UrlString, documentURL as Platform.DevToolsPath.UrlString, frameId,
1082
+ loaderId, initiator);
1065
1083
  requestToManagerMap.set(request, this.#manager);
1066
1084
  return request;
1067
1085
  }
@@ -1401,6 +1419,8 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
1401
1419
  for (const requestInterceptor of this.#urlsForRequestInterceptor.keysArray()) {
1402
1420
  await requestInterceptor(interceptedRequest);
1403
1421
  if (interceptedRequest.hasResponded()) {
1422
+ this.dispatchEventToListeners(
1423
+ MultitargetNetworkManager.Events.RequestIntercepted, interceptedRequest.request.url);
1404
1424
  return;
1405
1425
  }
1406
1426
  }
@@ -1467,6 +1487,7 @@ export namespace MultitargetNetworkManager {
1467
1487
  UserAgentChanged = 'UserAgentChanged',
1468
1488
  InterceptorsChanged = 'InterceptorsChanged',
1469
1489
  AcceptedEncodingsChanged = 'AcceptedEncodingsChanged',
1490
+ RequestIntercepted = 'RequestIntercepted',
1470
1491
  }
1471
1492
 
1472
1493
  export type EventTypes = {
@@ -1475,6 +1496,7 @@ export namespace MultitargetNetworkManager {
1475
1496
  [Events.UserAgentChanged]: void,
1476
1497
  [Events.InterceptorsChanged]: void,
1477
1498
  [Events.AcceptedEncodingsChanged]: void,
1499
+ [Events.RequestIntercepted]: string,
1478
1500
  };
1479
1501
  }
1480
1502
 
@@ -1709,7 +1731,7 @@ export interface InterceptionPattern {
1709
1731
  export type RequestInterceptor = (request: InterceptedRequest) => Promise<void>;
1710
1732
 
1711
1733
  export interface RequestUpdateDroppedEventData {
1712
- url: string;
1734
+ url: Platform.DevToolsPath.UrlString;
1713
1735
  frameId: Protocol.Page.FrameId|null;
1714
1736
  loaderId: Protocol.Network.LoaderId;
1715
1737
  resourceType: Protocol.Network.ResourceType;
@@ -204,7 +204,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
204
204
  TextUtils.ContentProvider.ContentProvider {
205
205
  #requestIdInternal: string;
206
206
  #backendRequestIdInternal?: Protocol.Network.RequestId;
207
- readonly #documentURLInternal: string;
207
+ readonly #documentURLInternal: Platform.DevToolsPath.UrlString;
208
208
  readonly #frameIdInternal: Protocol.Page.FrameId|null;
209
209
  readonly #loaderIdInternal: Protocol.Network.LoaderId|null;
210
210
  readonly #initiatorInternal: Protocol.Network.Initiator|null|undefined;
@@ -257,7 +257,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
257
257
  #includedRequestCookiesInternal: Cookie[];
258
258
  #blockedResponseCookiesInternal: BlockedSetCookieWithReason[];
259
259
  localizedFailDescription: string|null;
260
- #urlInternal!: string;
260
+ #urlInternal!: Platform.DevToolsPath.UrlString;
261
261
  #responseReceivedTimeInternal!: number;
262
262
  #transferSizeInternal!: number;
263
263
  #finishedInternal!: boolean;
@@ -290,11 +290,12 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
290
290
  #parsedQueryParameters?: NameValue[];
291
291
  #contentDataProvider?: (() => Promise<ContentData>);
292
292
  #isSameSiteInternal: boolean|null;
293
+ #wasIntercepted: boolean;
293
294
 
294
295
  private constructor(
295
- requestId: string, backendRequestId: Protocol.Network.RequestId|undefined, url: string, documentURL: string,
296
- frameId: Protocol.Page.FrameId|null, loaderId: Protocol.Network.LoaderId|null,
297
- initiator: Protocol.Network.Initiator|null) {
296
+ requestId: string, backendRequestId: Protocol.Network.RequestId|undefined, url: Platform.DevToolsPath.UrlString,
297
+ documentURL: Platform.DevToolsPath.UrlString, frameId: Protocol.Page.FrameId|null,
298
+ loaderId: Protocol.Network.LoaderId|null, initiator: Protocol.Network.Initiator|null) {
298
299
  super();
299
300
 
300
301
  this.#requestIdInternal = requestId;
@@ -363,23 +364,28 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
363
364
 
364
365
  this.localizedFailDescription = null;
365
366
  this.#isSameSiteInternal = null;
367
+
368
+ this.#wasIntercepted = false;
366
369
  }
367
370
 
368
371
  static create(
369
- backendRequestId: Protocol.Network.RequestId, url: string, documentURL: string,
370
- frameId: Protocol.Page.FrameId|null, loaderId: Protocol.Network.LoaderId|null,
371
- initiator: Protocol.Network.Initiator|null): NetworkRequest {
372
+ backendRequestId: Protocol.Network.RequestId, url: Platform.DevToolsPath.UrlString,
373
+ documentURL: Platform.DevToolsPath.UrlString, frameId: Protocol.Page.FrameId|null,
374
+ loaderId: Protocol.Network.LoaderId|null, initiator: Protocol.Network.Initiator|null): NetworkRequest {
372
375
  return new NetworkRequest(backendRequestId, backendRequestId, url, documentURL, frameId, loaderId, initiator);
373
376
  }
374
377
 
375
378
  static createForWebSocket(
376
- backendRequestId: Protocol.Network.RequestId, requestURL: string,
379
+ backendRequestId: Protocol.Network.RequestId, requestURL: Platform.DevToolsPath.UrlString,
377
380
  initiator?: Protocol.Network.Initiator): NetworkRequest {
378
- return new NetworkRequest(backendRequestId, backendRequestId, requestURL, '', null, null, initiator || null);
381
+ return new NetworkRequest(
382
+ backendRequestId, backendRequestId, requestURL, '' as Platform.DevToolsPath.UrlString, null, null,
383
+ initiator || null);
379
384
  }
380
385
 
381
386
  static createWithoutBackendRequest(
382
- requestId: string, url: string, documentURL: string, initiator: Protocol.Network.Initiator|null): NetworkRequest {
387
+ requestId: string, url: Platform.DevToolsPath.UrlString, documentURL: Platform.DevToolsPath.UrlString,
388
+ initiator: Protocol.Network.Initiator|null): NetworkRequest {
383
389
  return new NetworkRequest(requestId, undefined, url, documentURL, null, null, initiator);
384
390
  }
385
391
 
@@ -403,7 +409,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
403
409
  return this.#backendRequestIdInternal;
404
410
  }
405
411
 
406
- url(): string {
412
+ url(): Platform.DevToolsPath.UrlString {
407
413
  return this.#urlInternal;
408
414
  }
409
415
 
@@ -411,7 +417,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
411
417
  return this.#urlInternal.startsWith('blob:');
412
418
  }
413
419
 
414
- setUrl(x: string): void {
420
+ setUrl(x: Platform.DevToolsPath.UrlString): void {
415
421
  if (this.#urlInternal === x) {
416
422
  return;
417
423
  }
@@ -424,7 +430,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
424
430
  this.#pathInternal = undefined;
425
431
  }
426
432
 
427
- get documentURL(): string {
433
+ get documentURL(): Platform.DevToolsPath.UrlString {
428
434
  return this.#documentURLInternal;
429
435
  }
430
436
 
@@ -964,6 +970,14 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
964
970
  return this.#responseHeaderValues[headerName];
965
971
  }
966
972
 
973
+ wasIntercepted(): boolean {
974
+ return this.#wasIntercepted;
975
+ }
976
+
977
+ setWasIntercepted(wasIntercepted: boolean): void {
978
+ this.#wasIntercepted = wasIntercepted;
979
+ }
980
+
967
981
  get responseCookies(): Cookie[] {
968
982
  if (!this.#responseCookiesInternal) {
969
983
  this.#responseCookiesInternal =
@@ -1175,8 +1189,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
1175
1189
  this.#contentDataProvider = dataProvider;
1176
1190
  }
1177
1191
 
1178
- // TODO(crbug.com/1253323): Cast to RawPathString will be removed when migration to branded types is complete.
1179
- contentURL(): string {
1192
+ contentURL(): Platform.DevToolsPath.UrlString {
1180
1193
  return this.#urlInternal;
1181
1194
  }
1182
1195
 
@@ -42,8 +42,8 @@ import type {ResourceTreeFrame, ResourceTreeModel} from './ResourceTreeModel.js'
42
42
  export class Resource implements TextUtils.ContentProvider.ContentProvider {
43
43
  readonly #resourceTreeModel: ResourceTreeModel;
44
44
  #requestInternal: NetworkRequest|null;
45
- #urlInternal!: string;
46
- readonly #documentURLInternal: string;
45
+ #urlInternal!: Platform.DevToolsPath.UrlString;
46
+ readonly #documentURLInternal: Platform.DevToolsPath.UrlString;
47
47
  readonly #frameIdInternal: Protocol.Page.FrameId|null;
48
48
  readonly #loaderIdInternal: Protocol.Network.LoaderId|null;
49
49
  readonly #type: Common.ResourceType.ResourceType;
@@ -58,9 +58,10 @@ export class Resource implements TextUtils.ContentProvider.ContentProvider {
58
58
  #contentRequested?: boolean;
59
59
 
60
60
  constructor(
61
- resourceTreeModel: ResourceTreeModel, request: NetworkRequest|null, url: string, documentURL: string,
62
- frameId: Protocol.Page.FrameId|null, loaderId: Protocol.Network.LoaderId|null,
63
- type: Common.ResourceType.ResourceType, mimeType: string, lastModified: Date|null, contentSize: number|null) {
61
+ resourceTreeModel: ResourceTreeModel, request: NetworkRequest|null, url: Platform.DevToolsPath.UrlString,
62
+ documentURL: Platform.DevToolsPath.UrlString, frameId: Protocol.Page.FrameId|null,
63
+ loaderId: Protocol.Network.LoaderId|null, type: Common.ResourceType.ResourceType, mimeType: string,
64
+ lastModified: Date|null, contentSize: number|null) {
64
65
  this.#resourceTreeModel = resourceTreeModel;
65
66
  this.#requestInternal = request;
66
67
  this.url = url;
@@ -101,11 +102,11 @@ export class Resource implements TextUtils.ContentProvider.ContentProvider {
101
102
  return this.#requestInternal;
102
103
  }
103
104
 
104
- get url(): string {
105
+ get url(): Platform.DevToolsPath.UrlString {
105
106
  return this.#urlInternal;
106
107
  }
107
108
 
108
- set url(x: string) {
109
+ set url(x: Platform.DevToolsPath.UrlString) {
109
110
  this.#urlInternal = x;
110
111
  this.#parsedURLInternal = new Common.ParsedURL.ParsedURL(x);
111
112
  }
@@ -114,7 +115,7 @@ export class Resource implements TextUtils.ContentProvider.ContentProvider {
114
115
  return this.#parsedURLInternal;
115
116
  }
116
117
 
117
- get documentURL(): string {
118
+ get documentURL(): Platform.DevToolsPath.UrlString {
118
119
  return this.#documentURLInternal;
119
120
  }
120
121
 
@@ -150,8 +151,7 @@ export class Resource implements TextUtils.ContentProvider.ContentProvider {
150
151
  this.#isGeneratedInternal = val;
151
152
  }
152
153
 
153
- // TODO(crbug.com/1253323): Cast to RawPathString will be removed when migration to branded types is complete.
154
- contentURL(): string {
154
+ contentURL(): Platform.DevToolsPath.UrlString {
155
155
  return this.#urlInternal;
156
156
  }
157
157
 
@@ -34,6 +34,7 @@
34
34
 
35
35
  import * as Common from '../common/common.js';
36
36
  import * as i18n from '../i18n/i18n.js';
37
+ import type * as Platform from '../platform/platform.js';
37
38
  import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
38
39
  import * as Protocol from '../../generated/protocol.js';
39
40
 
@@ -237,8 +238,8 @@ export class ResourceTreeModel extends SDKModel<EventTypes> {
237
238
  const frame = this.framesInternal.get(framePayload.id);
238
239
  if (frame && !frame.getResourcesMap().get(framePayload.url)) {
239
240
  const frameResource = this.createResourceFromFramePayload(
240
- framePayload, framePayload.url, Common.ResourceType.resourceTypes.Document, framePayload.mimeType, null,
241
- null);
241
+ framePayload, framePayload.url as Platform.DevToolsPath.UrlString, Common.ResourceType.resourceTypes.Document,
242
+ framePayload.mimeType, null, null);
242
243
  frameResource.isGenerated = true;
243
244
  frame.addResource(frameResource);
244
245
  }
@@ -342,25 +343,27 @@ export class ResourceTreeModel extends SDKModel<EventTypes> {
342
343
  for (let i = 0; i < frameTreePayload.resources.length; ++i) {
343
344
  const subresource = frameTreePayload.resources[i];
344
345
  const resource = this.createResourceFromFramePayload(
345
- framePayload, subresource.url, Common.ResourceType.resourceTypes[subresource.type], subresource.mimeType,
346
- subresource.lastModified || null, subresource.contentSize || null);
346
+ framePayload, subresource.url as Platform.DevToolsPath.UrlString,
347
+ Common.ResourceType.resourceTypes[subresource.type], subresource.mimeType, subresource.lastModified || null,
348
+ subresource.contentSize || null);
347
349
  frame.addResource(resource);
348
350
  }
349
351
 
350
352
  if (!frame.getResourcesMap().get(framePayload.url)) {
351
353
  const frameResource = this.createResourceFromFramePayload(
352
- framePayload, framePayload.url, Common.ResourceType.resourceTypes.Document, framePayload.mimeType, null,
353
- null);
354
+ framePayload, framePayload.url as Platform.DevToolsPath.UrlString, Common.ResourceType.resourceTypes.Document,
355
+ framePayload.mimeType, null, null);
354
356
  frame.addResource(frameResource);
355
357
  }
356
358
  }
357
359
 
358
360
  private createResourceFromFramePayload(
359
- frame: Protocol.Page.Frame, url: string, type: Common.ResourceType.ResourceType, mimeType: string,
360
- lastModifiedTime: number|null, contentSize: number|null): Resource {
361
+ frame: Protocol.Page.Frame, url: Platform.DevToolsPath.UrlString, type: Common.ResourceType.ResourceType,
362
+ mimeType: string, lastModifiedTime: number|null, contentSize: number|null): Resource {
361
363
  const lastModified = typeof lastModifiedTime === 'number' ? new Date(lastModifiedTime * 1000) : null;
362
364
  return new Resource(
363
- this, null, url, frame.url, frame.id, frame.loaderId, type, mimeType, lastModified, contentSize);
365
+ this, null, url, frame.url as Platform.DevToolsPath.UrlString, frame.id, frame.loaderId, type, mimeType,
366
+ lastModified, contentSize);
364
367
  }
365
368
 
366
369
  suspendReload(): void {
@@ -601,7 +604,7 @@ export class ResourceTreeFrame {
601
604
  crossTargetParentFrameId: string|null;
602
605
  #loaderIdInternal: string;
603
606
  #nameInternal: string|null|undefined;
604
- #urlInternal: string;
607
+ #urlInternal: Platform.DevToolsPath.UrlString;
605
608
  #domainAndRegistryInternal: string;
606
609
  #securityOriginInternal: string|null;
607
610
  #unreachableUrlInternal: string;
@@ -633,7 +636,7 @@ export class ResourceTreeFrame {
633
636
 
634
637
  this.#loaderIdInternal = (payload && payload.loaderId) || '';
635
638
  this.#nameInternal = payload && payload.name;
636
- this.#urlInternal = (payload && payload.url) || '';
639
+ this.#urlInternal = ((payload && payload.url) || '') as Platform.DevToolsPath.UrlString;
637
640
  this.#domainAndRegistryInternal = (payload && payload.domainAndRegistry) || '';
638
641
  this.#securityOriginInternal = payload && payload.securityOrigin;
639
642
  this.#unreachableUrlInternal = (payload && payload.unreachableUrl) || '';
@@ -685,7 +688,7 @@ export class ResourceTreeFrame {
685
688
  navigate(framePayload: Protocol.Page.Frame): void {
686
689
  this.#loaderIdInternal = framePayload.loaderId;
687
690
  this.#nameInternal = framePayload.name;
688
- this.#urlInternal = framePayload.url;
691
+ this.#urlInternal = framePayload.url as Platform.DevToolsPath.UrlString;
689
692
  this.#domainAndRegistryInternal = framePayload.domainAndRegistry;
690
693
  this.#securityOriginInternal = framePayload.securityOrigin;
691
694
  this.#unreachableUrlInternal = framePayload.unreachableUrl || '';
@@ -719,7 +722,7 @@ export class ResourceTreeFrame {
719
722
  return this.#nameInternal || '';
720
723
  }
721
724
 
722
- get url(): string {
725
+ get url(): Platform.DevToolsPath.UrlString {
723
726
  return this.#urlInternal;
724
727
  }
725
728
 
@@ -29,6 +29,7 @@
29
29
 
30
30
  import * as Protocol from '../../generated/protocol.js';
31
31
  import * as TextUtils from '../../models/text_utils/text_utils.js';
32
+ import type * as Platform from '../../core/platform/platform.js';
32
33
  import * as Common from '../common/common.js';
33
34
  import * as i18n from '../i18n/i18n.js';
34
35
 
@@ -56,7 +57,7 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
56
57
  export class Script implements TextUtils.ContentProvider.ContentProvider, FrameAssociated {
57
58
  debuggerModel: DebuggerModel;
58
59
  scriptId: Protocol.Runtime.ScriptId;
59
- sourceURL: string;
60
+ sourceURL: Platform.DevToolsPath.UrlString;
60
61
  lineOffset: number;
61
62
  columnOffset: number;
62
63
  endLine: number;
@@ -65,7 +66,7 @@ export class Script implements TextUtils.ContentProvider.ContentProvider, FrameA
65
66
  hash: string;
66
67
  readonly #isContentScriptInternal: boolean;
67
68
  readonly #isLiveEditInternal: boolean;
68
- sourceMapURL: string|undefined;
69
+ sourceMapURL: Platform.DevToolsPath.UrlString|undefined;
69
70
  debugSymbols: Protocol.Debugger.DebugSymbols|null;
70
71
  hasSourceURL: boolean;
71
72
  contentLength: number;
@@ -77,12 +78,12 @@ export class Script implements TextUtils.ContentProvider.ContentProvider, FrameA
77
78
  readonly #embedderNameInternal: string|null;
78
79
  readonly isModule: boolean|null;
79
80
  constructor(
80
- debuggerModel: DebuggerModel, scriptId: Protocol.Runtime.ScriptId, sourceURL: string, startLine: number,
81
- startColumn: number, endLine: number, endColumn: number, executionContextId: number, hash: string,
82
- isContentScript: boolean, isLiveEdit: boolean, sourceMapURL: string|undefined, hasSourceURL: boolean,
83
- length: number, isModule: boolean|null, originStackTrace: Protocol.Runtime.StackTrace|null,
84
- codeOffset: number|null, scriptLanguage: string|null, debugSymbols: Protocol.Debugger.DebugSymbols|null,
85
- embedderName: string|null) {
81
+ debuggerModel: DebuggerModel, scriptId: Protocol.Runtime.ScriptId, sourceURL: Platform.DevToolsPath.UrlString,
82
+ startLine: number, startColumn: number, endLine: number, endColumn: number, executionContextId: number,
83
+ hash: string, isContentScript: boolean, isLiveEdit: boolean,
84
+ sourceMapURL: Platform.DevToolsPath.UrlString|undefined, hasSourceURL: boolean, length: number,
85
+ isModule: boolean|null, originStackTrace: Protocol.Runtime.StackTrace|null, codeOffset: number|null,
86
+ scriptLanguage: string|null, debugSymbols: Protocol.Debugger.DebugSymbols|null, embedderName: string|null) {
86
87
  this.debuggerModel = debuggerModel;
87
88
  this.scriptId = scriptId;
88
89
  this.sourceURL = sourceURL;
@@ -163,8 +164,7 @@ export class Script implements TextUtils.ContentProvider.ContentProvider, FrameA
163
164
  return this.#isLiveEditInternal;
164
165
  }
165
166
 
166
- // TODO(crbug.com/1253323): Cast to RawPathString will be removed when migration to branded types is complete.
167
- contentURL(): string {
167
+ contentURL(): Platform.DevToolsPath.UrlString {
168
168
  return this.sourceURL;
169
169
  }
170
170
 
@@ -32,6 +32,8 @@
32
32
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
33
  */
34
34
 
35
+ // TODO(crbug.com/1253323): Casts to UrlString will be removed from this file when migration to branded types is complete.
36
+
35
37
  import * as TextUtils from '../../models/text_utils/text_utils.js';
36
38
  import * as Common from '../common/common.js';
37
39
  import * as i18n from '../i18n/i18n.js';
@@ -143,7 +145,7 @@ export class TextSourceMap implements SourceMap {
143
145
  readonly #sourceMappingURL: string;
144
146
  readonly #baseURL: string;
145
147
  #mappingsInternal: SourceMapEntry[]|null;
146
- readonly #sourceInfos: Map<string, TextSourceMap.SourceInfo>;
148
+ readonly #sourceInfos: Map<Platform.DevToolsPath.UrlString, TextSourceMap.SourceInfo>;
147
149
 
148
150
  /**
149
151
  * Implements Source Map V3 model. See https://github.com/google/closure-compiler/wiki/Source-Maps
@@ -201,11 +203,11 @@ export class TextSourceMap implements SourceMap {
201
203
  return this.#sourceMappingURL;
202
204
  }
203
205
 
204
- sourceURLs(): string[] {
206
+ sourceURLs(): Platform.DevToolsPath.UrlString[] {
205
207
  return [...this.#sourceInfos.keys()];
206
208
  }
207
209
 
208
- sourceContentProvider(sourceURL: string, contentType: Common.ResourceType.ResourceType):
210
+ sourceContentProvider(sourceURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType):
209
211
  TextUtils.ContentProvider.ContentProvider {
210
212
  const info = this.#sourceInfos.get(sourceURL);
211
213
  if (info && info.content) {
@@ -215,7 +217,7 @@ export class TextSourceMap implements SourceMap {
215
217
  }
216
218
 
217
219
  embeddedContentByURL(sourceURL: string): string|null {
218
- const entry = this.#sourceInfos.get(sourceURL);
220
+ const entry = this.#sourceInfos.get(sourceURL as Platform.DevToolsPath.UrlString);
219
221
  if (!entry) {
220
222
  return null;
221
223
  }
@@ -307,7 +309,7 @@ export class TextSourceMap implements SourceMap {
307
309
  }
308
310
 
309
311
  private reversedMappings(sourceURL: string): number[] {
310
- const info = this.#sourceInfos.get(sourceURL);
312
+ const info = this.#sourceInfos.get(sourceURL as Platform.DevToolsPath.UrlString);
311
313
  if (!info) {
312
314
  return [];
313
315
  }
@@ -371,7 +373,7 @@ export class TextSourceMap implements SourceMap {
371
373
  if (url === this.#compiledURLInternal && source) {
372
374
  url += '? [sm]';
373
375
  }
374
- this.#sourceInfos.set(url, new TextSourceMap.SourceInfo(source || null, null));
376
+ this.#sourceInfos.set(url as Platform.DevToolsPath.UrlString, new TextSourceMap.SourceInfo(source || null, null));
375
377
  sourcesList.push(url);
376
378
  }
377
379
  sourceMapToSourceList.set(sourceMap, sourcesList);
@@ -75,6 +75,7 @@ class ConnectionProxy implements SDK.Connections.ParallelConnectionInterface {
75
75
 
76
76
  const port = new LighthousePort();
77
77
  let rawConnection: ConnectionProxy|undefined;
78
+ let endTimespan: (() => unknown)|undefined;
78
79
 
79
80
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
81
  async function start(method: string, params: any): Promise<unknown> {
@@ -92,6 +93,17 @@ async function start(method: string, params: any): Promise<unknown> {
92
93
  undefined;
93
94
 
94
95
  try {
96
+ // For timespan we only need to perform setup on startTimespan.
97
+ // Config, flags, locale, etc. should be stored in the closure of endTimespan.
98
+ if (method === 'endTimespan') {
99
+ if (!endTimespan) {
100
+ throw new Error('Cannot end a timespan before starting one');
101
+ }
102
+ const result = await endTimespan();
103
+ endTimespan = undefined;
104
+ return result;
105
+ }
106
+
95
107
  const locale = await fetchLocaleData(params.locales);
96
108
  const flags = params.flags;
97
109
  flags.logLevel = flags.logLevel || 'info';
@@ -103,7 +115,7 @@ async function start(method: string, params: any): Promise<unknown> {
103
115
  const url = params.url;
104
116
 
105
117
  // Handle legacy Lighthouse runner path.
106
- if (method === 'start') {
118
+ if (method === 'navigation' && flags.legacyNavigation) {
107
119
  // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
108
120
  const connection = self.setUpWorkerConnection(port);
109
121
  // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
@@ -112,17 +124,23 @@ async function start(method: string, params: any): Promise<unknown> {
112
124
 
113
125
  const {mainTargetId, mainFrameId, mainSessionId} = params.target;
114
126
  rawConnection = new ConnectionProxy(mainSessionId);
115
- puppeteerConnection =
127
+ const {page} = puppeteerConnection =
116
128
  await Puppeteer.PuppeteerConnection.getPuppeteerConnection(rawConnection, mainFrameId, mainTargetId);
117
129
 
118
- // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
119
- const result = await self.runLighthouseNavigation({
120
- url,
121
- config,
122
- page: puppeteerConnection.page,
123
- });
130
+ if (method === 'snapshot') {
131
+ // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
132
+ return await self.runLighthouseSnapshot({config, page});
133
+ }
124
134
 
125
- return result;
135
+ if (method === 'startTimespan') {
136
+ // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
137
+ const timespan = await self.startLighthouseTimespan({config, page});
138
+ endTimespan = timespan.endTimespan;
139
+ return;
140
+ }
141
+
142
+ // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
143
+ return await self.runLighthouseNavigation(url, {config, page});
126
144
  } catch (err) {
127
145
  return ({
128
146
  fatal: true,
@@ -130,7 +148,10 @@ async function start(method: string, params: any): Promise<unknown> {
130
148
  stack: err.stack,
131
149
  });
132
150
  } finally {
133
- puppeteerConnection?.browser.disconnect();
151
+ // endTimespan will need to use the same connection as startTimespan.
152
+ if (method !== 'startTimespan') {
153
+ puppeteerConnection?.browser.disconnect();
154
+ }
134
155
  }
135
156
  }
136
157
 
@@ -179,8 +200,10 @@ function notifyFrontendViaWorkerMessage(method: string, params: any): void {
179
200
  self.onmessage = async(event: MessageEvent): Promise<void> => {
180
201
  const messageFromFrontend = JSON.parse(event.data);
181
202
  switch (messageFromFrontend.method) {
182
- case 'navigate':
183
- case 'start': {
203
+ case 'startTimespan':
204
+ case 'endTimespan':
205
+ case 'snapshot':
206
+ case 'navigation': {
184
207
  const result = await start(messageFromFrontend.method, messageFromFrontend.params);
185
208
  self.postMessage(JSON.stringify({id: messageFromFrontend.id, result}));
186
209
  break;
@@ -309,9 +309,14 @@ export class MainImpl {
309
309
  'timelineV8RuntimeCallStats', 'Timeline: V8 Runtime Call Stats on Timeline', true);
310
310
  Root.Runtime.experiments.register('timelineWebGL', 'Timeline: WebGL-based flamechart');
311
311
  Root.Runtime.experiments.register('timelineReplayEvent', 'Timeline: Replay input events', true);
312
+
313
+ // Debugging
312
314
  Root.Runtime.experiments.register(
313
315
  'wasmDWARFDebugging', 'WebAssembly Debugging: Enable DWARF support', undefined,
314
316
  'https://developer.chrome.com/blog/wasm-debugging-2020/');
317
+ Root.Runtime.experiments.register(
318
+ 'evaluateExpressionsWithSourceMaps', 'Console: Resolve variable names in expressions using source maps',
319
+ undefined);
315
320
 
316
321
  // Dual-screen
317
322
  Root.Runtime.experiments.register(
@@ -376,6 +381,9 @@ export class MainImpl {
376
381
  Root.Runtime.experiments.register(
377
382
  Root.Runtime.ExperimentName.HEADER_OVERRIDES, 'Local overrides for response headers');
378
383
 
384
+ // New Lighthouse panel with timespan and snapshot mode
385
+ Root.Runtime.experiments.register('lighthousePanelFR', 'Use Lighthouse panel with timespan and snapshot modes');
386
+
379
387
  Root.Runtime.experiments.enableExperimentsByDefault([
380
388
  'sourceOrderViewer',
381
389
  'hideIssuesFeature',