chrome-devtools-frontend 1.0.1515796 → 1.0.1515988

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 (129) hide show
  1. package/docs/contributing/infrastructure.md +131 -82
  2. package/front_end/Tests.js +3 -29
  3. package/front_end/core/common/Progress.ts +73 -55
  4. package/front_end/core/host/UserMetrics.ts +0 -1
  5. package/front_end/core/protocol_client/InspectorBackend.ts +2 -0
  6. package/front_end/core/root/Runtime.ts +0 -1
  7. package/front_end/core/sdk/CSSMatchedStyles.ts +12 -10
  8. package/front_end/core/sdk/CSSModel.ts +1 -31
  9. package/front_end/core/sdk/CSSPropertyParserMatchers.ts +27 -7
  10. package/front_end/core/sdk/DebuggerModel.ts +1 -31
  11. package/front_end/core/sdk/EnhancedTracesParser.ts +81 -50
  12. package/front_end/core/sdk/NetworkManager.ts +1 -31
  13. package/front_end/core/sdk/NetworkRequest.ts +1 -31
  14. package/front_end/core/sdk/RehydratingConnection.snapshot.txt +1003 -0
  15. package/front_end/core/sdk/RehydratingConnection.ts +13 -18
  16. package/front_end/core/sdk/RehydratingObject.ts +8 -31
  17. package/front_end/core/sdk/RemoteObject.ts +1 -31
  18. package/front_end/core/sdk/ResourceTreeModel.ts +1 -31
  19. package/front_end/core/sdk/RuntimeModel.ts +1 -31
  20. package/front_end/core/sdk/ServiceWorkerManager.ts +1 -31
  21. package/front_end/core/sdk/SourceMap.ts +1 -31
  22. package/front_end/core/sdk/TraceObject.ts +8 -3
  23. package/front_end/entrypoints/main/MainImpl.ts +0 -2
  24. package/front_end/models/ai_assistance/AiHistoryStorage.ts +1 -3
  25. package/front_end/models/ai_assistance/ConversationHandler.ts +4 -6
  26. package/front_end/models/ai_assistance/agents/AiAgent.ts +4 -1
  27. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +107 -72
  28. package/front_end/models/ai_assistance/agents/PerformanceAnnotationsAgent.ts +2 -2
  29. package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
  30. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +178 -85
  31. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +308 -218
  32. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +100 -100
  33. package/front_end/models/ai_assistance/data_formatters/UnitFormatters.ts +10 -1
  34. package/front_end/models/ai_assistance/performance/AIContext.ts +19 -21
  35. package/front_end/models/bindings/ContentProviderBasedProject.ts +6 -4
  36. package/front_end/models/breakpoints/BreakpointManager.ts +3 -3
  37. package/front_end/models/har/Writer.ts +11 -11
  38. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +3 -3
  39. package/front_end/models/persistence/IsolatedFileSystem.ts +4 -4
  40. package/front_end/models/persistence/IsolatedFileSystemManager.ts +7 -7
  41. package/front_end/models/persistence/PersistenceImpl.ts +8 -8
  42. package/front_end/models/persistence/PlatformFileSystem.ts +1 -1
  43. package/front_end/models/trace/ModelImpl.ts +2 -16
  44. package/front_end/models/trace/Processor.ts +15 -9
  45. package/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +4 -4
  46. package/front_end/models/trace/handlers/FramesHandler.ts +2 -2
  47. package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +7 -10
  48. package/front_end/models/trace/handlers/MetaHandler.ts +11 -9
  49. package/front_end/models/trace/handlers/ScreenshotsHandler.ts +1 -1
  50. package/front_end/models/trace/handlers/ScriptsHandler.ts +5 -5
  51. package/front_end/models/trace/handlers/UserInteractionsHandler.ts +2 -14
  52. package/front_end/models/trace/handlers/UserTimingsHandler.ts +3 -4
  53. package/front_end/models/trace/insights/CLSCulprits.ts +1 -1
  54. package/front_end/models/trace/insights/DocumentLatency.ts +3 -4
  55. package/front_end/models/trace/insights/DuplicatedJavaScript.ts +1 -1
  56. package/front_end/models/trace/insights/INPBreakdown.ts +1 -1
  57. package/front_end/models/trace/insights/ImageDelivery.ts +1 -1
  58. package/front_end/models/trace/insights/LCPBreakdown.ts +1 -1
  59. package/front_end/models/trace/insights/LCPDiscovery.ts +1 -1
  60. package/front_end/models/trace/insights/ModernHTTP.ts +1 -1
  61. package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -1
  62. package/front_end/models/trace/insights/RenderBlocking.ts +1 -1
  63. package/front_end/models/trace/insights/types.ts +2 -0
  64. package/front_end/models/trace/types/TraceEvents.ts +41 -64
  65. package/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +1 -1
  66. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +21 -99
  67. package/front_end/panels/application/ServiceWorkersView.ts +0 -1
  68. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +2 -3
  69. package/front_end/panels/common/GdpSignUpDialog.ts +6 -3
  70. package/front_end/panels/console/ConsoleView.ts +23 -28
  71. package/front_end/panels/console/ConsoleViewport.ts +2 -2
  72. package/front_end/panels/console/consoleView.css +11 -1
  73. package/front_end/panels/coverage/CoverageView.ts +2 -2
  74. package/front_end/panels/elements/ElementsTreeOutline.ts +2 -2
  75. package/front_end/panels/elements/StyleEditorWidget.ts +8 -19
  76. package/front_end/panels/elements/StylePropertyTreeElement.ts +39 -25
  77. package/front_end/panels/elements/StylesSidebarPane.ts +2 -2
  78. package/front_end/panels/elements/stylePropertiesTreeOutline.css +4 -3
  79. package/front_end/panels/layer_viewer/Layers3DView.ts +2 -2
  80. package/front_end/panels/layers/LayerTreeModel.ts +3 -3
  81. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +4 -4
  82. package/front_end/panels/network/NetworkLogView.ts +1 -1
  83. package/front_end/panels/network/NetworkLogViewColumns.ts +3 -3
  84. package/front_end/panels/network/NetworkSearchScope.ts +6 -6
  85. package/front_end/panels/search/SearchView.ts +33 -32
  86. package/front_end/panels/settings/components/SyncSection.ts +6 -1
  87. package/front_end/panels/sources/SourcesSearchScope.ts +4 -4
  88. package/front_end/panels/sources/TabbedEditorContainer.ts +5 -5
  89. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +10 -5
  90. package/front_end/panels/timeline/TimelineFlameChartView.ts +18 -15
  91. package/front_end/panels/timeline/TimelinePanel.ts +41 -22
  92. package/front_end/panels/timeline/TracingLayerTree.ts +4 -5
  93. package/front_end/panels/timeline/components/ExportTraceOptions.ts +37 -22
  94. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +17 -7
  95. package/front_end/third_party/axe-core/README.chromium +1 -0
  96. package/front_end/third_party/codemirror/README.chromium +1 -0
  97. package/front_end/third_party/codemirror.next/README.chromium +1 -0
  98. package/front_end/third_party/csp_evaluator/README.chromium +1 -0
  99. package/front_end/third_party/diff/README.chromium +1 -0
  100. package/front_end/third_party/i18n/README.chromium +1 -0
  101. package/front_end/third_party/intl-messageformat/README.chromium +1 -0
  102. package/front_end/third_party/json5/README.chromium +1 -0
  103. package/front_end/third_party/legacy-javascript/README.chromium +1 -0
  104. package/front_end/third_party/lighthouse/README.chromium +1 -0
  105. package/front_end/third_party/lit/README.chromium +1 -0
  106. package/front_end/third_party/marked/README.chromium +1 -0
  107. package/front_end/third_party/puppeteer-replay/README.chromium +1 -0
  108. package/front_end/third_party/third-party-web/README.chromium +1 -0
  109. package/front_end/third_party/vscode.web-custom-data/README.chromium +1 -0
  110. package/front_end/third_party/wasmparser/README.chromium +1 -0
  111. package/front_end/third_party/web-vitals/README.chromium +1 -0
  112. package/front_end/ui/components/tooltips/Tooltip.ts +17 -1
  113. package/front_end/ui/legacy/ContextMenu.ts +2 -2
  114. package/front_end/ui/legacy/GlassPane.ts +7 -3
  115. package/front_end/ui/legacy/ProgressIndicator.ts +29 -16
  116. package/front_end/ui/legacy/TabbedPane.ts +2 -2
  117. package/front_end/ui/legacy/Treeoutline.ts +10 -5
  118. package/front_end/ui/legacy/UIUtils.ts +42 -10
  119. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +14 -14
  120. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +6 -6
  121. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +3 -29
  122. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +14 -14
  123. package/front_end/ui/visual_logging/KnownContextValues.ts +2 -0
  124. package/inspector_overlay/highlight_common.ts +1 -27
  125. package/inspector_overlay/highlight_grid_common.ts +1 -27
  126. package/inspector_overlay/tool_highlight.ts +1 -27
  127. package/inspector_overlay/tool_persistent.ts +1 -27
  128. package/inspector_overlay/tool_source_order.ts +1 -27
  129. package/package.json +1 -1
