chrome-devtools-frontend 1.0.972361 → 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 (28) hide show
  1. package/config/gni/devtools_grd_files.gni +1 -0
  2. package/front_end/core/i18n/locales/en-US.json +24 -0
  3. package/front_end/core/i18n/locales/en-XL.json +24 -0
  4. package/front_end/core/sdk/NetworkManager.ts +15 -7
  5. package/front_end/core/sdk/NetworkRequest.ts +16 -14
  6. package/front_end/core/sdk/ResourceTreeModel.ts +8 -10
  7. package/front_end/core/sdk/SourceMap.ts +9 -9
  8. package/front_end/entrypoints/lighthouse_worker/LighthouseService.ts +30 -14
  9. package/front_end/models/bindings/SASSSourceMapping.ts +4 -3
  10. package/front_end/models/har/HARFormat.ts +4 -2
  11. package/front_end/models/har/Importer.ts +0 -1
  12. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +4 -4
  13. package/front_end/models/persistence/IsolatedFileSystem.ts +0 -1
  14. package/front_end/models/text_utils/StaticContentProvider.ts +5 -4
  15. package/front_end/panels/application/ServiceWorkerCacheViews.ts +2 -1
  16. package/front_end/panels/lighthouse/LighthouseController.ts +13 -2
  17. package/front_end/panels/lighthouse/LighthousePanel.ts +57 -8
  18. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +28 -5
  19. package/front_end/panels/lighthouse/LighthouseStartView.ts +6 -2
  20. package/front_end/panels/lighthouse/LighthouseStartViewFR.ts +61 -0
  21. package/front_end/panels/lighthouse/LighthouseTimespanView.ts +99 -0
  22. package/front_end/panels/sources/NavigatorView.ts +1 -3
  23. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  24. package/front_end/third_party/codemirror.next/chunk/json.js +2 -1
  25. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +3 -1
  26. package/front_end/third_party/codemirror.next/package.json +9 -9
  27. package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +7 -4
  28. package/package.json +1 -1
