chrome-devtools-frontend 1.0.1000934 → 1.0.1002543

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 (187) hide show
  1. package/config/gni/devtools_grd_files.gni +4 -3
  2. package/front_end/.eslintrc.js +1 -0
  3. package/front_end/core/common/ParsedURL.ts +3 -3
  4. package/front_end/core/host/InspectorFrontendHost.ts +30 -1
  5. package/front_end/core/i18n/locales/en-US.json +177 -12
  6. package/front_end/core/i18n/locales/en-XL.json +177 -12
  7. package/front_end/core/protocol_client/InspectorBackend.ts +4 -0
  8. package/front_end/core/root/Runtime.ts +7 -3
  9. package/front_end/core/sdk/ServiceWorkerManager.ts +6 -5
  10. package/front_end/entrypoints/formatter_worker/FormatterActions.ts +14 -0
  11. package/front_end/entrypoints/formatter_worker/ScopeParser.ts +491 -0
  12. package/front_end/entrypoints/formatter_worker/Substitute.ts +4 -440
  13. package/front_end/entrypoints/formatter_worker/formatter_worker.ts +2 -0
  14. package/front_end/generated/InspectorBackendCommands.js +38 -10
  15. package/front_end/generated/protocol-mapping.d.ts +5 -1
  16. package/front_end/generated/protocol-proxy-api.d.ts +4 -1
  17. package/front_end/generated/protocol.ts +50 -10
  18. package/front_end/models/bindings/BreakpointManager.ts +12 -11
  19. package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
  20. package/front_end/models/issues_manager/AttributionReportingIssue.ts +5 -36
  21. package/front_end/models/issues_manager/DeprecationIssue.ts +233 -257
  22. package/front_end/models/issues_manager/Issue.ts +8 -4
  23. package/front_end/models/persistence/PersistenceImpl.ts +2 -2
  24. package/front_end/models/timeline_model/TimelineModel.ts +0 -48
  25. package/front_end/panels/application/AppManifestView.ts +3 -3
  26. package/front_end/panels/application/ApplicationPanelCacheSection.ts +3 -1
  27. package/front_end/panels/application/ApplicationPanelSidebar.ts +11 -6
  28. package/front_end/panels/application/ApplicationPanelTreeElement.ts +2 -2
  29. package/front_end/panels/application/BackgroundServiceView.ts +5 -4
  30. package/front_end/panels/application/ResourcesPanel.ts +1 -1
  31. package/front_end/panels/application/components/BackForwardCacheView.ts +4 -5
  32. package/front_end/panels/application/components/FrameDetailsView.ts +19 -19
  33. package/front_end/panels/application/components/PermissionsPolicySection.ts +2 -2
  34. package/front_end/panels/console/ConsoleViewMessage.ts +6 -3
  35. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +1 -1
  36. package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +3 -2
  37. package/front_end/panels/css_overview/cssOverviewCompletedView.css +4 -0
  38. package/front_end/panels/elements/StylePropertyTreeElement.ts +19 -13
  39. package/front_end/panels/elements/StylesSidebarPane.ts +53 -0
  40. package/front_end/panels/elements/components/QueryContainer.ts +1 -1
  41. package/front_end/panels/issues/AffectedResourcesView.ts +4 -3
  42. package/front_end/panels/issues/AffectedSourcesView.ts +2 -1
  43. package/front_end/panels/issues/AttributionReportingIssueDetailsView.ts +0 -43
  44. package/front_end/panels/issues/IssueView.ts +1 -1
  45. package/front_end/panels/lighthouse/LighthouseController.ts +5 -3
  46. package/front_end/panels/lighthouse/LighthouseReporterTypes.ts +2 -1
  47. package/front_end/panels/lighthouse/lighthousePanel.css +4 -0
  48. package/front_end/panels/network/components/RequestTrustTokensView.ts +7 -7
  49. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +2 -2
  50. package/front_end/panels/profiler/HeapSnapshotView.ts +2 -1
  51. package/front_end/panels/profiler/ProfileDataGrid.ts +1 -1
  52. package/front_end/panels/security/SecurityPanel.ts +6 -5
  53. package/front_end/panels/settings/SettingsScreen.ts +2 -3
  54. package/front_end/panels/sources/DebuggerPlugin.ts +10 -9
  55. package/front_end/panels/sources/JavaScriptBreakpointsSidebarPane.ts +3 -3
  56. package/front_end/panels/timeline/PerformanceModel.ts +2 -6
  57. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +1 -14
  58. package/front_end/panels/timeline/TimelineUIUtils.ts +14 -12
  59. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1036 -1088
  60. package/front_end/third_party/lighthouse/locales/en-US.json +241 -4
  61. package/front_end/third_party/lighthouse/locales/en-XL.json +241 -4
  62. package/front_end/third_party/lighthouse/report/bundle.d.ts +2 -0
  63. package/front_end/third_party/lighthouse/report/bundle.js +18 -12
  64. package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
  65. package/front_end/third_party/puppeteer/package/README.md +11 -11
  66. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Debug.d.ts.map +1 -1
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Debug.js +26 -2
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Debug.js.map +1 -1
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.d.ts.map +1 -1
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js +7 -0
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js.map +1 -1
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts +2 -2
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js +19 -11
  75. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js.map +1 -1
  76. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.d.ts +2 -2
  77. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.d.ts.map +1 -1
  78. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.js +6 -2
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.js.map +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.d.ts +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.js +1 -1
  82. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/compat.d.ts +3 -0
  83. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/compat.d.ts.map +1 -0
  84. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/compat.js +18 -0
  85. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/compat.js.map +1 -0
  86. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/constants.d.ts +2 -0
  87. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/constants.d.ts.map +1 -0
  88. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/constants.js +7 -0
  89. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/constants.js.map +1 -0
  90. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.d.ts +2 -0
  91. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.d.ts.map +1 -0
  92. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.js +5 -0
  93. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.js.map +1 -0
  94. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/initialize-node.d.ts.map +1 -1
  95. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/initialize-node.js +2 -15
  96. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/initialize-node.js.map +1 -1
  97. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.d.ts +1 -1
  98. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.d.ts.map +1 -1
  99. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.js +23 -15
  100. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.js.map +1 -1
  101. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.d.ts.map +1 -1
  102. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js +1 -0
  103. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.d.ts +1 -1
  105. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.d.ts.map +1 -1
  106. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.js +17 -3
  107. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.js.map +1 -1
  108. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/install.d.ts.map +1 -1
  109. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/install.js +1 -6
  110. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/install.js.map +1 -1
  111. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +1 -1
  112. package/front_end/third_party/puppeteer/package/lib/esm/package.json +1 -0
  113. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Debug.d.ts.map +1 -1
  114. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Debug.js +3 -2
  115. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Debug.js.map +1 -1
  116. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.d.ts.map +1 -1
  117. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js +7 -0
  118. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js.map +1 -1
  119. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts +2 -2
  120. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  121. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js +19 -11
  122. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js.map +1 -1
  123. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.d.ts +2 -2
  124. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.d.ts.map +1 -1
  125. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.js +6 -2
  126. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.js.map +1 -1
  127. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.d.ts +1 -1
  128. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.js +1 -1
  129. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/compat.d.ts +3 -0
  130. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/compat.d.ts.map +1 -0
  131. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/compat.js +17 -0
  132. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/compat.js.map +1 -0
  133. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/constants.d.ts +2 -0
  134. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/constants.d.ts.map +1 -0
  135. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/constants.js +4 -0
  136. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/constants.js.map +1 -0
  137. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.d.ts +2 -0
  138. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.d.ts.map +1 -0
  139. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.js +2 -0
  140. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.js.map +1 -0
  141. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/initialize-node.d.ts.map +1 -1
  142. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/initialize-node.js +2 -15
  143. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/initialize-node.js.map +1 -1
  144. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.d.ts +1 -1
  145. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.d.ts.map +1 -1
  146. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js +21 -13
  147. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js.map +1 -1
  148. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.d.ts.map +1 -1
  149. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js +1 -0
  150. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js.map +1 -1
  151. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.d.ts +1 -1
  152. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.d.ts.map +1 -1
  153. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.js +17 -3
  154. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.js.map +1 -1
  155. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.d.ts.map +1 -1
  156. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.js +1 -6
  157. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.js.map +1 -1
  158. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +1 -1
  159. package/front_end/third_party/puppeteer/package/lib/types.d.ts +6 -6
  160. package/front_end/third_party/puppeteer/package/package.json +33 -18
  161. package/front_end/third_party/puppeteer/puppeteer-tsconfig.json +4 -1
  162. package/front_end/ui/components/data_grid/DataGrid.ts +1 -1
  163. package/front_end/ui/components/data_grid/DataGridUtils.ts +1 -1
  164. package/front_end/ui/components/docs/linkifier/simple-url.ts +2 -1
  165. package/front_end/ui/components/docs/panel_feedback/basic.ts +3 -2
  166. package/front_end/ui/components/docs/panel_feedback/button.ts +2 -1
  167. package/front_end/ui/components/linkifier/LinkifierImpl.ts +4 -3
  168. package/front_end/ui/components/linkifier/LinkifierUtils.ts +2 -3
  169. package/front_end/ui/components/panel_feedback/FeedbackButton.ts +4 -6
  170. package/front_end/ui/components/panel_feedback/PanelFeedback.ts +5 -4
  171. package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +4 -4
  172. package/front_end/ui/legacy/EmptyWidget.ts +2 -1
  173. package/front_end/ui/legacy/UIUtils.ts +4 -4
  174. package/front_end/ui/legacy/XLink.ts +12 -13
  175. package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +2 -4
  176. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +1 -1
  177. package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +0 -2
  178. package/front_end/ui/legacy/components/utils/ImagePreview.ts +3 -7
  179. package/front_end/ui/legacy/components/utils/Linkifier.ts +23 -23
  180. package/front_end/ui/legacy/toolbar.css +1 -1
  181. package/front_end/ui/lit-html/lit-html.ts +3 -0
  182. package/package.json +1 -1
  183. package/scripts/eslint_rules/lib/lit_template_result_or_nothing.js +4 -0
  184. package/scripts/eslint_rules/tests/lit_template_result_or_nothing_test.js +13 -0
  185. package/front_end/models/issues_manager/descriptions/arInvalidAttributionSourceEventId.md +0 -3
  186. package/front_end/models/issues_manager/descriptions/arInvalidAttributionSourceExpiry.md +0 -4
  187. package/front_end/models/issues_manager/descriptions/arInvalidAttributionSourcePriority.md +0 -4