@@ -21,6 +21,7 @@ import {
21
21
  BinOpMatcher,
22
22
  ColorMatcher,
23
23
  ColorMixMatcher,
24
+ CustomFunctionMatcher,
24
25
  defaultValueForCSSType,
25
26
  EnvFunctionMatcher,
26
27
  FlexGridMatcher,
@@ -934,6 +935,7 @@ export class CSSMatchedStyles {
934
935
  new PositionTryMatcher(),
935
936
  new LengthMatcher(),
936
937
  new MathFunctionMatcher(),
938
+ new CustomFunctionMatcher(),
937
939
  new AutoBaseMatcher(),
938
940
  new BinOpMatcher(),
939
941
  new RelativeColorChannelMatcher(),
@@ -1263,11 +1265,11 @@ class DOMInheritanceCascade {
1263
1265
  if (!nodeCascade) {
1264
1266
  return null;
1265
1267
  }
1266
- return this.innerComputeCSSVariable(nodeCascade, variableName);
1268
+ return this.#computeCSSVariable(nodeCascade, variableName);
1267
1269
  }
1268
1270
 
1269
- private innerComputeCSSVariable(nodeCascade: NodeCascade, variableName: string, sccRecord = new SCCRecord()):
1270
- CSSVariableValue|null {
1271
+ #computeCSSVariable(nodeCascade: NodeCascade, variableName: string, sccRecord = new SCCRecord()): CSSVariableValue
1272
+ |null {
1271
1273
  const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
1272
1274
  const computedCSSVariables = this.#computedCSSVariables.get(nodeCascade);
1273
1275
  if (!computedCSSVariables || !availableCSSVariables?.has(variableName)) {
@@ -1303,7 +1305,7 @@ class DOMInheritanceCascade {
1303
1305
  return null;
1304
1306
  }
1305
1307
 
1306
- return this.innerWalkTree(
1308
+ return this.#walkTree(
1307
1309
  nodeCascade, ast, definedValue.declaration.style, variableName, sccRecord, definedValue.declaration) as
1308
1310
  CSSVariableValue |
1309
1311
  null;
@@ -1315,7 +1317,7 @@ class DOMInheritanceCascade {
1315
1317
  if (!nodeCascade) {
1316
1318
  return null;
1317
1319
  }
1318
- return this.innerComputeAttribute(nodeCascade, style, attributeName, type, new SCCRecord());
1320
+ return this.#computeAttribute(nodeCascade, style, attributeName, type, new SCCRecord());
1319
1321
  }
1320
1322
 
1321
1323
  private attributeValueAsType(style: CSSStyleDeclaration, attributeName: string, type: string): string|null {
@@ -1336,10 +1338,10 @@ class DOMInheritanceCascade {
1336
1338
  if (!ast) {
1337
1339
  return null;
1338
1340
  }
1339
- return this.innerWalkTree(nodeCascade, ast, style, `attr(${attributeName})`, sccRecord)?.value ?? null;
1341
+ return this.#walkTree(nodeCascade, ast, style, `attr(${attributeName})`, sccRecord)?.value ?? null;
1340
1342
  }
1341
1343
 
1342
- private innerComputeAttribute(
1344
+ #computeAttribute(
1343
1345
  nodeCascade: NodeCascade, style: CSSStyleDeclaration, attributeName: string, type: CSSType,
1344
1346
  sccRecord = new SCCRecord()): string|null {
1345
1347
  if (type.isCSSTokens) {
@@ -1352,7 +1354,7 @@ class DOMInheritanceCascade {
1352
1354
  return this.attributeValueAsType(style, attributeName, type.type);
1353
1355
  }
1354
1356
 
1355
- private innerWalkTree(
1357
+ #walkTree(
1356
1358
  outerNodeCascade: NodeCascade, ast: SyntaxTree, parentStyle: CSSStyleDeclaration, substitutionName: string,
1357
1359
  sccRecord: SCCRecord, declaration?: CSSValueSource): CSSVariableValue|CSSAttributeValue|null {
1358
1360
  const record = sccRecord.add(outerNodeCascade, substitutionName);
@@ -1370,7 +1372,7 @@ class DOMInheritanceCascade {
1370
1372
  const matching = PropertyParser.BottomUpTreeMatching.walk(ast, [
1371
1373
  new BaseVariableMatcher(match => {
1372
1374
  const {value, mayFallback} = recurseWithCycleDetection(
1373
- match.name, nodeCascade => this.innerComputeCSSVariable(nodeCascade, match.name, sccRecord)?.value ?? null);
1375
+ match.name, nodeCascade => this.#computeCSSVariable(nodeCascade, match.name, sccRecord)?.value ?? null);
1374
1376
  if (!mayFallback || value !== null) {
1375
1377
  return value;
1376
1378
  }
@@ -1581,7 +1583,7 @@ class DOMInheritanceCascade {
1581
1583
  for (const variableName of variableNames) {
1582
1584
  const prevValue = accumulatedCSSVariables.get(variableName);
1583
1585
  accumulatedCSSVariables.delete(variableName);
1584
- const computedValue = this.innerComputeCSSVariable(nodeCascade, variableName);
1586
+ const computedValue = this.#computeCSSVariable(nodeCascade, variableName);
1585
1587
  if (prevValue && computedValue?.value === prevValue.value) {
1586
1588
  computedValue.declaration = prevValue.declaration;
1587
1589
  }
@@ -1,37 +1,7 @@
1
- // Copyright 2021 The Chromium Authors
1
+ // Copyright 2010 The Chromium Authors
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
- /*
6
- * Copyright (C) 2010 Google Inc. All rights reserved.
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are
10
- * met:
11
- *
12
- * * Redistributions of source code must retain the above copyright
13
- * notice, this list of conditions and the following disclaimer.
14
- * * Redistributions in binary form must reproduce the above
15
- * copyright notice, this list of conditions and the following disclaimer
16
- * in the documentation and/or other materials provided with the
17
- * distribution.
18
- * * Neither the #name of Google Inc. nor the names of its
19
- * contributors may be used to endorse or promote products derived from
20
- * this software without specific prior written permission.
21
- *
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
- */
34
-
35
5
  import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
36
6
  import type * as Protocol from '../../generated/protocol.js';
37
7
  import * as TextUtils from '../../models/text_utils/text_utils.js';
@@ -709,7 +709,6 @@ export const enum LinkableNameProperties {
709
709
  FONT_PALETTE = 'font-palette',
710
710
  POSITION_TRY_FALLBACKS = 'position-try-fallbacks',
711
711
  POSITION_TRY = 'position-try',
712
- FUNCTION = 'function', // Not a property; we use it to mark user defined functions.
713
712
  }
714
713
 
715
714
  const enum AnimationLonghandPart {
@@ -819,10 +818,6 @@ export class LinkableNameMatcher extends matcherBase(LinkableNameMatch) {
819
818
  return null;
820
819
  }
821
820
 
822
- if (parentNode.name === 'CallExpression' && node.name === 'VariableName') {
823
- return new LinkableNameMatch(text, node, LinkableNameProperties.FUNCTION);
824
- }
825
-
826
821
  if (!(propertyName && LinkableNameMatcher.isLinkableNameProperty(propertyName))) {
827
822
  return null;
828
823
  }
@@ -987,12 +982,14 @@ export const enum ArithmeticFunction {
987
982
  }
988
983
  type MathFunction = SelectFunction|ArithmeticFunction;
989
984
 
990
- export class MathFunctionMatch implements Match {
985
+ export class BaseFunctionMatch<T extends string> implements Match {
991
986
  constructor(
992
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly func: MathFunction,
987
+ readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly func: T,
993
988
  readonly args: CodeMirror.SyntaxNode[][]) {
994
989
  }
990
+ }
995
991
 
992
+ export class MathFunctionMatch extends BaseFunctionMatch<MathFunction> {
996
993
  isArithmeticFunctionCall(): boolean {
997
994
  const func = this.func as ArithmeticFunction;
998
995
  switch (func) {
@@ -1048,6 +1045,29 @@ export class MathFunctionMatcher extends matcherBase(MathFunctionMatch) {
1048
1045
  }
1049
1046
  }
1050
1047
 
1048
+ export class CustomFunctionMatch extends BaseFunctionMatch<string> {}
1049
+
1050
+ // clang-format off
1051
+ export class CustomFunctionMatcher extends matcherBase(CustomFunctionMatch) {
1052
+ // clang-format on
1053
+
1054
+ override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): CustomFunctionMatch|null {
1055
+ if (node.name !== 'CallExpression') {
1056
+ return null;
1057
+ }
1058
+ const callee = matching.ast.text(node.getChild('VariableName'));
1059
+ if (!callee?.startsWith('--')) {
1060
+ return null;
1061
+ }
1062
+ const args = ASTUtils.callArgs(node);
1063
+ if (args.some(arg => arg.length === 0 || matching.hasUnresolvedSubstitutionsRange(arg[0], arg[arg.length - 1]))) {
1064
+ return null;
1065
+ }
1066
+ const text = matching.ast.text(node);
1067
+ return new CustomFunctionMatch(text, node, callee, args);
1068
+ }
1069
+ }
1070
+
1051
1071
  export class FlexGridMatch implements Match {
1052
1072
  constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly isFlex: boolean) {
1053
1073
  }
@@ -1,37 +1,7 @@
1
- // Copyright 2021 The Chromium Authors
1
+ // Copyright 2010 The Chromium Authors
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
- /*
6
- * Copyright (C) 2010 Google Inc. All rights reserved.
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are
10
- * met:
11
- *
12
- * * Redistributions of source code must retain the above copyright
13
- * notice, this list of conditions and the following disclaimer.
14
- * * Redistributions in binary form must reproduce the above
15
- * copyright notice, this list of conditions and the following disclaimer
16
- * in the documentation and/or other materials provided with the
17
- * distribution.
18
- * * Neither the #name of Google Inc. nor the names of its
19
- * contributors may be used to endorse or promote products derived from
20
- * this software without specific prior written permission.
21
- *
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
- */
34
-
35
5
  import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
36
6
  import * as Protocol from '../../generated/protocol.js';
37
7
  import * as Common from '../common/common.js';
@@ -8,61 +8,87 @@ import type * as Platform from '../platform/platform.js';
8
8
  import {UserVisibleError} from '../platform/platform.js';
9
9
 
10
10
  import type {
11
- HydratingDataPerTarget, RehydratingExecutionContext, RehydratingScript, RehydratingTarget, TraceFile} from
11
+ HydratingDataPerTarget, RehydratingExecutionContext, RehydratingScript, RehydratingTarget} from
12
12
  './RehydratingObject.js';
13
13
  import type {SourceMapV3} from './SourceMap.js';
14
+ import type {TraceObject} from './TraceObject.js';
14
15
 
15
- interface RehydratingTraceBase {
16
+ interface EventBase {
16
17
  cat: string;
17
18
  pid: number;
18
19
  args: {data: object};
19
20
  name: string;
20
21
  }
21
22
 
22
- interface TraceEventTargetRundown extends RehydratingTraceBase {
23
+ /**
24
+ * While called 'TargetRundown', this event is emitted for each script that is compiled or evaluated.
25
+ * Within EnhancedTraceParser, this event is used to construct targets and execution contexts (and to associate scripts to frames).
26
+ *
27
+ * See `inspector_target_rundown_event::Data` https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/inspector/inspector_trace_events.cc;l=1189-1232;drc=48d6f7175422b2c969c14258f9f8d5b196c28d18
28
+ */
29
+ export interface RundownScriptCompiled extends EventBase {
23
30
  cat: 'disabled-by-default-devtools.target-rundown';
31
+ name: 'ScriptCompiled'|'ModuleEvaluated';
24
32
  args: {
25
33
  data: {
26
34
  frame: Protocol.Page.FrameId,
27
- frameType: string,
35
+ frameType: 'page'|'iframe',
28
36
  url: string,
29
- isolate: string,
37
+ /**
38
+ * isolate is a `uint64_t`, which is too much for JS number to represent exactly.
39
+ * TODO: consider adjusting the trace event impl to either string or reduced precision. see https://crrev.com/c/6300647
40
+ * This applies for all `isolate` in trace events we consume.
41
+ */
42
+ isolate: number,
43
+ /** AKA V8ContextToken. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/inspector/inspector_trace_events.cc;l=1229;drc=3c88f61e18b043e70c225d8d57c77832a85e7f58 */
30
44
  v8context: string,
31
45
  origin: string,
32
46
  scriptId: number,
47
+ /** script->World().isMainWorld() */
33
48
  isDefault?: boolean,
34
- contextType?: string,
49
+ contextType?: 'default'|'isolated'|'worker',
35
50
  },
36
51
  };
37
52
  }
38
-
39
- interface TraceEventScriptRundown extends RehydratingTraceBase {
53
+ /**
54
+ * When profiling starts, all currently loaded scripts are emitted via this event.
55
+ *
56
+ * See `Script::TraceScriptRundown()` https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/script.cc;l=184-220;drc=328f6c467b940f322544567740c9c871064d045c
57
+ */
58
+ export interface RundownScript extends EventBase {
40
59
  cat: 'disabled-by-default-devtools.v8-source-rundown';
60
+ name: 'ScriptCatchup';
41
61
  args: {
42
62
  data: {
43
- isolate: string,
63
+ isolate: number,
44
64
  executionContextId: Protocol.Runtime.ExecutionContextId,
45
65
  scriptId: number,
46
- // These don't actually get set in v8.
47
- url: string,
48
- hash: string,
49
66
  isModule: boolean,
67
+ /** aka HasSourceURLComment */
50
68
  hasSourceUrl: boolean,
69
+ // These don't actually get set in v8.
70
+ url?: string,
71
+ hash?: string,
72
+ /** value of the sourceURL comment. */
73
+ sourceUrl?: string,
74
+ /* value of the sourceMappingURL comment */
75
+ sourceMapUrl?: string,
76
+ /** If true, the source map url was a data URL, so the `sourceMapUrl` was removed. */
77
+ sourceMapUrlElided?: boolean,
51
78
  startLine?: number,
52
79
  startColumn?: number,
53
80
  endLine?: number,
54
81
  endColumn?: number,
55
- sourceUrl?: string,
56
- sourceMapUrl?: string,
57
82
  },
58
83
  };
59
84
  }
60
85
 
61
- interface TraceEventScriptRundownSource extends RehydratingTraceBase {
86
+ export interface RundownScriptSource extends EventBase {
62
87
  cat: 'disabled-by-default-devtools.v8-source-rundown-sources';
88
+ name: 'ScriptCatchup'|'LargeScriptCatchup'|'TooLargeScriptCatchup';
63
89
  args: {
64
90
  data: {
65
- isolate: string,
91
+ isolate: number,
66
92
  scriptId: number,
67
93
  length?: number,
68
94
  sourceText?: string,
@@ -70,7 +96,7 @@ interface TraceEventScriptRundownSource extends RehydratingTraceBase {
70
96
  };
71
97
  }
72
98
 
73
- interface TraceEventTracingStartedInBrowser extends RehydratingTraceBase {
99
+ interface TracingStartedInBrowser extends EventBase {
74
100
  cat: 'disabled-by-default-devtools.timeline';
75
101
  args: {
76
102
  data: {
@@ -87,20 +113,20 @@ interface TraceEventTracingStartedInBrowser extends RehydratingTraceBase {
87
113
  };
88
114
  }
89
115
 
90
- interface TraceEventFunctionCall extends RehydratingTraceBase {
116
+ interface FunctionCall extends EventBase {
91
117
  cat: 'devtools.timeline';
92
118
  args: {
93
119
  data: {
94
120
  frame: Protocol.Page.FrameId,
95
121
  scriptId: Protocol.Runtime.ScriptId,
96
- isolate?: string,
122
+ isolate?: number,
97
123
  },
98
124
  };
99
125
  }
100
126
 
101
127
  export class EnhancedTracesParser {
102
- #trace: TraceFile;
103
- #scriptRundownEvents: TraceEventScriptRundown[] = [];
128
+ #trace: TraceObject;
129
+ #scriptRundownEvents: RundownScript[] = [];
104
130
  #scriptToV8Context: Map<string, string> = new Map<string, string>();
105
131
  #scriptToFrame: Map<string, Protocol.Page.FrameId> = new Map<string, Protocol.Page.FrameId>();
106
132
  #scriptToScriptSource: Map<string, string> = new Map<string, string>();
@@ -111,7 +137,7 @@ export class EnhancedTracesParser {
111
137
  #scripts: RehydratingScript[] = [];
112
138
  static readonly enhancedTraceVersion: number = 1;
113
139
 
114
- constructor(trace: TraceFile) {
140
+ constructor(trace: TraceObject) {
115
141
  this.#trace = trace;
116
142
 
117
143
  // Initialize with the trace provided.
@@ -124,7 +150,7 @@ export class EnhancedTracesParser {
124
150
 
125
151
  parseEnhancedTrace(): void {
126
152
  for (const event of this.#trace.traceEvents) {
127
- if (this.isTracingStartInBrowserEvent(event)) {
153
+ if (this.isTracingStartedInBrowser(event)) {
128
154
  // constructs all targets by devtools.timeline TracingStartedInBrowser
129
155
  const data = event.args?.data;
130
156
  for (const frame of data.frames) {
@@ -148,7 +174,7 @@ export class EnhancedTracesParser {
148
174
  if (data.isolate) {
149
175
  this.#scriptToFrame.set(this.getScriptIsolateId(data.isolate, data.scriptId), data.frame);
150
176
  }
151
- } else if (this.isTargetRundownEvent(event)) {
177
+ } else if (this.isRundownScriptCompiled(event)) {
152
178
  // Set up script to v8 context mapping
153
179
  const data = event.args?.data;
154
180
  this.#scriptToV8Context.set(this.getScriptIsolateId(data.isolate, data.scriptId), data.v8context);
@@ -159,7 +185,7 @@ export class EnhancedTracesParser {
159
185
  this.#targets.push({
160
186
  targetId: frameId,
161
187
  type: data.frameType,
162
- isolate: data.isolate,
188
+ isolate: String(data.isolate),
163
189
  pid: event.pid,
164
190
  url: data.url,
165
191
  });
@@ -175,33 +201,36 @@ export class EnhancedTracesParser {
175
201
  isDefault: data.isDefault,
176
202
  type: data.contextType,
177
203
  },
178
- isolate: data.isolate,
204
+ isolate: String(data.isolate),
205
+ name: data.origin,
206
+ uniqueId: `${data.v8context}-${data.isolate}`,
179
207
  });
180
208
  }
181
- } else if (this.isScriptRundownEvent(event)) {
209
+ } else if (this.isRundownScript(event)) {
182
210
  this.#scriptRundownEvents.push(event);
183
211
  const data = event.args.data;
184
212
  // Add script
185
213
  if (!this.#scripts.find(
186
- script => script.scriptId === String(data.scriptId) && script.isolate === data.isolate)) {
214
+ script => script.scriptId === String(data.scriptId) && script.isolate === String(data.isolate))) {
187
215
  this.#scripts.push({
188
216
  scriptId: String(data.scriptId) as Protocol.Runtime.ScriptId,
189
- isolate: data.isolate,
217
+ isolate: String(data.isolate),
218
+ buildId: '',
190
219
  executionContextId: data.executionContextId,
191
220
  startLine: data.startLine ?? 0,
192
221
  startColumn: data.startColumn ?? 0,
193
222
  endLine: data.endLine ?? 0,
194
223
  endColumn: data.endColumn ?? 0,
195
- hash: data.hash,
224
+ hash: data.hash ?? '',
196
225
  isModule: data.isModule,
197
- url: data.url,
226
+ url: data.url ?? '',
198
227
  hasSourceURL: data.hasSourceUrl,
199
- sourceURL: data.sourceUrl,
228
+ sourceURL: data.sourceUrl ?? '',
200
229
  sourceMapURL: data.sourceMapUrl,
201
230
  pid: event.pid,
202
231
  });
203
232
  }
204
- } else if (this.isScriptRundownSourceEvent(event)) {
233
+ } else if (this.isRundownScriptSource(event)) {
205
234
  // Set up script to source text and length mapping
206
235
  const data = event.args.data;
207
236
  const scriptIsolateId = this.getScriptIsolateId(data.isolate, data.scriptId);
@@ -262,10 +291,10 @@ export class EnhancedTracesParser {
262
291
  const linkedExecutionContext = this.#executionContexts.find(
263
292
  context => context.id === script.executionContextId && context.isolate === script.isolate);
264
293
  if (linkedExecutionContext) {
265
- script.auxData = linkedExecutionContext.auxData;
294
+ script.executionContextAuxData = linkedExecutionContext.auxData;
266
295
  // If a script successfully mapped to an execution context and aux data, link script to frame
267
- if (script.auxData?.frameId) {
268
- this.#scriptToFrame.set(scriptIsolateId, script.auxData?.frameId);
296
+ if (script.executionContextAuxData?.frameId) {
297
+ this.#scriptToFrame.set(scriptIsolateId, script.executionContextAuxData?.frameId);
269
298
  }
270
299
  }
271
300
  });
@@ -335,38 +364,38 @@ export class EnhancedTracesParser {
335
364
  return sourceMap;
336
365
  }
337
366
 
338
- private getScriptIsolateId(isolate: string, scriptId: Protocol.Runtime.ScriptId|number): string {
339
- return scriptId + '@' + isolate;
367
+ private getScriptIsolateId(isolate: number|string, scriptId: Protocol.Runtime.ScriptId|number): string {
368
+ return `${scriptId}@${isolate}`;
340
369
  }
341
370
 
342
- private getExecutionContextIsolateId(isolate: string, executionContextId: Protocol.Runtime.ExecutionContextId):
371
+ private getExecutionContextIsolateId(isolate: number|string, executionContextId: Protocol.Runtime.ExecutionContextId):
343
372
  string {
344
- return executionContextId + '@' + isolate;
373
+ return `${executionContextId}@${isolate}`;
345
374
  }
346
375
 
347
- private isTraceEvent(event: unknown): event is RehydratingTraceBase {
348
- return 'cat' in (event as RehydratingTraceBase) && 'pid' in (event as RehydratingTraceBase) &&
349
- 'args' in (event as RehydratingTraceBase) && 'data' in (event as RehydratingTraceBase).args;
376
+ private isTraceEvent(event: unknown): event is EventBase {
377
+ return 'cat' in (event as EventBase) && 'pid' in (event as EventBase) && 'args' in (event as EventBase) &&
378
+ 'data' in (event as EventBase).args;
350
379
  }
351
380
 
352
- private isTargetRundownEvent(event: unknown): event is TraceEventTargetRundown {
381
+ private isRundownScriptCompiled(event: unknown): event is RundownScriptCompiled {
353
382
  return this.isTraceEvent(event) && event.cat === 'disabled-by-default-devtools.target-rundown';
354
383
  }
355
384
 
356
- private isScriptRundownEvent(event: unknown): event is TraceEventScriptRundown {
385
+ private isRundownScript(event: unknown): event is RundownScript {
357
386
  return this.isTraceEvent(event) && event.cat === 'disabled-by-default-devtools.v8-source-rundown';
358
387
  }
359
388
 
360
- private isScriptRundownSourceEvent(event: unknown): event is TraceEventScriptRundownSource {
389
+ private isRundownScriptSource(event: unknown): event is RundownScriptSource {
361
390
  return this.isTraceEvent(event) && event.cat === 'disabled-by-default-devtools.v8-source-rundown-sources';
362
391
  }
363
392
 
364
- private isTracingStartInBrowserEvent(event: unknown): event is TraceEventTracingStartedInBrowser {
393
+ private isTracingStartedInBrowser(event: unknown): event is TracingStartedInBrowser {
365
394
  return this.isTraceEvent(event) && event.cat === 'disabled-by-default-devtools.timeline' &&
366
395
  event.name === 'TracingStartedInBrowser';
367
396
  }
368
397
 
369
- private isFunctionCallEvent(event: unknown): event is TraceEventFunctionCall {
398
+ private isFunctionCallEvent(event: unknown): event is FunctionCall {
370
399
  return this.isTraceEvent(event) && event.cat === 'devtools.timeline' && event.name === 'FunctionCall';
371
400
  }
372
401
 
@@ -408,8 +437,8 @@ export class EnhancedTracesParser {
408
437
  for (const script of scripts) {
409
438
  const scriptExecutionContextIsolateId =
410
439
  this.getExecutionContextIsolateId(script.isolate, script.executionContextId);
411
- const scriptFrameId = script.auxData?.frameId as string as Protocol.Target.TargetID;
412
- if (script.auxData?.frameId && targetIds.has(scriptFrameId)) {
440
+ const scriptFrameId = script.executionContextAuxData?.frameId as string as Protocol.Target.TargetID;
441
+ if (script.executionContextAuxData?.frameId && targetIds.has(scriptFrameId)) {
413
442
  targetToScripts.get(scriptFrameId)?.push(script);
414
443
  executionContextIsolateToTarget.set(scriptExecutionContextIsolateId, scriptFrameId);
415
444
  } else if (this.#scriptToFrame.has(this.getScriptIsolateId(script.isolate, script.scriptId))) {
@@ -457,12 +486,14 @@ export class EnhancedTracesParser {
457
486
  id: script.executionContextId,
458
487
  origin: '',
459
488
  v8Context: '',
489
+ name: '',
460
490
  auxData: {
461
491
  frameId: targetId as string as Protocol.Page.FrameId,
462
492
  isDefault: false,
463
493
  type: 'type',
464
494
  },
465
495
  isolate: script.isolate,
496
+ uniqueId: `${targetId}-${script.isolate}`,
466
497
  };
467
498
  executionContexts.push(artificialContext);
468
499
  }
@@ -1,37 +1,7 @@
1
- // Copyright 2021 The Chromium Authors
1
+ // Copyright 2011 The Chromium Authors
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
- /*
6
- * Copyright (C) 2011 Google Inc. All rights reserved.
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are
10
- * met:
11
- *
12
- * * Redistributions of source code must retain the above copyright
13
- * notice, this list of conditions and the following disclaimer.
14
- * * Redistributions in binary form must reproduce the above
15
- * copyright notice, this list of conditions and the following disclaimer
16
- * in the documentation and/or other materials provided with the
17
- * distribution.
18
- * * Neither the #name of Google Inc. nor the names of its
19
- * contributors may be used to endorse or promote products derived from
20
- * this software without specific prior written permission.
21
- *
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
- */
34
-
35
5
  import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
36
6
  import * as Protocol from '../../generated/protocol.js';
37
7
  import * as TextUtils from '../../models/text_utils/text_utils.js';
@@ -1,37 +1,7 @@
1
- // Copyright 2021 The Chromium Authors
1
+ // Copyright 2012 The Chromium Authors
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
- /*
6
- * Copyright (C) 2012 Google Inc. All rights reserved.
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are
10
- * met:
11
- *
12
- * * Redistributions of source code must retain the above copyright
13
- * notice, this list of conditions and the following disclaimer.
14
- * * Redistributions in binary form must reproduce the above
15
- * copyright notice, this list of conditions and the following disclaimer
16
- * in the documentation and/or other materials provided with the
17
- * distribution.
18
- * * Neither the #name of Google Inc. nor the names of its
19
- * contributors may be used to endorse or promote products derived from
20
- * this software without specific prior written permission.
21
- *
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
- */
34
-
35
5
  import * as Protocol from '../../generated/protocol.js';
36
6
  import * as TextUtils from '../../models/text_utils/text_utils.js';
37
7
  import * as Common from '../common/common.js';