chrome-devtools-frontend 1.0.1153166 → 1.0.1155899

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 (61) hide show
  1. package/config/gni/devtools_grd_files.gni +3 -2
  2. package/front_end/core/common/Revealer.ts +1 -1
  3. package/front_end/core/host/InspectorFrontendHostAPI.ts +2 -0
  4. package/front_end/core/host/UserMetrics.ts +32 -12
  5. package/front_end/core/platform/array-utilities.ts +25 -9
  6. package/front_end/core/sdk/ChildTargetManager.ts +2 -1
  7. package/front_end/core/sdk/FilmStripModel.ts +35 -25
  8. package/front_end/devtools_compatibility.js +2 -0
  9. package/front_end/entrypoints/lighthouse_worker/LighthouseWorkerService.ts +8 -2
  10. package/front_end/entrypoints/worker_app/worker_app.ts +0 -1
  11. package/front_end/generated/InspectorBackendCommands.js +2 -1
  12. package/front_end/generated/protocol.ts +36 -0
  13. package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +90 -73
  14. package/front_end/models/issues_manager/IssuesManager.ts +5 -0
  15. package/front_end/models/issues_manager/SourceFrameIssuesManager.ts +31 -61
  16. package/front_end/models/issues_manager/StylesheetLoadingIssue.ts +69 -0
  17. package/front_end/models/issues_manager/descriptions/stylesheetLateImport.md +4 -0
  18. package/front_end/models/issues_manager/descriptions/stylesheetRequestFailed.md +3 -0
  19. package/front_end/models/issues_manager/issues_manager.ts +2 -0
  20. package/front_end/models/timeline_model/TimelineModel.ts +4 -0
  21. package/front_end/models/trace/ModelImpl.ts +1 -0
  22. package/front_end/models/trace/README.md +73 -17
  23. package/front_end/models/trace/handlers/NetworkRequestsHandler.ts +1 -1
  24. package/front_end/models/trace/handlers/RendererHandler.ts +33 -143
  25. package/front_end/models/trace/handlers/UserTimings.md +1 -1
  26. package/front_end/models/trace/types/TraceEvents.ts +3 -2
  27. package/front_end/panels/application/ApplicationPanelSidebar.ts +9 -6
  28. package/front_end/panels/application/PreloadingTreeElement.ts +25 -7
  29. package/front_end/panels/application/preloading/PreloadingView.ts +64 -31
  30. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +19 -9
  31. package/front_end/panels/console/ConsoleViewMessage.ts +14 -2
  32. package/front_end/panels/elements/ElementsPanel.ts +2 -3
  33. package/front_end/panels/elements/components/LayoutPane.ts +256 -60
  34. package/front_end/panels/elements/elements-legacy.ts +0 -3
  35. package/front_end/panels/elements/elements-meta.ts +10 -2
  36. package/front_end/panels/elements/elements.ts +0 -2
  37. package/front_end/panels/network/NetworkDataGridNode.ts +8 -0
  38. package/front_end/panels/network/NetworkLogView.ts +2 -1
  39. package/front_end/panels/network/NetworkPanel.ts +12 -1
  40. package/front_end/panels/recorder/components/ExtensionView.ts +1 -1
  41. package/front_end/panels/sources/DebuggerPlugin.ts +7 -4
  42. package/front_end/panels/sources/SourcesPanel.ts +1 -1
  43. package/front_end/panels/sources/components/BreakpointsView.ts +406 -89
  44. package/front_end/panels/sources/sources-meta.ts +13 -4
  45. package/front_end/panels/sources/sources.ts +0 -2
  46. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +1 -1
  47. package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +106 -95
  48. package/front_end/panels/timeline/TimelineFlameChartView.ts +1 -1
  49. package/front_end/panels/timeline/TimelinePaintProfilerView.ts +5 -0
  50. package/front_end/panels/timeline/TimelinePanel.ts +8 -8
  51. package/front_end/ui/legacy/UIUtils.ts +1 -1
  52. package/front_end/ui/legacy/components/perf_ui/.eslintrc.js +18 -0
  53. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +5 -1
  54. package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +5 -2
  55. package/front_end/ui/legacy/components/utils/Linkifier.ts +10 -0
  56. package/package.json +1 -1
  57. package/scripts/build/generate_deprecations.py +3 -0
  58. package/front_end/panels/elements/LayoutSidebarPane.ts +0 -249
  59. package/front_end/panels/sources/BreakpointsSidebarPane.ts +0 -480
  60. package/front_end/ui/components/docs/layout_pane/basic.html +0 -25
  61. package/front_end/ui/components/docs/layout_pane/basic.ts +0 -78