@@ -5,6 +5,8 @@
5
5
  import * as Acorn from '../../third_party/acorn/acorn.js';
6
6
 
7
7
  import {ECMA_VERSION} from './AcornTokenizer.js';
8
+ import {DefinitionKind} from './FormatterActions.js';
9
+ import {ScopeVariableAnalysis} from './ScopeParser.js';
8
10
 
9
11
  export function substituteExpression(expression: string, nameMap: Map<string, string>): string {
10
12
  const replacements = computeSubstitution(expression, nameMap);
@@ -26,8 +28,8 @@ function computeSubstitution(expression: string, nameMap: Map<string, string>):
26
28
  // Parse the expression and find variables and scopes.
27
29
  const root = Acorn.parse(expression, {ecmaVersion: ECMA_VERSION, allowAwaitOutsideFunction: true, ranges: false}) as
28
30
  Acorn.ESTree.Node;
29
- const scopeVariables = new ScopeVariableAnalysis();
30
- scopeVariables.processNode(root);
31
+ const scopeVariables = new ScopeVariableAnalysis(root);
32
+ scopeVariables.run();
31
33
  const freeVariables = scopeVariables.getFreeVariables();
32
34
  const result: Replacement[] = [];
33
35
 
@@ -101,441 +103,3 @@ function applySubstitution(expression: string, replacements: Replacement[]): str
101
103
  accumulator.push(expression.slice(last));
102
104
  return accumulator.join('');
103
105
  }