@@ -1050,6 +1050,7 @@ grd_files_debug_sources = [
1050
1050
  "front_end/panels/lighthouse/LighthouseStartView.js",
1051
1051
  "front_end/panels/lighthouse/LighthouseStartViewFR.js",
1052
1052
  "front_end/panels/lighthouse/LighthouseStatusView.js",
1053
+ "front_end/panels/lighthouse/LighthouseTimespanView.js",
1053
1054
  "front_end/panels/lighthouse/RadioSetting.js",
1054
1055
  "front_end/panels/lighthouse/lighthouseDialog.css.js",
1055
1056
  "front_end/panels/lighthouse/lighthousePanel.css.js",
@@ -5819,6 +5819,9 @@
5819
5819
  "panels/lighthouse/LighthouseController.ts | thereMayBeStoredDataAffectingSingular": {
5820
5820
  "message": "There may be stored data affecting loading performance in this location: {PH1}. Audit this page in an incognito window to prevent those resources from affecting your scores."
5821
5821
  },
5822
+ "panels/lighthouse/LighthouseController.ts | timespan": {
5823
+ "message": "Timespan"
5824
+ },
5822
5825
  "panels/lighthouse/LighthouseController.ts | useLegacyNavigation": {
5823
5826
  "message": "Audit the page using classic Lighthouse when in navigation mode."
5824
5827
  },
@@ -5879,9 +5882,18 @@
5879
5882
  "panels/lighthouse/LighthouseStartView.ts | learnMore": {
5880
5883
  "message": "Learn more"
5881
5884
  },
5885
+ "panels/lighthouse/LighthouseStartViewFR.ts | analyzeNavigation": {
5886
+ "message": "Analyze navigation"
5887
+ },
5888
+ "panels/lighthouse/LighthouseStartViewFR.ts | analyzeSnapshot": {
5889
+ "message": "Analyze snapshot"
5890
+ },
5882
5891
  "panels/lighthouse/LighthouseStartViewFR.ts | mode": {
5883
5892
  "message": "Mode"
5884
5893
  },
5894
+ "panels/lighthouse/LighthouseStartViewFR.ts | startTimespan": {
5895
+ "message": "Start timespan"
5896
+ },
5885
5897
  "panels/lighthouse/LighthouseStatusView.ts | ahSorryWeRanIntoAnError": {
5886
5898
  "message": "Ah, sorry! We ran into an error."
5887
5899
  },
@@ -5969,6 +5981,18 @@
5969
5981
  "panels/lighthouse/LighthouseStatusView.ts | walmartSawAIncreaseInRevenueFor": {
5970
5982
  "message": "Walmart saw a 1% increase in revenue for every 100ms improvement in page load [Source: WPO Stats]"
5971
5983
  },
5984
+ "panels/lighthouse/LighthouseTimespanView.ts | cancel": {
5985
+ "message": "Cancel"
5986
+ },
5987
+ "panels/lighthouse/LighthouseTimespanView.ts | endTimespan": {
5988
+ "message": "End timespan"
5989
+ },
5990
+ "panels/lighthouse/LighthouseTimespanView.ts | timespanStarted": {
5991
+ "message": "Timespan started, interact with the page"
5992
+ },
5993
+ "panels/lighthouse/LighthouseTimespanView.ts | timespanStarting": {
5994
+ "message": "Timespan starting…"
5995
+ },
5972
5996
  "panels/media/EventDisplayTable.ts | eventDisplay": {
5973
5997
  "message": "Event display"
5974
5998
  },
@@ -5819,6 +5819,9 @@
5819
5819
  "panels/lighthouse/LighthouseController.ts | thereMayBeStoredDataAffectingSingular": {
5820
5820
  "message": "T̂h́êŕê ḿâý b̂é ŝt́ôŕêd́ d̂át̂á âf́f̂éĉt́îńĝ ĺôád̂ín̂ǵ p̂ér̂f́ôŕm̂án̂ćê ín̂ t́ĥíŝ ĺôćât́îón̂: {PH1}. Áûd́ît́ t̂h́îś p̂áĝé îń âń îńĉóĝńît́ô ẃîńd̂óŵ t́ô ṕr̂év̂én̂t́ t̂h́ôśê ŕêśôúr̂ćêś f̂ŕôḿ âf́f̂éĉt́îńĝ ýôúr̂ śĉór̂éŝ."
5821
5821
  },
5822
+ "panels/lighthouse/LighthouseController.ts | timespan": {
5823
+ "message": "T̂ím̂éŝṕâń"
5824
+ },
5822
5825
  "panels/lighthouse/LighthouseController.ts | useLegacyNavigation": {
5823
5826
  "message": "Âúd̂ít̂ t́ĥé p̂áĝé ûśîńĝ ćl̂áŝśîć L̂íĝh́t̂h́ôúŝé ŵh́êń îń n̂áv̂íĝát̂íôń m̂ód̂é."
5824
5827
  },
@@ -5879,9 +5882,18 @@
5879
5882
  "panels/lighthouse/LighthouseStartView.ts | learnMore": {
5880
5883
  "message": "L̂éâŕn̂ ḿôŕê"
5881
5884
  },
5885
+ "panels/lighthouse/LighthouseStartViewFR.ts | analyzeNavigation": {
5886
+ "message": "Âńâĺŷźê ńâv́îǵât́îón̂"
5887
+ },
5888
+ "panels/lighthouse/LighthouseStartViewFR.ts | analyzeSnapshot": {
5889
+ "message": "Âńâĺŷźê śn̂áp̂śĥót̂"
5890
+ },
5882
5891
  "panels/lighthouse/LighthouseStartViewFR.ts | mode": {
5883
5892
  "message": "M̂ód̂é"
5884
5893
  },
5894
+ "panels/lighthouse/LighthouseStartViewFR.ts | startTimespan": {
5895
+ "message": "Ŝt́âŕt̂ t́îḿêśp̂án̂"
5896
+ },
5885
5897
  "panels/lighthouse/LighthouseStatusView.ts | ahSorryWeRanIntoAnError": {
5886
5898
  "message": "Âh́, ŝór̂ŕŷ! Ẃê ŕâń îńt̂ó âń êŕr̂ór̂."
5887
5899
  },
@@ -5969,6 +5981,18 @@
5969
5981
  "panels/lighthouse/LighthouseStatusView.ts | walmartSawAIncreaseInRevenueFor": {
5970
5982
  "message": "Ŵál̂ḿâŕt̂ śâẃ â 1% ín̂ćr̂éâśê ín̂ ŕêv́êńûé f̂ór̂ év̂ér̂ý 100m̂ś îḿp̂ŕôv́êḿêńt̂ ín̂ ṕâǵê ĺôád̂ [Śôúr̂ćê: WPO Stats]"
5971
5983
  },
5984
+ "panels/lighthouse/LighthouseTimespanView.ts | cancel": {
5985
+ "message": "Ĉán̂ćêĺ"
5986
+ },
5987
+ "panels/lighthouse/LighthouseTimespanView.ts | endTimespan": {
5988
+ "message": "Êńd̂ t́îḿêśp̂án̂"
5989
+ },
5990
+ "panels/lighthouse/LighthouseTimespanView.ts | timespanStarted": {
5991
+ "message": "T̂ím̂éŝṕâń ŝt́âŕt̂éd̂, ín̂t́êŕâćt̂ ẃît́ĥ t́ĥé p̂áĝé"
5992
+ },
5993
+ "panels/lighthouse/LighthouseTimespanView.ts | timespanStarting": {
5994
+ "message": "T̂ím̂éŝṕâń ŝt́âŕt̂ín̂ǵ…"
5995
+ },
5972
5996
  "panels/media/EventDisplayTable.ts | eventDisplay": {
5973
5997
  "message": "Êv́êńt̂ d́îśp̂ĺâý"
5974
5998
  },
@@ -447,7 +447,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
447
447
 
448
448
  private updateNetworkRequestWithResponse(networkRequest: NetworkRequest, response: Protocol.Network.Response): void {
449
449
  if (response.url && networkRequest.url() !== response.url) {
450
- networkRequest.setUrl(response.url);
450
+ networkRequest.setUrl(response.url as Platform.DevToolsPath.UrlString);
451
451
  }
452
452
  networkRequest.mimeType = (response.mimeType as MIME_TYPE);
453
453
  if (!networkRequest.statusCode) {
@@ -588,10 +588,12 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
588
588
  frameId,
589
589
  });
590
590
  }