@@ -40,70 +40,87 @@ import {DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js';
40
40
  import {LiveLocationPool, LiveLocationWithPool, type LiveLocation} from './LiveLocation.js';
41
41
  import {CSSWorkspaceBinding} from './CSSWorkspaceBinding.js';
42
42
 
43
- const targetToMessageHelperMap = new WeakMap<SDK.Target.Target, PresentationConsoleMessageHelper>();
43
+ export interface MessageSource {
44
+ url?: Platform.DevToolsPath.UrlString;
45
+ line: number;
46
+ column: number;
47
+ scriptId?: Protocol.Runtime.ScriptId;
48
+ stackTrace?: Protocol.Runtime.StackTrace;
49
+ }
44
50
 
45
- export class PresentationConsoleMessageManager implements
51
+ export class PresentationSourceFrameMessageManager implements
46
52
  SDK.TargetManager.SDKModelObserver<SDK.DebuggerModel.DebuggerModel>,
47
53
  SDK.TargetManager.SDKModelObserver<SDK.CSSModel.CSSModel> {
54
+ #targetToMessageHelperMap = new WeakMap<SDK.Target.Target, PresentationSourceFrameMessageHelper>();
48
55
  constructor() {
49
56
  SDK.TargetManager.TargetManager.instance().observeModels(SDK.DebuggerModel.DebuggerModel, this);
50
57
  SDK.TargetManager.TargetManager.instance().observeModels(SDK.CSSModel.CSSModel, this);
51
-
52
- SDK.TargetManager.TargetManager.instance().addModelListener(
53
- SDK.ConsoleModel.ConsoleModel, SDK.ConsoleModel.Events.ConsoleCleared, this.consoleCleared, this);
54
- SDK.TargetManager.TargetManager.instance().addModelListener(
55
- SDK.ConsoleModel.ConsoleModel, SDK.ConsoleModel.Events.MessageAdded,
56
- event => this.consoleMessageAdded(event.data));
57
- SDK.ConsoleModel.ConsoleModel.allMessagesUnordered().forEach(this.consoleMessageAdded, this);
58
58
  }
59
59
 
60
60
  modelAdded(model: SDK.DebuggerModel.DebuggerModel|SDK.CSSModel.CSSModel): void {
61
61
  const target = model.target();
62
- const helper = targetToMessageHelperMap.get(target) ?? new PresentationConsoleMessageHelper();
62
+ const helper = this.#targetToMessageHelperMap.get(target) ?? new PresentationSourceFrameMessageHelper();
63
63
  if (model instanceof SDK.DebuggerModel.DebuggerModel) {
64
64
  helper.setDebuggerModel(model);
65
65
  } else {
66
66
  helper.setCSSModel(model);
67
67
  }
68
- targetToMessageHelperMap.set(target, helper);
68
+ this.#targetToMessageHelperMap.set(target, helper);
69
69
  }
70
70
 
71
71
  modelRemoved(model: SDK.DebuggerModel.DebuggerModel|SDK.CSSModel.CSSModel): void {
72
72
  const target = model.target();
73
- const helper = targetToMessageHelperMap.get(target);
74
- if (helper) {
75
- helper.consoleCleared();
76
- }
73
+ const helper = this.#targetToMessageHelperMap.get(target);
74
+ helper?.clear();
77
75
  }
78
76
 
79
- private consoleMessageAdded(message: SDK.ConsoleModel.ConsoleMessage): void {
80
- const runtimeModel = message.runtimeModel();
81
- if (!message.isErrorOrWarning() || !message.runtimeModel() ||
82
- message.source === Protocol.Log.LogEntrySource.Violation || !runtimeModel) {
83
- return;
84
- }
85
- const helper = targetToMessageHelperMap.get(runtimeModel.target());
86
- if (helper) {
87
- void helper.consoleMessageAdded(message);
88
- }
77
+ addMessage(message: Workspace.UISourceCode.Message, source: MessageSource, target: SDK.Target.Target): void {
78
+ const helper = this.#targetToMessageHelperMap.get(target);
79
+ void helper?.addMessage(message, source);
89
80
  }
90
81
 
91
- private consoleCleared(): void {
82
+ clear(): void {
92
83
  for (const target of SDK.TargetManager.TargetManager.instance().targets()) {
93
- const helper = targetToMessageHelperMap.get(target);
94
- if (helper) {
95
- helper.consoleCleared();
96
- }
84
+ const helper = this.#targetToMessageHelperMap.get(target);
85
+ helper?.clear();
97
86
  }
98
87
  }
99
88
  }
100
89
 
101
- export class PresentationConsoleMessageHelper {
90
+ export class PresentationConsoleMessageManager {
91
+ #sourceFrameMessageManager = new PresentationSourceFrameMessageManager();
92
+
93
+ constructor() {
94
+ SDK.TargetManager.TargetManager.instance().addModelListener(
95
+ SDK.ConsoleModel.ConsoleModel, SDK.ConsoleModel.Events.MessageAdded,
96
+ event => this.consoleMessageAdded(event.data));
97
+ SDK.ConsoleModel.ConsoleModel.allMessagesUnordered().forEach(this.consoleMessageAdded, this);
98
+ SDK.TargetManager.TargetManager.instance().addModelListener(
99
+ SDK.ConsoleModel.ConsoleModel, SDK.ConsoleModel.Events.ConsoleCleared,
100
+ () => this.#sourceFrameMessageManager.clear());
101
+ }
102
+
103
+ private consoleMessageAdded(consoleMessage: SDK.ConsoleModel.ConsoleMessage): void {
104
+ const runtimeModel = consoleMessage.runtimeModel();
105
+ if (!consoleMessage.isErrorOrWarning() || !consoleMessage.runtimeModel() ||
106
+ consoleMessage.source === Protocol.Log.LogEntrySource.Violation || !runtimeModel) {
107
+ return;
108
+ }
109
+ const level = consoleMessage.level === Protocol.Log.LogEntryLevel.Error ?
110
+ Workspace.UISourceCode.Message.Level.Error :
111
+ Workspace.UISourceCode.Message.Level.Warning;
112
+ this.#sourceFrameMessageManager.addMessage(
113
+ new Workspace.UISourceCode.Message(level, consoleMessage.messageText), consoleMessage, runtimeModel.target());
114
+ }
115
+ }
116
+
117
+ export class PresentationSourceFrameMessageHelper {
102
118
  #debuggerModel?: SDK.DebuggerModel.DebuggerModel;
103
119
  #cssModel?: SDK.CSSModel.CSSModel;
104
- #presentationMessages:
105
- Map<Platform.DevToolsPath.UrlString,
106
- Array<{message: SDK.ConsoleModel.ConsoleMessage, presentation: PresentationConsoleMessage}>> = new Map();
120
+ #presentationMessages: Map<Platform.DevToolsPath.UrlString, Array<{
121
+ source: MessageSource,
122
+ presentation: PresentationSourceFrameMessage,
123
+ }>> = new Map();
107
124
  readonly #locationPool: LiveLocationPool;
108
125
 
109
126
  constructor() {
@@ -136,56 +153,56 @@ export class PresentationConsoleMessageHelper {
136
153
  SDK.CSSModel.Events.StyleSheetAdded, event => queueMicrotask(() => this.#styleSheetAdded(event)));
137
154
  }
138
155
 
139
- async consoleMessageAdded(message: SDK.ConsoleModel.ConsoleMessage): Promise<void> {
140
- const presentation = new PresentationConsoleMessage(message, this.#locationPool);
141
- const location = this.#rawLocation(message) ?? this.#cssLocation(message) ?? this.#uiLocation(message);
156
+ async addMessage(message: Workspace.UISourceCode.Message, source: MessageSource): Promise<void> {
157
+ const presentation = new PresentationSourceFrameMessage(message, this.#locationPool);
158
+ const location = this.#rawLocation(source) ?? this.#cssLocation(source) ?? this.#uiLocation(source);
142
159
  if (location) {
143
160
  await presentation.updateLocationSource(location);
144
161
  }
145
- if (message.url) {
146
- let messages = this.#presentationMessages.get(message.url);
162
+ if (source.url) {
163
+ let messages = this.#presentationMessages.get(source.url);
147
164
  if (!messages) {
148
165
  messages = [];
149
- this.#presentationMessages.set(message.url, messages);
166
+ this.#presentationMessages.set(source.url, messages);
150
167
  }
151
- messages.push({message, presentation});
168
+ messages.push({source, presentation});
152
169
  }
153
170
  }
154
171
 
155
- #uiLocation(message: SDK.ConsoleModel.ConsoleMessage): Workspace.UISourceCode.UILocation|null {
156
- if (!message.url) {
172
+ #uiLocation(source: MessageSource): Workspace.UISourceCode.UILocation|null {
173
+ if (!source.url) {
157
174
  return null;
158
175
  }
159
176
 
160
- const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(message.url);
177
+ const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(source.url);
161
178
  if (!uiSourceCode) {
162
179
  return null;
163
180
  }
164
- return new Workspace.UISourceCode.UILocation(uiSourceCode, message.line, message.column);
181
+ return new Workspace.UISourceCode.UILocation(uiSourceCode, source.line, source.column);
165
182
  }
166
183
 
167
- #cssLocation(message: SDK.ConsoleModel.ConsoleMessage): SDK.CSSModel.CSSLocation|null {
168
- if (!this.#cssModel || !message.url) {
184
+ #cssLocation(source: MessageSource): SDK.CSSModel.CSSLocation|null {
185
+ if (!this.#cssModel || !source.url) {
169
186
  return null;
170
187
  }
171
- const locations = this.#cssModel.createRawLocationsByURL(message.url, message.line, message.column);
188
+ const locations = this.#cssModel.createRawLocationsByURL(source.url, source.line, source.column);
172
189
  return locations[0] ?? null;
173
190
  }
174
191
 
175
- #rawLocation(message: SDK.ConsoleModel.ConsoleMessage): SDK.DebuggerModel.Location|null {
192
+ #rawLocation(source: MessageSource): SDK.DebuggerModel.Location|null {
176
193
  if (!this.#debuggerModel) {
177
194
  return null;
178
195
  }
179
- if (message.scriptId) {
180
- return this.#debuggerModel.createRawLocationByScriptId(message.scriptId, message.line, message.column);
196
+ if (source.scriptId) {
197
+ return this.#debuggerModel.createRawLocationByScriptId(source.scriptId, source.line, source.column);
181
198
  }
182
- const callFrame = message.stackTrace && message.stackTrace.callFrames ? message.stackTrace.callFrames[0] : null;
199
+ const callFrame = source.stackTrace && source.stackTrace.callFrames ? source.stackTrace.callFrames[0] : null;
183
200
  if (callFrame) {
184
201
  return this.#debuggerModel.createRawLocationByScriptId(
185
202
  callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber);
186
203
  }
187
- if (message.url) {
188
- return this.#debuggerModel.createRawLocationByURL(message.url, message.line, message.column);
204
+ if (source.url) {
205
+ return this.#debuggerModel.createRawLocationByURL(source.url, source.line, source.column);
189
206
  }
190
207
  return null;
191
208
  }
@@ -195,8 +212,8 @@ export class PresentationConsoleMessageHelper {
195
212
  const messages = this.#presentationMessages.get(script.sourceURL);
196
213
 
197
214
  const promises: Promise<void>[] = [];
198
- for (const {message, presentation} of messages ?? []) {
199
- const rawLocation = this.#rawLocation(message);
215
+ for (const {presentation, source} of messages ?? []) {
216
+ const rawLocation = this.#rawLocation(source);
200
217
  if (rawLocation && script.scriptId === rawLocation.scriptId) {
201
218
  promises.push(presentation.updateLocationSource(rawLocation));
202
219
  }
@@ -213,9 +230,9 @@ export class PresentationConsoleMessageHelper {
213
230
  const messages = this.#presentationMessages.get(uiSourceCode.url());
214
231
 
215
232
  const promises: Promise<void>[] = [];
216
- for (const {message, presentation} of messages ?? []) {
233
+ for (const {presentation, source} of messages ?? []) {
217
234
  promises.push(presentation.updateLocationSource(
218
- new Workspace.UISourceCode.UILocation(uiSourceCode, message.line, message.column)));
235
+ new Workspace.UISourceCode.UILocation(uiSourceCode, source.line, source.column)));
219
236
  }
220
237
  void Promise.all(promises).then(this.uiSourceCodeAddedForTest.bind(this));
221
238
  }
@@ -229,10 +246,10 @@ export class PresentationConsoleMessageHelper {
229
246
  const messages = this.#presentationMessages.get(header.sourceURL);
230
247
 
231
248
  const promises: Promise<void>[] = [];
232
- for (const {message, presentation} of messages ?? []) {
233
- if (header.containsLocation(message.line, message.column)) {
249
+ for (const {source, presentation} of messages ?? []) {
250
+ if (header.containsLocation(source.line, source.column)) {
234
251
  promises.push(
235
- presentation.updateLocationSource(new SDK.CSSModel.CSSLocation(header, message.line, message.column)));
252
+ presentation.updateLocationSource(new SDK.CSSModel.CSSLocation(header, source.line, source.column)));
236
253
  }
237
254
  }
238
255
  void Promise.all(promises).then(this.styleSheetAddedForTest.bind(this));
@@ -241,7 +258,7 @@ export class PresentationConsoleMessageHelper {
241
258
  styleSheetAddedForTest(): void {
242
259
  }
243
260
 
244
- consoleCleared(): void {
261
+ clear(): void {
245
262
  this.#debuggerReset();
246
263
  }
247
264
 
@@ -273,15 +290,14 @@ class FrozenLiveLocation extends LiveLocationWithPool {
273
290
  }
274
291
  }
275
292
 
276
- export class PresentationConsoleMessage extends Workspace.UISourceCode.Message {
293
+ export class PresentationSourceFrameMessage {
277
294
  #uiSourceCode?: Workspace.UISourceCode.UISourceCode;
278
295
  #liveLocation?: LiveLocation;
279
- #locationPool: LiveLocationPool;
296
+ readonly #locationPool: LiveLocationPool;
297
+ readonly #message: Workspace.UISourceCode.Message;
280
298
 
281
- constructor(message: SDK.ConsoleModel.ConsoleMessage, locationPool: LiveLocationPool) {
282
- const level = message.level === Protocol.Log.LogEntryLevel.Error ? Workspace.UISourceCode.Message.Level.Error :
283
- Workspace.UISourceCode.Message.Level.Warning;
284
- super(level, message.messageText);
299
+ constructor(message: Workspace.UISourceCode.Message, locationPool: LiveLocationPool) {
300
+ this.#message = message;
285
301
  this.#locationPool = locationPool;
286
302
  }
287
303
 
@@ -303,10 +319,10 @@ export class PresentationConsoleMessage extends Workspace.UISourceCode.Message {
303
319
 
304
320
  async #updateLocation(liveLocation: LiveLocation): Promise<void> {
305
321
  if (this.#uiSourceCode) {
306
- this.#uiSourceCode.removeMessage(this);
322
+ this.#uiSourceCode.removeMessage(this.#message);
307
323
  }
308
324
  if (liveLocation !== this.#liveLocation) {
309
- this.#uiSourceCode?.removeMessage(this);
325
+ this.#uiSourceCode?.removeMessage(this.#message);
310
326
  this.#liveLocation?.dispose();
311
327
  this.#liveLocation = liveLocation;
312
328
  }
@@ -314,13 +330,14 @@ export class PresentationConsoleMessage extends Workspace.UISourceCode.Message {
314
330
  if (!uiLocation) {
315
331
  return;
316
332
  }
317
- this.range = TextUtils.TextRange.TextRange.createFromLocation(uiLocation.lineNumber, uiLocation.columnNumber || 0);
333
+ this.#message.range =
334
+ TextUtils.TextRange.TextRange.createFromLocation(uiLocation.lineNumber, uiLocation.columnNumber || 0);
318
335
  this.#uiSourceCode = uiLocation.uiSourceCode;
319
- this.#uiSourceCode.addMessage(this);
336
+ this.#uiSourceCode.addMessage(this.#message);
320
337
  }
321
338
 
322
339
  dispose(): void {
323
- this.#uiSourceCode?.removeMessage(this);
340
+ this.#uiSourceCode?.removeMessage(this.#message);
324
341
  this.#liveLocation?.dispose();
325
342
  }
326
343
  }
@@ -25,6 +25,7 @@ import {QuirksModeIssue} from './QuirksModeIssue.js';
25
25
  import {CookieIssue} from './CookieIssue.js';
26
26
  import {SharedArrayBufferIssue} from './SharedArrayBufferIssue.js';
27
27
  import {SourceFrameIssuesManager} from './SourceFrameIssuesManager.js';
28
+ import {StylesheetLoadingIssue} from './StylesheetLoadingIssue.js';
28
29
 
29
30
  export {Events} from './IssuesManagerEvents.js';
30
31
 
@@ -108,6 +109,10 @@ const issueCodeHandlers = new Map<
108
109
  Protocol.Audits.InspectorIssueCode.BounceTrackingIssue,
109
110
  BounceTrackingIssue.fromInspectorIssue,
110
111
  ],
112
+ [
113
+ Protocol.Audits.InspectorIssueCode.StylesheetLoadingIssue,
114
+ StylesheetLoadingIssue.fromInspectorIssue,
115
+ ],
111
116
  ]);
112
117
 
113
118
  /**
@@ -3,9 +3,7 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import * as Common from '../../core/common/common.js';
6
- import * as SDK from '../../core/sdk/sdk.js';
7
6
  import * as Bindings from '../../models/bindings/bindings.js';
8
- import * as TextUtils from '../../models/text_utils/text_utils.js';
9
7
  import * as Workspace from '../../models/workspace/workspace.js';
10
8
 
11
9
  import {
@@ -19,10 +17,10 @@ import {type IssueAddedEvent, type IssuesManager} from './IssuesManager.js';
19
17
  import {Events} from './IssuesManagerEvents.js';
20
18
  import {getIssueTitleFromMarkdownDescription} from './MarkdownIssueDescription.js';
21
19
 
22
- export class SourceFrameIssuesManager {
23
- #locationPool = new Bindings.LiveLocation.LiveLocationPool();
24
- #issueMessages = new Array<IssueMessage>();
20
+ import {lateImportStylesheetLoadingCode, type StylesheetLoadingIssue} from './StylesheetLoadingIssue.js';
25
21
 
22
+ export class SourceFrameIssuesManager {
23
+ #sourceFrameMessageManager = new Bindings.PresentationConsoleMessageHelper.PresentationSourceFrameMessageManager();
26
24
  constructor(private readonly issuesManager: IssuesManager) {
27
25
  this.issuesManager.addEventListener(Events.IssueAdded, this.#onIssueAdded, this);
28
26
  this.issuesManager.addEventListener(Events.FullUpdateRequired, this.#onFullUpdateRequired, this);
@@ -30,47 +28,44 @@ export class SourceFrameIssuesManager {
30
28
 
31
29
  #onIssueAdded(event: Common.EventTarget.EventTargetEvent<IssueAddedEvent>): void {
32
30
  const {issue} = event.data;
33
- this.#addIssue(issue);
31
+ void this.#addIssue(issue);
34
32
  }
35
33
 
36
- #addIssue(issue: Issue): void {
37
- if (!this.#isTrustedTypeIssue(issue)) {
34
+ async #addIssue(issue: Issue): Promise<void> {
35
+ if (!this.#isTrustedTypeIssue(issue) && !this.#isLateImportIssue(issue)) {
38
36
  return;
39
37
  }
40
38
  const issuesModel = issue.model();
41
39
  if (!issuesModel) {
42
40
  return;
43
41
  }
44
- const debuggerModel = issuesModel.target().model(SDK.DebuggerModel.DebuggerModel);
45
42
  const srcLocation = toZeroBasedLocation(issue.details().sourceCodeLocation);
46
- if (srcLocation && debuggerModel) {
47
- const rawLocation =
48
- debuggerModel.createRawLocationByURL(srcLocation.url, srcLocation.lineNumber, srcLocation.columnNumber);
49
- if (rawLocation) {
50
- void this.#addIssueMessageToScript(issue, rawLocation);
51
- }
43
+ const description = issue.getDescription();
44
+ if (!description || !srcLocation) {
45
+ return;
46
+ }
47
+ const messageText = await getIssueTitleFromMarkdownDescription(description);
48
+ if (!messageText) {
49
+ return;
52
50
  }
51
+ const clickHandler = (): void => {
52
+ void Common.Revealer.reveal(issue);
53
+ };
54
+ this.#sourceFrameMessageManager.addMessage(
55
+ new IssueMessage(messageText, issue.getKind(), clickHandler), {
56
+ line: srcLocation.lineNumber,
57
+ column: srcLocation.columnNumber ?? -1,
58
+ url: srcLocation.url,
59
+ scriptId: srcLocation.scriptId,
60
+ },
61
+ issuesModel.target());
53
62
  }
54
63
 
55
64
  #onFullUpdateRequired(): void {
56
65
  this.#resetMessages();
57
66
  const issues = this.issuesManager.issues();
58
67
  for (const issue of issues) {
59
- this.#addIssue(issue);
60
- }
61
- }
62
-
63
- async #addIssueMessageToScript(issue: Issue, rawLocation: SDK.DebuggerModel.Location): Promise<void> {
64
- const description = issue.getDescription();
65
- if (description) {
66
- const title = await getIssueTitleFromMarkdownDescription(description);
67
- if (title) {
68
- const clickHandler = (): void => {
69
- void Common.Revealer.reveal(issue);
70
- };
71
- this.#issueMessages.push(
72
- new IssueMessage(title, issue.getKind(), rawLocation, this.#locationPool, clickHandler));
73
- }
68
+ void this.#addIssue(issue);
74
69
  }
75
70
  }
76
71
 
@@ -79,48 +74,23 @@ export class SourceFrameIssuesManager {
79
74
  issue.code() === trustedTypesPolicyViolationCode;
80
75
  }
81
76
 
77
+ #isLateImportIssue(issue: Issue): issue is StylesheetLoadingIssue {
78
+ return issue.code() === lateImportStylesheetLoadingCode;
79
+ }
80
+
82
81
  #resetMessages(): void {
83
- for (const message of this.#issueMessages) {
84
- message.dispose();
85
- }
86
- this.#issueMessages = [];
87
- this.#locationPool.disposeAll();
82
+ this.#sourceFrameMessageManager.clear();
88
83
  }
89
84
  }
90
85
 
91
86
  export class IssueMessage extends Workspace.UISourceCode.Message {
92
- #uiSourceCode?: Workspace.UISourceCode.UISourceCode = undefined;
93
87
  #kind: IssueKind;
94
-
95
- constructor(
96
- title: string, kind: IssueKind, rawLocation: SDK.DebuggerModel.Location,
97
- locationPool: Bindings.LiveLocation.LiveLocationPool, clickHandler: () => void) {
88
+ constructor(title: string, kind: IssueKind, clickHandler: () => void) {
98
89
  super(Workspace.UISourceCode.Message.Level.Issue, title, clickHandler);
99
90
  this.#kind = kind;
100
- void Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createLiveLocation(
101
- rawLocation, this.#updateLocation.bind(this), locationPool);
102
- }
103
-
104
- async #updateLocation(liveLocation: Bindings.LiveLocation.LiveLocation): Promise<void> {
105
- if (this.#uiSourceCode) {
106
- this.#uiSourceCode.removeMessage(this);
107
- }
108
- const uiLocation = await liveLocation.uiLocation();
109
- if (!uiLocation) {
110
- return;
111
- }
112
- this.range = TextUtils.TextRange.TextRange.createFromLocation(uiLocation.lineNumber, uiLocation.columnNumber || 0);
113
- this.#uiSourceCode = uiLocation.uiSourceCode;
114
- this.#uiSourceCode.addMessage(this);
115
91
  }
116
92
 
117
93
  getIssueKind(): IssueKind {
118
94
  return this.#kind;
119
95
  }
120
-
121
- dispose(): void {
122
- if (this.#uiSourceCode) {
123
- this.#uiSourceCode.removeMessage(this);
124
- }
125
- }
126
96
  }
@@ -0,0 +1,69 @@
1
+ // Copyright 2023 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Protocol from '../../generated/protocol.js';
6
+ import type * as SDK from '../../core/sdk/sdk.js';
7
+
8
+ import {Issue, IssueCategory, IssueKind} from './Issue.js';
9
+ import {type MarkdownIssueDescription} from './MarkdownIssueDescription.js';
10
+
11
+ export const lateImportStylesheetLoadingCode = [
12
+ Protocol.Audits.InspectorIssueCode.StylesheetLoadingIssue,
13
+ Protocol.Audits.StyleSheetLoadingIssueReason.LateImportRule,
14
+ ].join('::');
15
+
16
+ export class StylesheetLoadingIssue extends Issue {
17
+ #issueDetails: Protocol.Audits.StylesheetLoadingIssueDetails;
18
+ constructor(issueDetails: Protocol.Audits.StylesheetLoadingIssueDetails, issuesModel: SDK.IssuesModel.IssuesModel) {
19
+ const code =
20
+ `${Protocol.Audits.InspectorIssueCode.StylesheetLoadingIssue}::${issueDetails.styleSheetLoadingIssueReason}`;
21
+ super(code, issuesModel);
22
+ this.#issueDetails = issueDetails;
23
+ }
24
+
25
+ override sources(): Array<Protocol.Audits.SourceCodeLocation> {
26
+ return [this.#issueDetails.sourceCodeLocation];
27
+ }
28
+
29
+ details(): Protocol.Audits.StylesheetLoadingIssueDetails {
30
+ return this.#issueDetails;
31
+ }
32
+
33
+ primaryKey(): string {
34
+ return JSON.stringify(this.#issueDetails);
35
+ }
36
+
37
+ getDescription(): MarkdownIssueDescription {
38
+ switch (this.#issueDetails.styleSheetLoadingIssueReason) {
39
+ case Protocol.Audits.StyleSheetLoadingIssueReason.LateImportRule:
40
+ return {
41
+ file: 'stylesheetLateImport.md',
42
+ links: [],
43
+ };
44
+ case Protocol.Audits.StyleSheetLoadingIssueReason.RequestFailed:
45
+ return {
46
+ file: 'stylesheetRequestFailed.md',
47
+ links: [],
48
+ };
49
+ }
50
+ }
51
+
52
+ getCategory(): IssueCategory {
53
+ return IssueCategory.Other;
54
+ }
55
+
56
+ getKind(): IssueKind {
57
+ return IssueKind.PageError;
58
+ }
59
+
60
+ static fromInspectorIssue(issueModel: SDK.IssuesModel.IssuesModel, inspectorIssue: Protocol.Audits.InspectorIssue):
61
+ StylesheetLoadingIssue[] {
62
+ const stylesheetLoadingDetails = inspectorIssue.details.stylesheetLoadingIssueDetails;
63
+ if (!stylesheetLoadingDetails) {
64
+ console.warn('Stylesheet loading issue without details received');
65
+ return [];
66
+ }
67
+ return [new StylesheetLoadingIssue(stylesheetLoadingDetails, issueModel)];
68
+ }
69
+ }
@@ -0,0 +1,4 @@
1
+ # Define @import rules at the top of the stylesheet
2
+
3
+ An @import rule was ignored because it wasn't defined at the top of the stylesheet. Such rules must appear at the top,
4
+ before any style declaration and any other at-rule with the exception of @charset and @layer.
@@ -0,0 +1,3 @@
1
+ # Verify stylesheet URLs
2
+
3
+ This page failed to load a stylesheet from a URL.
@@ -24,6 +24,7 @@ import * as QuirksModeIssue from './QuirksModeIssue.js';
24
24
  import * as RelatedIssue from './RelatedIssue.js';
25
25
  import * as SharedArrayBufferIssue from './SharedArrayBufferIssue.js';
26
26
  import * as SourceFrameIssuesManager from './SourceFrameIssuesManager.js';
27
+ import * as StylesheetLoadingIssue from './StylesheetLoadingIssue.js';
27
28
 
28
29
  export {
29
30
  AttributionReportingIssue,
@@ -48,4 +49,5 @@ export {
48
49
  RelatedIssue,
49
50
  SharedArrayBufferIssue,
50
51
  SourceFrameIssuesManager,
52
+ StylesheetLoadingIssue,
51
53
  };
@@ -1161,6 +1161,10 @@ export class TimelineModelImpl {
1161
1161
 
1162
1162
  case RecordType.DisplayItemListSnapshot:
1163
1163
  case RecordType.PictureSnapshot: {
1164
+ // If we get a snapshot, we try to find the last Paint event for the
1165
+ // current layer, and store the snapshot as the relevant picture for
1166
+ // that event, thus creating a relationship between the snapshot and
1167
+ // the last Paint event for the current timestamp.
1164
1168
  const layerUpdateEvent = this.findAncestorEvent(RecordType.UpdateLayer);
1165
1169
  if (!layerUpdateEvent || layerUpdateEvent.args['layerTreeId'] !== this.mainFrameLayerTreeId) {
1166
1170
  break;
@@ -29,6 +29,7 @@ export const ENABLED_TRACE_HANDLERS = {
29
29
  LayoutShifts: Handlers.ModelHandlers.LayoutShifts,
30
30
  Screenshots: Handlers.ModelHandlers.Screenshots,
31
31
  GPU: Handlers.ModelHandlers.GPU,
32
+ NetworkRequests: Handlers.ModelHandlers.NetworkRequests,
32
33
  };
33
34
  export type PartialTraceParseDataDuringMigration =
34
35
  Readonly<Handlers.Types.EnabledHandlerDataWithMeta<typeof ENABLED_TRACE_HANDLERS>>;