104
-
105
- interface Use {
106
- offset: number;
107
- scope: Scope;
108
- isShorthandAssignmentProperty: boolean;
109
- }
110
-
111
- const enum DefinitionKind {
112
- None = 0,
113
- Let = 1,
114
- Var = 2,
115
- Fixed = 3,
116
- }
117
-
118
- interface VariableUses {
119
- definitionKind: DefinitionKind;
120
- uses: Use[];
121
- }
122
-
123
- class Scope {
124
- readonly variables = new Map<string, VariableUses>();
125
- readonly parent: Scope|null;
126
-
127
- constructor(parent: Scope|null) {
128
- this.parent = parent;
129
- }
130
-
131
- addVariable(name: string, offset: number, definitionKind: DefinitionKind, isShorthandAssignmentProperty: boolean):
132
- void {
133
- const variable = this.variables.get(name);
134
- const use = {offset, scope: this, isShorthandAssignmentProperty};
135
- if (!variable) {
136
- this.variables.set(name, {definitionKind, uses: [use]});
137
- return;
138
- }
139
- if (variable.definitionKind === DefinitionKind.None) {
140
- variable.definitionKind = definitionKind;
141
- }
142
- variable.uses.push(use);
143
- }
144
-
145
- findBinders(name: string): VariableUses[] {
146
- const result = [];
147
- let scope: Scope|null = this;
148
- while (scope !== null) {
149
- const defUse = scope.variables.get(name);
150
- if (defUse && defUse.definitionKind !== DefinitionKind.None) {
151
- result.push(defUse);
152
- }
153
- scope = scope.parent;
154
- }
155
- return result;
156
- }
157
-
158
- #mergeChildDefUses(name: string, defUses: VariableUses): void {
159
- const variable = this.variables.get(name);
160
- if (!variable) {
161
- this.variables.set(name, defUses);
162
- return;
163
- }
164
- variable.uses.push(...defUses.uses);
165
- if (defUses.definitionKind === DefinitionKind.Var) {
166
- console.assert(variable.definitionKind !== DefinitionKind.Let);
167
- if (variable.definitionKind === DefinitionKind.None) {
168
- variable.definitionKind = defUses.definitionKind;
169
- }
170
- } else {
171
- console.assert(defUses.definitionKind === DefinitionKind.None);
172
- }
173
- }
174
-
175
- finalizeToParent(isFunctionScope: boolean): void {
176
- if (!this.parent) {
177
- console.error('Internal error: wrong nesting in scope analysis.');
178
- throw new Error('Internal error');
179
- }
180
-
181
- // Move all unbound variables to the parent (also move var-bound variables
182
- // if the parent is not a function).
183
- const keysToRemove = [];
184
- for (const [name, defUse] of this.variables.entries()) {
185
- if (defUse.definitionKind === DefinitionKind.None ||
186
- (defUse.definitionKind === DefinitionKind.Var && !isFunctionScope)) {
187
- this.parent.#mergeChildDefUses(name, defUse);
188
- keysToRemove.push(name);
189
- }
190
- }
191
- keysToRemove.forEach(k => this.variables.delete(k));
192
- }
193
- }
194
-
195
- class ScopeVariableAnalysis {
196
- readonly #rootScope = new Scope(null);
197
- readonly #allNames = new Set<string>();
198
- #currentScope = this.#rootScope;
199
-
200
- processNode(node: Acorn.ESTree.Node|null): void {
201
- if (node === null) {
202
- return;
203
- }
204
- switch (node.type) {
205
- case 'AwaitExpression':
206
- this.processNode(node.argument);
207
- break;
208
- case 'ArrayExpression':
209
- node.elements.forEach(item => this.processNode(item));
210
- break;
211
- case 'ExpressionStatement':
212
- this.processNode(node.expression);
213
- break;
214
- case 'Program':
215
- console.assert(this.#currentScope === this.#rootScope);
216
- node.body.forEach(item => this.processNode(item));
217
- console.assert(this.#currentScope === this.#rootScope);
218
- break;
219
- case 'ArrayPattern':
220
- node.elements.forEach(item => this.processNode(item));
221
- break;
222
- case 'ArrowFunctionExpression':
223
- this.#pushScope();
224
- node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.Var));
225
- this.processNode(node.body);
226
- this.#popScope(true);
227
- break;
228
- case 'AssignmentExpression':
229
- case 'AssignmentPattern':
230
- case 'BinaryExpression':
231
- case 'LogicalExpression':
232
- this.processNode(node.left);
233
- this.processNode(node.right);
234
- break;
235
- case 'BlockStatement':
236
- this.#pushScope();
237
- node.body.forEach(this.processNode.bind(this));
238
- this.#popScope(false);
239
- break;
240
- case 'CallExpression':
241
- this.processNode(node.callee);
242
- node.arguments.forEach(this.processNode.bind(this));
243
- break;
244
- case 'VariableDeclaration': {
245
- const definitionKind = node.kind === 'var' ? DefinitionKind.Var : DefinitionKind.Let;
246
- node.declarations.forEach(this.#processVariableDeclarator.bind(this, definitionKind));
247
- break;
248
- }
249
- case 'CatchClause':
250
- this.#pushScope();
251
- this.#processNodeAsDefinition(DefinitionKind.Let, node.param);
252
- node.body.body.forEach(this.processNode.bind(this));
253
- this.#popScope(false);
254
- break;
255
- case 'ClassBody':
256
- node.body.forEach(this.processNode.bind(this));
257
- break;
258
- case 'ClassDeclaration':
259
- this.#processNodeAsDefinition(DefinitionKind.Let, node.id);
260
- this.#pushScope();
261
- this.processNode(node.superClass ?? null);
262
- this.processNode(node.body);
263
- this.#popScope(false);
264
- break;
265
- case 'ClassExpression':
266
- this.#pushScope();
267
- // Intentionally ignore the id.
268
- this.processNode(node.superClass ?? null);
269
- this.processNode(node.body);
270
- this.#popScope(false);
271
- break;
272
- case 'ChainExpression':
273
- this.processNode(node.expression);
274
- break;
275
- case 'ConditionalExpression':
276
- this.processNode(node.test);
277
- this.processNode(node.consequent);
278
- this.processNode(node.alternate);
279
- break;
280
- case 'DoWhileStatement':
281
- this.processNode(node.body);
282
- this.processNode(node.test);
283
- break;
284
- case 'ForInStatement':
285
- case 'ForOfStatement':
286
- this.#pushScope();
287
- this.processNode(node.left);
288
- this.processNode(node.right);
289
- this.processNode(node.body);
290
- this.#popScope(false);
291
- break;
292
- case 'ForStatement':
293
- this.#pushScope();
294
- this.processNode(node.init ?? null);
295
- this.processNode(node.test ?? null);
296
- this.processNode(node.update ?? null);
297
- this.processNode(node.body);
298
- this.#popScope(false);
299
- break;
300
- case 'FunctionDeclaration':
301
- this.#processNodeAsDefinition(DefinitionKind.Var, node.id);
302
- this.#pushScope();
303
- this.#addVariable('this', node.start, DefinitionKind.Fixed);
304
- this.#addVariable('arguments', node.start, DefinitionKind.Fixed);
305
- node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.Let));
306
- this.processNode(node.body);
307
- this.#popScope(true);
308
- break;
309
- case 'FunctionExpression':
310
- // Id is intentionally ignored in function expressions.
311
- this.#pushScope();
312
- this.#addVariable('this', node.start, DefinitionKind.Fixed);
313
- this.#addVariable('arguments', node.start, DefinitionKind.Fixed);
314
- node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.Let));
315
- this.processNode(node.body);
316
- this.#popScope(true);
317
- break;
318
- case 'Identifier':
319
- this.#addVariable(node.name, node.start);
320
- break;
321
- case 'IfStatement':
322
- this.processNode(node.test);
323
- this.processNode(node.consequent);
324
- this.processNode(node.alternate ?? null);
325
- break;
326
- case 'LabeledStatement':
327
- this.processNode(node.body);
328
- break;
329
- case 'MetaProperty':
330
- break;
331
- case 'MethodDefinition':
332
- if (node.computed) {
333
- this.processNode(node.key);
334
- }
335
- this.processNode(node.value);
336
- break;
337
- case 'NewExpression':
338
- this.processNode(node.callee);
339
- node.arguments.forEach(this.processNode.bind(this));
340
- break;
341
- case 'MemberExpression':
342
- this.processNode(node.object);
343
- if (node.computed) {
344
- this.processNode(node.property);
345
- }
346
- break;
347
- case 'ObjectExpression':
348
- node.properties.forEach(this.processNode.bind(this));
349
- break;
350
- case 'ObjectPattern':
351
- node.properties.forEach(this.processNode.bind(this));
352
- break;
353
- case 'PrivateIdentifier':
354
- break;
355
- case 'PropertyDefinition':
356
- if (node.computed) {
357
- this.processNode(node.key);
358
- }
359
- this.processNode(node.value ?? null);
360
- break;
361
- case 'Property':
362
- if (node.shorthand) {
363
- console.assert(node.value === node.key);
364
- console.assert(node.value.type === 'Identifier');
365
- this.#addVariable((node.value as Acorn.ESTree.Identifier).name, node.value.start, DefinitionKind.None, true);
366
- } else {
367
- if (node.computed) {
368
- this.processNode(node.key);
369
- }
370
- this.processNode(node.value);
371
- }
372
- break;
373
- case 'RestElement':
374
- this.#processNodeAsDefinition(DefinitionKind.Let, node.argument);
375
- break;
376
- case 'ReturnStatement':
377
- this.processNode(node.argument ?? null);
378
- break;
379
- case 'SequenceExpression':
380
- node.expressions.forEach(this.processNode.bind(this));
381
- break;
382
- case 'SpreadElement':
383
- this.processNode(node.argument);
384
- break;
385
- case 'SwitchCase':
386
- this.processNode(node.test ?? null);
387
- node.consequent.forEach(this.processNode.bind(this));
388
- break;
389
- case 'SwitchStatement':
390
- this.processNode(node.discriminant);
391
- node.cases.forEach(this.processNode.bind(this));
392
- break;
393
- case 'TaggedTemplateExpression':
394
- this.processNode(node.tag);
395
- this.processNode(node.quasi);
396
- break;
397
- case 'TemplateLiteral':
398
- node.expressions.forEach(this.processNode.bind(this));
399
- break;
400
- case 'ThisExpression':
401
- this.#addVariable('this', node.start);
402
- break;
403
- case 'ThrowStatement':
404
- this.processNode(node.argument);
405
- break;
406
- case 'TryStatement':
407
- this.processNode(node.block);
408
- this.processNode(node.handler ?? null);
409
- this.processNode(node.finalizer ?? null);
410
- break;
411
- case 'WithStatement':
412
- this.processNode(node.object);
413
- // TODO jarin figure how to treat the with body.
414
- this.processNode(node.body);
415
- break;
416
- case 'YieldExpression':
417
- this.processNode(node.argument ?? null);
418
- break;
419
- case 'UnaryExpression':
420
- case 'UpdateExpression':
421
- this.processNode(node.argument);
422
- break;
423
- case 'WhileStatement':
424
- this.processNode(node.test);
425
- this.processNode(node.body);
426
- break;
427
-
428
- // Ignore, no expressions involved.
429
- case 'BreakStatement':
430
- case 'ContinueStatement':
431
- case 'DebuggerStatement':
432
- case 'EmptyStatement':
433
- case 'Literal':
434
- case 'Super':
435
- case 'TemplateElement':
436
- break;
437
- // Ignore, cannot be used outside of a module.
438
- case 'ImportDeclaration':
439
- case 'ImportDefaultSpecifier':
440
- case 'ImportNamespaceSpecifier':
441
- case 'ImportSpecifier':
442
- case 'ImportExpression':
443
- case 'ExportAllDeclaration':
444
- case 'ExportDefaultDeclaration':
445
- case 'ExportNamedDeclaration':
446
- case 'ExportSpecifier':
447
- break;
448
-
449
- case 'VariableDeclarator':
450
- console.error('Should not encounter VariableDeclarator in general traversal.');
451
- break;
452
- }
453
- }
454
-
455
- getFreeVariables(): Map<string, Use[]> {
456
- const result = new Map<string, Use[]>();
457
- for (const [name, defUse] of this.#rootScope.variables) {
458
- if (defUse.definitionKind !== DefinitionKind.None) {
459
- // Skip bound variables.
460
- continue;
461
- }
462
- result.set(name, defUse.uses);
463
- }
464
- return result;
465
- }
466
-
467
- getAllNames(): Set<string> {
468
- return this.#allNames;
469
- }
470
-
471
- #pushScope(): void {
472
- this.#currentScope = new Scope(this.#currentScope);
473
- }
474
-
475
- #popScope(isFunctionContext: boolean): void {
476
- if (this.#currentScope.parent === null) {
477
- console.error('Internal error: wrong nesting in scope analysis.');
478
- throw new Error('Internal error');
479
- }
480
- this.#currentScope.finalizeToParent(isFunctionContext);
481
- this.#currentScope = this.#currentScope.parent;
482
- }
483
-
484
- #addVariable(
485
- name: string, offset: number, definitionKind: DefinitionKind = DefinitionKind.None,
486
- isShorthandAssignmentProperty: boolean = false): void {
487
- this.#allNames.add(name);
488
- this.#currentScope.addVariable(name, offset, definitionKind, isShorthandAssignmentProperty);
489
- }
490
-
491
- #processNodeAsDefinition(
492
- definitionKind: DefinitionKind.Let|DefinitionKind.Var,
493
- node: Acorn.ESTree.Pattern|Acorn.ESTree.AssignmentProperty|null): void {
494
- if (node === null) {
495
- return;
496
- }
497
- switch (node.type) {
498
- case 'ArrayPattern':
499
- node.elements.forEach(this.#processNodeAsDefinition.bind(this, definitionKind));
500
- break;
501
- case 'AssignmentPattern':
502
- this.#processNodeAsDefinition(definitionKind, node.left);
503
- this.processNode(node.right);
504
- break;
505
- case 'Identifier':
506
- this.#addVariable(node.name, node.start, definitionKind);
507
- break;
508
- case 'MemberExpression':
509
- this.processNode(node.object);
510
- if (node.computed) {
511
- this.processNode(node.property);
512
- }
513
- break;
514
- case 'ObjectPattern':
515
- node.properties.forEach(this.#processNodeAsDefinition.bind(this, definitionKind));
516
- break;
517
- case 'Property':
518
- // This is AssignmentProperty inside an object pattern.
519
- if (node.shorthand) {
520
- console.assert(node.value === node.key);
521
- console.assert(node.value.type === 'Identifier');
522
- this.#addVariable((node.value as Acorn.ESTree.Identifier).name, node.value.start, definitionKind, true);
523
- } else {
524
- if (node.computed) {
525
- this.processNode(node.key);
526
- }
527
- this.#processNodeAsDefinition(definitionKind, node.value);
528
- }
529
- break;
530
- case 'RestElement':
531
- this.#processNodeAsDefinition(definitionKind, node.argument);
532
- break;
533
- }
534
- }
535
-
536
- #processVariableDeclarator(
537
- definitionKind: DefinitionKind.Let|DefinitionKind.Var, decl: Acorn.ESTree.VariableDeclarator): void {
538
- this.#processNodeAsDefinition(definitionKind, decl.id);
539
- this.processNode(decl.init ?? null);
540
- }
541
- }
@@ -16,6 +16,7 @@ import * as HTMLOutline from './HTMLOutline.js';
16
16
  import * as JavaScriptFormatter from './JavaScriptFormatter.js';