591
- networkRequest = this.appendRedirect(requestId, timestamp, request.url);
591
+ networkRequest = this.appendRedirect(requestId, timestamp, request.url as Platform.DevToolsPath.UrlString);
592
592
  this.#manager.dispatchEventToListeners(Events.RequestRedirected, networkRequest);
593
593
  } else {
594
- 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);
595
597
  requestToManagerMap.set(networkRequest, this.#manager);
596
598
  }
597
599
  networkRequest.hasNetworkData = true;
@@ -716,7 +718,8 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
716
718
  }
717
719
 
718
720
  webSocketCreated({requestId, url: requestURL, initiator}: Protocol.Network.WebSocketCreatedEvent): void {
719
- const networkRequest = NetworkRequest.createForWebSocket(requestId, requestURL, initiator);
721
+ const networkRequest =
722
+ NetworkRequest.createForWebSocket(requestId, requestURL as Platform.DevToolsPath.UrlString, initiator);
720
723
  requestToManagerMap.set(networkRequest, this.#manager);
721
724
  networkRequest.setResourceType(Common.ResourceType.resourceTypes.WebSocket);
722
725
  this.startNetworkRequest(networkRequest, null);
@@ -865,7 +868,9 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
865
868
  return builder;
866
869
  }
867
870
 
868
- 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 {
869
874
  const originalNetworkRequest = this.#requestsById.get(requestId);
870
875
  if (!originalNetworkRequest) {
871
876
  throw new Error(`Could not find original network request for ${requestId}`);
@@ -968,7 +973,8 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
968
973
 
969
974
  webTransportCreated({transportId, url: requestURL, timestamp: time, initiator}:
970
975
  Protocol.Network.WebTransportCreatedEvent): void {
971
- const networkRequest = NetworkRequest.createForWebSocket(transportId, requestURL, initiator);
976
+ const networkRequest =
977
+ NetworkRequest.createForWebSocket(transportId, requestURL as Platform.DevToolsPath.UrlString, initiator);
972
978
  networkRequest.hasNetworkData = true;
973
979
  requestToManagerMap.set(networkRequest, this.#manager);
974
980
  networkRequest.setResourceType(Common.ResourceType.resourceTypes.WebTransport);
@@ -1071,7 +1077,9 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
1071
1077
  private createNetworkRequest(
1072
1078
  requestId: Protocol.Network.RequestId, frameId: Protocol.Page.FrameId, loaderId: Protocol.Network.LoaderId,
1073
1079
  url: string, documentURL: string, initiator: Protocol.Network.Initiator|null): NetworkRequest {
1074
- 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);
1075
1083
  requestToManagerMap.set(request, this.#manager);
1076
1084
  return request;
1077
1085
  }
@@ -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;
@@ -293,9 +293,9 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
293
293
  #wasIntercepted: boolean;
294
294
 
295
295
  private constructor(
296
- requestId: string, backendRequestId: Protocol.Network.RequestId|undefined, url: string, documentURL: string,
297
- frameId: Protocol.Page.FrameId|null, loaderId: Protocol.Network.LoaderId|null,
298
- 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) {
299
299
  super();
300
300
 
301
301
  this.#requestIdInternal = requestId;
@@ -369,20 +369,23 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
369
369
  }
370
370
 
371
371
  static create(
372
- backendRequestId: Protocol.Network.RequestId, url: string, documentURL: string,
373
- frameId: Protocol.Page.FrameId|null, loaderId: Protocol.Network.LoaderId|null,
374
- 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 {
375
375
  return new NetworkRequest(backendRequestId, backendRequestId, url, documentURL, frameId, loaderId, initiator);
376
376
  }
377
377
 
378
378
  static createForWebSocket(
379
- backendRequestId: Protocol.Network.RequestId, requestURL: string,
379
+ backendRequestId: Protocol.Network.RequestId, requestURL: Platform.DevToolsPath.UrlString,
380
380
  initiator?: Protocol.Network.Initiator): NetworkRequest {
381
- 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);
382
384
  }
383
385
 
384
386
  static createWithoutBackendRequest(
385
- 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 {
386
389
  return new NetworkRequest(requestId, undefined, url, documentURL, null, null, initiator);
387
390
  }
388
391
 
@@ -414,13 +417,12 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
414
417
  return this.#urlInternal.startsWith('blob:');
415
418
  }
416
419
 
417
- // TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
418
- setUrl(x: string): void {
420
+ setUrl(x: Platform.DevToolsPath.UrlString): void {
419
421
  if (this.#urlInternal === x) {
420
422
  return;
421
423
  }
422
424
 
423
- this.#urlInternal = x as Platform.DevToolsPath.UrlString;
425
+ this.#urlInternal = x;
424
426
  this.#parsedURLInternal = new Common.ParsedURL.ParsedURL(x);
425
427
  this.#queryStringInternal = undefined;
426
428
  this.#parsedQueryParameters = undefined;
@@ -428,7 +430,7 @@ export class NetworkRequest extends Common.ObjectWrapper.ObjectWrapper<EventType
428
430
  this.#pathInternal = undefined;
429
431
  }
430
432
 
431
- get documentURL(): string {
433
+ get documentURL(): Platform.DevToolsPath.UrlString {
432
434
  return this.#documentURLInternal;
433
435
  }
434
436
 
@@ -51,8 +51,6 @@ import {SDKModel} from './SDKModel.js';
51
51
  import {TargetManager} from './TargetManager.js';
52
52
  import {SecurityOriginManager} from './SecurityOriginManager.js';
53
53
 
54
- // TODO(crbug.com/1253323): Casts to UrlString will be removed from this file when migration to branded types is complete.
55
-
56
54
  export class ResourceTreeModel extends SDKModel<EventTypes> {
57
55
  readonly agent: ProtocolProxyApi.PageApi;
58
56
  readonly #securityOriginManager: SecurityOriginManager;
@@ -304,8 +302,8 @@ export class ResourceTreeModel extends SDKModel<EventTypes> {
304
302
  }
305
303
 
306
304
  const resource = new Resource(
307
- this, null, url, frame.url as Platform.DevToolsPath.UrlString, frameId, data.loaderId,
308
- Common.ResourceType.resourceTypes[data.resourceType], data.mimeType, data.lastModified, null);
305
+ this, null, url, frame.url, frameId, data.loaderId, Common.ResourceType.resourceTypes[data.resourceType],
306
+ data.mimeType, data.lastModified, null);
309
307
  frame.addResource(resource);
310
308
  }
311
309
 
@@ -606,7 +604,7 @@ export class ResourceTreeFrame {
606
604
  crossTargetParentFrameId: string|null;
607
605
  #loaderIdInternal: string;
608
606
  #nameInternal: string|null|undefined;
609
- #urlInternal: string;
607
+ #urlInternal: Platform.DevToolsPath.UrlString;
610
608
  #domainAndRegistryInternal: string;
611
609
  #securityOriginInternal: string|null;
612
610
  #unreachableUrlInternal: string;
@@ -638,7 +636,7 @@ export class ResourceTreeFrame {
638
636
 
639
637
  this.#loaderIdInternal = (payload && payload.loaderId) || '';
640
638
  this.#nameInternal = payload && payload.name;
641
- this.#urlInternal = (payload && payload.url) || '';
639
+ this.#urlInternal = ((payload && payload.url) || '') as Platform.DevToolsPath.UrlString;
642
640
  this.#domainAndRegistryInternal = (payload && payload.domainAndRegistry) || '';
643
641
  this.#securityOriginInternal = payload && payload.securityOrigin;
644
642
  this.#unreachableUrlInternal = (payload && payload.unreachableUrl) || '';
@@ -690,7 +688,7 @@ export class ResourceTreeFrame {
690
688
  navigate(framePayload: Protocol.Page.Frame): void {
691
689
  this.#loaderIdInternal = framePayload.loaderId;
692
690
  this.#nameInternal = framePayload.name;
693
- this.#urlInternal = framePayload.url;
691
+ this.#urlInternal = framePayload.url as Platform.DevToolsPath.UrlString;
694
692
  this.#domainAndRegistryInternal = framePayload.domainAndRegistry;
695
693
  this.#securityOriginInternal = framePayload.securityOrigin;
696
694
  this.#unreachableUrlInternal = framePayload.unreachableUrl || '';
@@ -724,7 +722,7 @@ export class ResourceTreeFrame {
724
722
  return this.#nameInternal || '';
725
723
  }
726
724
 
727
- get url(): string {
725
+ get url(): Platform.DevToolsPath.UrlString {
728
726
  return this.#urlInternal;
729
727
  }
730
728
 
@@ -847,8 +845,8 @@ export class ResourceTreeFrame {
847
845
  return;
848
846
  }
849
847
  resource = new Resource(
850
- this.#model, request, request.url(), request.documentURL as Platform.DevToolsPath.UrlString, request.frameId,
851
- request.loaderId, request.resourceType(), request.mimeType, null, null);
848
+ this.#model, request, request.url(), request.documentURL, request.frameId, request.loaderId,
849
+ request.resourceType(), request.mimeType, null, null);
852
850
  this.resourcesMap.set(resource.url, resource);
853
851
  this.#model.dispatchEventToListeners(Events.ResourceAdded, resource);
854
852
  }
@@ -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,23 +203,21 @@ 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) {
212
214
  return TextUtils.StaticContentProvider.StaticContentProvider.fromString(sourceURL, contentType, info.content);
213
215
  }
214
- // TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
215
- return new CompilerSourceMappingContentProvider(
216
- sourceURL as Platform.DevToolsPath.UrlString, contentType, this.#initiator);
216
+ return new CompilerSourceMappingContentProvider(sourceURL, contentType, this.#initiator);
217
217
  }
218
218
 
219
219
  embeddedContentByURL(sourceURL: string): string|null {
220
- const entry = this.#sourceInfos.get(sourceURL);
220
+ const entry = this.#sourceInfos.get(sourceURL as Platform.DevToolsPath.UrlString);
221
221
  if (!entry) {
222
222
  return null;
223
223
  }
@@ -309,7 +309,7 @@ export class TextSourceMap implements SourceMap {
309
309
  }
310
310
 
311
311
  private reversedMappings(sourceURL: string): number[] {
312
- const info = this.#sourceInfos.get(sourceURL);
312
+ const info = this.#sourceInfos.get(sourceURL as Platform.DevToolsPath.UrlString);
313
313
  if (!info) {
314
314
  return [];
315
315
  }
@@ -373,7 +373,7 @@ export class TextSourceMap implements SourceMap {
373
373
  if (url === this.#compiledURLInternal && source) {
374
374
  url += '? [sm]';
375
375
  }
376
- 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));
377
377
  sourcesList.push(url);
378
378
  }
379
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 === 'legacyNavigation') {
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,22 +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
130
  if (method === 'snapshot') {
119
131
  // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
120
- return await self.runLighthouseSnapshot({
121
- config,
122
- page: puppeteerConnection.page,
123
- });
132
+ return await self.runLighthouseSnapshot({config, page});
133
+ }
134
+
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;
124
140
  }
125
141
 
126
142
  // @ts-expect-error https://github.com/GoogleChrome/lighthouse/issues/11628
127
- return await self.runLighthouseNavigation(url, {
128
- config,
129
- page: puppeteerConnection.page,
130
- });
143
+ return await self.runLighthouseNavigation(url, {config, page});
131
144
  } catch (err) {
132
145
  return ({
133
146
  fatal: true,
@@ -135,7 +148,10 @@ async function start(method: string, params: any): Promise<unknown> {
135
148
  stack: err.stack,
136
149
  });
137
150
  } finally {
138
- puppeteerConnection?.browser.disconnect();
151
+ // endTimespan will need to use the same connection as startTimespan.
152
+ if (method !== 'startTimespan') {
153
+ puppeteerConnection?.browser.disconnect();
154
+ }
139
155
  }
140
156
  }
141
157
 
@@ -184,10 +200,10 @@ function notifyFrontendViaWorkerMessage(method: string, params: any): void {
184
200
  self.onmessage = async(event: MessageEvent): Promise<void> => {
185
201
  const messageFromFrontend = JSON.parse(event.data);
186
202
  switch (messageFromFrontend.method) {
187
- case 'navigation':
188
- case 'timespan':
203
+ case 'startTimespan':
204
+ case 'endTimespan':
189
205
  case 'snapshot':
190
- case 'legacyNavigation': {
206
+ case 'navigation': {
191
207
  const result = await start(messageFromFrontend.method, messageFromFrontend.params);
192
208
  self.postMessage(JSON.stringify({id: messageFromFrontend.id, result}));
193
209
  break;
@@ -31,6 +31,7 @@
31
31
  import * as Common from '../../core/common/common.js';
32
32
  import * as SDK from '../../core/sdk/sdk.js';
33
33
  import type * as Protocol from '../../generated/protocol.js';
34
+ import type * as Platform from '../../core/platform/platform.js';
34
35
  import * as Workspace from '../workspace/workspace.js';
35
36
 
36
37
  import {ContentProviderBasedProject} from './ContentProviderBasedProject.js';
@@ -78,7 +79,7 @@ export class SASSSourceMapping implements SourceMapping {
78
79
  for (const sourceURL of sourceMap.sourceURLs()) {
79
80
  let binding = bindings.get(sourceURL);
80
81
  if (!binding) {
81
- binding = new Binding(project, sourceURL);
82
+ binding = new Binding(project, sourceURL as Platform.DevToolsPath.UrlString);
82
83
  bindings.set(sourceURL, binding);
83
84
  }
84
85
  binding.addSourceMap(sourceMap, header.frameId);
@@ -163,11 +164,11 @@ const uiSourceCodeToBinding = new WeakMap<Workspace.UISourceCode.UISourceCode, B
163
164
 
164
165
  class Binding {
165
166
  readonly #project: ContentProviderBasedProject;
166
- readonly #url: string;
167
+ readonly #url: Platform.DevToolsPath.UrlString;
167
168
  referringSourceMaps: SDK.SourceMap.TextSourceMap[];
168
169
  uiSourceCode: Workspace.UISourceCode.UISourceCode|null;
169
170
 
170
- constructor(project: ContentProviderBasedProject, url: string) {
171
+ constructor(project: ContentProviderBasedProject, url: Platform.DevToolsPath.UrlString) {
171
172
  this.#project = project;
172
173
  this.#url = url;
173
174
 
@@ -2,6 +2,8 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
+ import type * as Platform from '../../core/platform/platform.js';
6
+
5
7
  /* eslint-disable @typescript-eslint/no-explicit-any */
6
8
 
7
9
  class HARBase {
@@ -197,7 +199,7 @@ export class HAREntry extends HARBase {
197
199
 
198
200
  class HARRequest extends HARBase {
199
201
  method: string;
200
- url: string;
202
+ url: Platform.DevToolsPath.UrlString;
201
203
  httpVersion: string;
202
204
  cookies: HARCookie[];
203
205
  headers: HARHeader[];
@@ -209,7 +211,7 @@ class HARRequest extends HARBase {
209
211
  constructor(data: any) {
210
212
  super(data);
211
213
  this.method = String(data['method']);
212
- this.url = String(data['url']);
214
+ this.url = String(data['url']) as Platform.DevToolsPath.UrlString;
213
215
  this.httpVersion = String(data['httpVersion']);
214
216
  this.cookies = Array.isArray(data['cookies']) ? data['cookies'].map(cookie => new HARCookie(cookie)) : [];
215
217
  this.headers = Array.isArray(data['headers']) ? data['headers'].map(header => new HARHeader(header)) : [];
@@ -38,7 +38,6 @@ export class Importer {
38
38
  lineNumber: initiatorEntry.lineNumber,
39
39
  };
40
40
  }
41
-
42
41
  const request = SDK.NetworkRequest.NetworkRequest.createWithoutBackendRequest(
43
42
  'har-' + requests.length, entry.request.url, documentURL, initiator);
44
43
  const page = pageref ? pages.get(pageref) : undefined;
@@ -79,9 +79,9 @@ export class FileSystemWorkspaceBinding {
79
79
  return fileSystem.supportsAutomapping();
80
80
  }
81
81
 
82
- static completeURL(project: Workspace.Workspace.Project, relativePath: string): string {
82
+ static completeURL(project: Workspace.Workspace.Project, relativePath: string): Platform.DevToolsPath.UrlString {
83
83
  const fsProject = project as FileSystem;
84
- return fsProject.fileSystemBaseURL + relativePath;
84
+ return Common.ParsedURL.ParsedURL.concatenate(fsProject.fileSystemBaseURL, relativePath);
85
85
  }
86
86
 
87
87
  static fileSystemPath(projectId: string): string {
@@ -155,7 +155,7 @@ export class FileSystemWorkspaceBinding {
155
155
 
156
156
  export class FileSystem extends Workspace.Workspace.ProjectStore {
157
157
  readonly fileSystemInternal: PlatformFileSystem;
158
- readonly fileSystemBaseURL: string;
158
+ readonly fileSystemBaseURL: Platform.DevToolsPath.UrlString;
159
159
  private readonly fileSystemParentURL: string;
160
160
  private readonly fileSystemWorkspaceBinding: FileSystemWorkspaceBinding;
161
161
  private readonly fileSystemPathInternal: string;
@@ -171,7 +171,7 @@ export class FileSystem extends Workspace.Workspace.ProjectStore {
171
171
  super(workspace, id, Workspace.Workspace.projectTypes.FileSystem, displayName);
172
172
 
173
173
  this.fileSystemInternal = isolatedFileSystem;
174
- this.fileSystemBaseURL = this.fileSystemInternal.path() + '/';
174
+ this.fileSystemBaseURL = Common.ParsedURL.ParsedURL.concatenate(this.fileSystemInternal.path(), '/');
175
175
  this.fileSystemParentURL = this.fileSystemBaseURL.substr(0, fileSystemPath.lastIndexOf('/') + 1);
176
176
  this.fileSystemWorkspaceBinding = fileSystemWorkspaceBinding;
177
177
  this.fileSystemPathInternal = fileSystemPath;
@@ -81,7 +81,6 @@ export class IsolatedFileSystem extends PlatformFileSystem {
81
81
 
82
82
  constructor(
83
83
  manager: IsolatedFileSystemManager, path: string, embedderPath: string, domFileSystem: FileSystem, type: string) {
84
- // TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
85
84
  super(path, type);
86
85
  this.manager = manager;
87
86
  this.embedderPathInternal = embedderPath;
@@ -14,9 +14,9 @@ export class StaticContentProvider implements ContentProvider {
14
14
  private readonly lazyContent: () => Promise<DeferredContent>;
15
15
 
16
16
  constructor(
17
- contentURL: string, contentType: Common.ResourceType.ResourceType, lazyContent: () => Promise<DeferredContent>) {
18
- // TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
19
- this.contentURLInternal = contentURL as Platform.DevToolsPath.UrlString;
17
+ contentURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType,
18
+ lazyContent: () => Promise<DeferredContent>) {
19
+ this.contentURLInternal = contentURL;
20
20
  this.contentTypeInternal = contentType;
21
21
  this.lazyContent = lazyContent;
22
22
  }
@@ -27,7 +27,8 @@ export class StaticContentProvider implements ContentProvider {
27
27
  content: string,
28
28
  isEncoded: boolean,
29
29
  }> => Promise.resolve({content, isEncoded: false});
30
- return new StaticContentProvider(contentURL, contentType, lazyContent);
30
+ // TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
31
+ return new StaticContentProvider(contentURL as Platform.DevToolsPath.UrlString, contentType, lazyContent);
31
32
  }
32
33
 
33
34
  contentURL(): Platform.DevToolsPath.UrlString {
@@ -381,7 +381,8 @@ export class ServiceWorkerCacheView extends UI.View.SimpleView {
381
381
 
382
382
  private createRequest(entry: Protocol.CacheStorage.DataEntry): SDK.NetworkRequest.NetworkRequest {
383
383
  const request = SDK.NetworkRequest.NetworkRequest.createWithoutBackendRequest(
384
- 'cache-storage-' + entry.requestURL, entry.requestURL, '', null);
384
+ 'cache-storage-' + entry.requestURL, entry.requestURL as Platform.DevToolsPath.UrlString,
385
+ '' as Platform.DevToolsPath.UrlString, null);
385
386
  request.requestMethod = entry.requestMethod;
386
387
  request.setRequestHeaders(entry.requestHeaders);
387
388
  request.statusCode = entry.responseStatus;