17
17
  import * as JavaScriptOutline from './JavaScriptOutline.js';
18
18
  import * as JSONFormatter from './JSONFormatter.js';
19
+ import * as ScopeParser from './ScopeParser.js';
19
20
  import * as Substitute from './Substitute.js';
20
21
 
21
22
  export {
@@ -28,5 +29,6 @@ export {
28
29
  JavaScriptFormatter,
29
30
  JavaScriptOutline,
30
31
  JSONFormatter,
32
+ ScopeParser,
31
33
  Substitute,
32
34
  };
@@ -263,11 +263,9 @@ export function registerCommands(inspectorBackend) {
263
263
  {KHttpError: 'kHttpError', KUnavailableOffline: 'kUnavailableOffline', KDigitalAssetLinks: 'kDigitalAssetLinks'});
264
264
  inspectorBackend.registerEnum('Audits.AttributionReportingIssueType', {
265
265
  PermissionPolicyDisabled: 'PermissionPolicyDisabled',
266
- InvalidAttributionSourceEventId: 'InvalidAttributionSourceEventId',
267
266
  AttributionSourceUntrustworthyOrigin: 'AttributionSourceUntrustworthyOrigin',
268
267
  AttributionUntrustworthyOrigin: 'AttributionUntrustworthyOrigin',
269
- InvalidAttributionSourceExpiry: 'InvalidAttributionSourceExpiry',
270
- InvalidAttributionSourcePriority: 'InvalidAttributionSourcePriority'
268
+ InvalidHeader: 'InvalidHeader'
271
269
  });
272
270
  inspectorBackend.registerEnum(
273
271
  'Audits.GenericIssueErrorType', {CrossOriginPortalPostMessageError: 'CrossOriginPortalPostMessageError'});
@@ -291,10 +289,7 @@ export function registerCommands(inspectorBackend) {
291
289
  GetUserMediaInsecureOrigin: 'GetUserMediaInsecureOrigin',
292
290
  HostCandidateAttributeGetter: 'HostCandidateAttributeGetter',
293
291
  InsecurePrivateNetworkSubresourceRequest: 'InsecurePrivateNetworkSubresourceRequest',
294
- LegacyConstraintGoogCpuOveruseDetection: 'LegacyConstraintGoogCpuOveruseDetection',
295
292
  LegacyConstraintGoogIPv6: 'LegacyConstraintGoogIPv6',
296
- LegacyConstraintGoogScreencastMinBitrate: 'LegacyConstraintGoogScreencastMinBitrate',
297
- LegacyConstraintGoogSuspendBelowMinBitrate: 'LegacyConstraintGoogSuspendBelowMinBitrate',
298
293
  LocalCSSFileExtensionRejected: 'LocalCSSFileExtensionRejected',
299
294
  MediaElementAudioSourceNode: 'MediaElementAudioSourceNode',
300
295
  MediaSourceAbortRemove: 'MediaSourceAbortRemove',
@@ -321,16 +316,13 @@ export function registerCommands(inspectorBackend) {
321
316
  RTCConstraintEnableDtlsSrtpTrue: 'RTCConstraintEnableDtlsSrtpTrue',
322
317
  RTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics:
323
318
  'RTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics',
324
- RTCPeerConnectionLegacyCreateWithMediaConstraints: 'RTCPeerConnectionLegacyCreateWithMediaConstraints',
325
319
  RTCPeerConnectionSdpSemanticsPlanB: 'RTCPeerConnectionSdpSemanticsPlanB',
326
320
  RtcpMuxPolicyNegotiate: 'RtcpMuxPolicyNegotiate',
327
321
  RTPDataChannel: 'RTPDataChannel',
328
- SelectionAddRangeIntersect: 'SelectionAddRangeIntersect',
329
322
  SharedArrayBufferConstructedWithoutIsolation: 'SharedArrayBufferConstructedWithoutIsolation',
330
323
  TextToSpeech_DisallowedByAutoplay: 'TextToSpeech_DisallowedByAutoplay',
331
324
  V8SharedArrayBufferConstructedInExtensionWithoutIsolation:
332
325
  'V8SharedArrayBufferConstructedInExtensionWithoutIsolation',
333
- WebCodecsVideoFrameDefaultTimestamp: 'WebCodecsVideoFrameDefaultTimestamp',
334
326
  XHRJSONEncodingDetection: 'XHRJSONEncodingDetection',
335
327
  XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: 'XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload',
336
328
  XRSupportsSession: 'XRSupportsSession'
@@ -1071,6 +1063,8 @@ export function registerCommands(inspectorBackend) {
1071
1063
  {'name': 'key', 'type': 'string', 'optional': false}, {'name': 'value', 'type': 'string', 'optional': false}
1072
1064
  ],
1073
1065
  []);
1066
+ inspectorBackend.registerCommand(
1067
+ 'DOMStorage.getStorageKeyForFrame', [{'name': 'frameId', 'type': 'string', 'optional': false}], ['storageKey']);
1074
1068
 
1075
1069
  // Database.
1076
1070
  inspectorBackend.registerEvent('Database.addDatabase', ['database']);
@@ -2348,7 +2342,41 @@ export function registerCommands(inspectorBackend) {
2348
2342
  inspectorBackend.registerEnum(
2349
2343
  'Page.BackForwardCacheNotRestoredReasonType',
2350
2344
  {SupportPending: 'SupportPending', PageSupportNeeded: 'PageSupportNeeded', Circumstantial: 'Circumstantial'});
2351
- inspectorBackend.registerEnum('Page.PrerenderFinalStatus', {Activated: 'Activated'});
2345
+ inspectorBackend.registerEnum('Page.PrerenderFinalStatus', {
2346
+ Activated: 'Activated',
2347
+ Destroyed: 'Destroyed',
2348
+ LowEndDevice: 'LowEndDevice',
2349
+ CrossOriginRedirect: 'CrossOriginRedirect',
2350
+ CrossOriginNavigation: 'CrossOriginNavigation',
2351
+ InvalidSchemeRedirect: 'InvalidSchemeRedirect',
2352
+ InvalidSchemeNavigation: 'InvalidSchemeNavigation',
2353
+ InProgressNavigation: 'InProgressNavigation',
2354
+ NavigationRequestBlockedByCsp: 'NavigationRequestBlockedByCsp',
2355
+ MainFrameNavigation: 'MainFrameNavigation',
2356
+ MojoBinderPolicy: 'MojoBinderPolicy',
2357
+ RendererProcessCrashed: 'RendererProcessCrashed',
2358
+ RendererProcessKilled: 'RendererProcessKilled',
2359
+ Download: 'Download',
2360
+ TriggerDestroyed: 'TriggerDestroyed',
2361
+ NavigationNotCommitted: 'NavigationNotCommitted',
2362
+ NavigationBadHttpStatus: 'NavigationBadHttpStatus',
2363
+ ClientCertRequested: 'ClientCertRequested',
2364
+ NavigationRequestNetworkError: 'NavigationRequestNetworkError',
2365
+ MaxNumOfRunningPrerendersExceeded: 'MaxNumOfRunningPrerendersExceeded',
2366
+ CancelAllHostsForTesting: 'CancelAllHostsForTesting',
2367
+ DidFailLoad: 'DidFailLoad',
2368
+ Stop: 'Stop',
2369
+ SslCertificateError: 'SslCertificateError',
2370
+ LoginAuthRequested: 'LoginAuthRequested',
2371
+ UaChangeRequiresReload: 'UaChangeRequiresReload',
2372
+ BlockedByClient: 'BlockedByClient',
2373
+ AudioOutputDeviceRequested: 'AudioOutputDeviceRequested',
2374
+ MixedContent: 'MixedContent',
2375
+ TriggerBackgrounded: 'TriggerBackgrounded',
2376
+ EmbedderTriggeredAndSameOriginRedirected: 'EmbedderTriggeredAndSameOriginRedirected',
2377
+ EmbedderTriggeredAndCrossOriginRedirected: 'EmbedderTriggeredAndCrossOriginRedirected',
2378
+ EmbedderTriggeredAndDestroyed: 'EmbedderTriggeredAndDestroyed'
2379
+ });
2352
2380
  inspectorBackend.registerEvent('Page.domContentEventFired', ['timestamp']);
2353
2381
  inspectorBackend.registerEnum(
2354
2382
  'Page.FileChooserOpenedEventMode', {SelectSingle: 'selectSingle', SelectMultiple: 'selectMultiple'});
@@ -1464,6 +1464,10 @@ export namespace ProtocolMapping {
1464
1464
  'DOMStorage.removeDOMStorageItem':
1465
1465
  {paramsType: [Protocol.DOMStorage.RemoveDOMStorageItemRequest]; returnType: void;};
1466
1466
  'DOMStorage.setDOMStorageItem': {paramsType: [Protocol.DOMStorage.SetDOMStorageItemRequest]; returnType: void;};
1467
+ 'DOMStorage.getStorageKeyForFrame': {
1468
+ paramsType: [Protocol.DOMStorage.GetStorageKeyForFrameRequest];
1469
+ returnType: Protocol.DOMStorage.GetStorageKeyForFrameResponse;
1470
+ };
1467
1471
  /**
1468
1472
  * Disables database tracking, prevents database events from being sent to the client.
1469
1473
  */
@@ -1614,7 +1618,7 @@ export namespace ProtocolMapping {
1614
1618
  * Sends a BeginFrame to the target and returns when the frame was completed. Optionally captures a
1615
1619
  * screenshot from the resulting frame. Requires that the target was created with enabled
1616
1620
  * BeginFrameControl. Designed for use with --run-all-compositor-stages-before-draw, see also
1617
- * https://goo.gl/3zHXhB for more background.
1621
+ * https://goo.gle/chrome-headless-rendering for more background.
1618
1622
  */
1619
1623
  'HeadlessExperimental.beginFrame': {
1620
1624
  paramsType: [Protocol.HeadlessExperimental.BeginFrameRequest?];
@@ -1280,6 +1280,9 @@ declare namespace ProtocolProxyApi {
1280
1280
 
1281
1281
  invoke_setDOMStorageItem(params: Protocol.DOMStorage.SetDOMStorageItemRequest):
1282
1282
  Promise<Protocol.ProtocolResponseWithError>;
1283
+
1284
+ invoke_getStorageKeyForFrame(params: Protocol.DOMStorage.GetStorageKeyForFrameRequest):
1285
+ Promise<Protocol.DOMStorage.GetStorageKeyForFrameResponse>;
1283
1286
  }
1284
1287
  export interface DOMStorageDispatcher {
1285
1288
  domStorageItemAdded(params: Protocol.DOMStorage.DomStorageItemAddedEvent): void;
@@ -1496,7 +1499,7 @@ declare namespace ProtocolProxyApi {
1496
1499
  * Sends a BeginFrame to the target and returns when the frame was completed. Optionally captures a
1497
1500
  * screenshot from the resulting frame. Requires that the target was created with enabled
1498
1501
  * BeginFrameControl. Designed for use with --run-all-compositor-stages-before-draw, see also
1499
- * https://goo.gl/3zHXhB for more background.
1502
+ * https://goo.gle/chrome-headless-rendering for more background.
1500
1503
  */
1501
1504
  invoke_beginFrame(params: Protocol.HeadlessExperimental.BeginFrameRequest):
1502
1505
  Promise<Protocol.HeadlessExperimental.BeginFrameResponse>;