chrome-devtools-frontend 1.0.1001476 → 1.0.1003469
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.
- package/config/gni/devtools_grd_files.gni +5 -6
- package/front_end/core/common/ParsedURL.ts +3 -3
- package/front_end/core/host/InspectorFrontendHost.ts +30 -1
- package/front_end/core/host/InspectorFrontendHostAPI.ts +1 -0
- package/front_end/core/host/UserMetrics.ts +17 -1
- package/front_end/core/i18n/locales/en-US.json +24 -63
- package/front_end/core/i18n/locales/en-XL.json +24 -63
- package/front_end/core/protocol_client/InspectorBackend.ts +4 -0
- package/front_end/core/root/Runtime.ts +7 -3
- package/front_end/core/sdk/ServiceWorkerManager.ts +6 -5
- package/front_end/core/sdk/TracingModel.ts +5 -4
- package/front_end/devtools_compatibility.js +1 -0
- package/front_end/entrypoints/formatter_worker/FormatterActions.ts +14 -0
- package/front_end/entrypoints/formatter_worker/ScopeParser.ts +491 -0
- package/front_end/entrypoints/formatter_worker/Substitute.ts +4 -440
- package/front_end/entrypoints/formatter_worker/formatter_worker.ts +2 -0
- package/front_end/entrypoints/main/MainImpl.ts +1 -0
- package/front_end/generated/InspectorBackendCommands.js +42 -12
- package/front_end/generated/SupportedCSSProperties.js +3 -5
- package/front_end/generated/protocol-mapping.d.ts +5 -1
- package/front_end/generated/protocol-proxy-api.d.ts +4 -1
- package/front_end/generated/protocol.ts +68 -14
- package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
- package/front_end/models/issues_manager/AttributionReportingIssue.ts +6 -34
- package/front_end/models/issues_manager/DeprecationIssue.ts +84 -172
- package/front_end/models/issues_manager/Issue.ts +8 -4
- package/front_end/models/issues_manager/descriptions/arInvalidHeader.md +3 -0
- package/front_end/models/persistence/NetworkPersistenceManager.ts +20 -0
- package/front_end/models/timeline_model/TimelineModel.ts +2 -49
- package/front_end/panels/application/AppManifestView.ts +3 -3
- package/front_end/panels/application/ApplicationPanelCacheSection.ts +3 -1
- package/front_end/panels/application/ApplicationPanelSidebar.ts +11 -6
- package/front_end/panels/application/ApplicationPanelTreeElement.ts +2 -2
- package/front_end/panels/application/BackgroundServiceView.ts +5 -4
- package/front_end/panels/application/ResourcesPanel.ts +1 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +6 -3
- package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +3 -2
- package/front_end/panels/elements/StylePropertyTreeElement.ts +19 -13
- package/front_end/panels/elements/StylesSidebarPane.ts +74 -5
- package/front_end/panels/elements/stylesSidebarPane.css +3 -0
- package/front_end/panels/issues/AffectedResourcesView.ts +4 -3
- package/front_end/panels/issues/AffectedSourcesView.ts +2 -1
- package/front_end/panels/issues/AttributionReportingIssueDetailsView.ts +9 -38
- package/front_end/panels/issues/IssueView.ts +1 -1
- package/front_end/panels/lighthouse/LighthouseController.ts +6 -3
- package/front_end/panels/lighthouse/LighthouseReporterTypes.ts +2 -1
- package/front_end/panels/lighthouse/lighthousePanel.css +4 -0
- package/front_end/panels/network/NetworkLogView.ts +32 -0
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +2 -2
- package/front_end/panels/profiler/HeapSnapshotView.ts +2 -1
- package/front_end/panels/profiler/ProfileDataGrid.ts +1 -1
- package/front_end/panels/security/SecurityPanel.ts +6 -5
- package/front_end/panels/settings/SettingsScreen.ts +2 -3
- package/front_end/panels/sources/SourcesNavigator.ts +1 -1
- package/front_end/panels/sources/SourcesPanel.ts +1 -1
- package/front_end/panels/timeline/PerformanceModel.ts +2 -6
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +5 -26
- package/front_end/panels/timeline/TimelineUIUtils.ts +14 -12
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1036 -1088
- package/front_end/third_party/lighthouse/locales/en-US.json +244 -4
- package/front_end/third_party/lighthouse/locales/en-XL.json +244 -4
- package/front_end/third_party/lighthouse/report/bundle.d.ts +4 -22
- package/front_end/third_party/lighthouse/report/bundle.js +23 -366
- package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
- package/front_end/ui/components/docs/linkifier/simple-url.ts +2 -1
- package/front_end/ui/components/docs/panel_feedback/basic.ts +3 -2
- package/front_end/ui/components/docs/panel_feedback/button.ts +2 -1
- package/front_end/ui/components/linkifier/LinkifierImpl.ts +4 -3
- package/front_end/ui/components/linkifier/LinkifierUtils.ts +2 -3
- package/front_end/ui/components/panel_feedback/FeedbackButton.ts +4 -6
- package/front_end/ui/components/panel_feedback/PanelFeedback.ts +5 -4
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +3 -3
- package/front_end/ui/components/text_editor/javascript.ts +6 -15
- package/front_end/ui/legacy/EmptyWidget.ts +2 -1
- package/front_end/ui/legacy/InspectorView.ts +29 -0
- package/front_end/ui/legacy/UIUtils.ts +4 -4
- package/front_end/ui/legacy/XLink.ts +12 -13
- package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +2 -4
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +1 -1
- package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +0 -2
- package/front_end/ui/legacy/components/utils/ImagePreview.ts +3 -7
- package/front_end/ui/legacy/components/utils/Linkifier.ts +23 -23
- package/front_end/ui/legacy/toolbar.css +1 -1
- package/package.json +1 -1
- package/scripts/whitespaces.txt +1 -0
- package/front_end/models/issues_manager/descriptions/arInvalidAttributionSourceEventId.md +0 -3
- package/front_end/models/issues_manager/descriptions/arInvalidAttributionSourceExpiry.md +0 -4
- 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.
|
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
|
};
|
@@ -407,6 +407,7 @@ export class MainImpl {
|
|
407
407
|
Root.Runtime.ExperimentName.SYNC_SETTINGS,
|
408
408
|
Root.Runtime.ExperimentName.CSS_LAYERS,
|
409
409
|
Root.Runtime.ExperimentName.EYEDROPPER_COLOR_PICKER,
|
410
|
+
'lighthousePanelFR',
|
410
411
|
]);
|
411
412
|
|
412
413
|
Root.Runtime.experiments.cleanUpStaleExperiments();
|
@@ -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
|
-
|
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', {
|
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'});
|
@@ -3320,7 +3348,8 @@ export function registerCommands(inspectorBackend) {
|
|
3320
3348
|
[
|
3321
3349
|
{'name': 'reportProgress', 'type': 'boolean', 'optional': true},
|
3322
3350
|
{'name': 'treatGlobalObjectsAsRoots', 'type': 'boolean', 'optional': true},
|
3323
|
-
{'name': 'captureNumericValue', 'type': 'boolean', 'optional': true}
|
3351
|
+
{'name': 'captureNumericValue', 'type': 'boolean', 'optional': true},
|
3352
|
+
{'name': 'exposeInternals', 'type': 'boolean', 'optional': true}
|
3324
3353
|
],
|
3325
3354
|
[]);
|
3326
3355
|
inspectorBackend.registerCommand(
|
@@ -3328,7 +3357,8 @@ export function registerCommands(inspectorBackend) {
|
|
3328
3357
|
[
|
3329
3358
|
{'name': 'reportProgress', 'type': 'boolean', 'optional': true},
|
3330
3359
|
{'name': 'treatGlobalObjectsAsRoots', 'type': 'boolean', 'optional': true},
|
3331
|
-
{'name': 'captureNumericValue', 'type': 'boolean', 'optional': true}
|
3360
|
+
{'name': 'captureNumericValue', 'type': 'boolean', 'optional': true},
|
3361
|
+
{'name': 'exposeInternals', 'type': 'boolean', 'optional': true}
|
3332
3362
|
],
|
3333
3363
|
[]);
|
3334
3364
|
|
@@ -486,11 +486,11 @@ export const generatedProperties = [
|
|
486
486
|
{'name': 'forced-color-adjust', 'inherited': true, 'keywords': ['auto', 'none', 'preserve-parent-color']},
|
487
487
|
{'longhands': ['row-gap', 'column-gap'], 'name': 'gap'},
|
488
488
|
{
|
489
|
-
'name': 'grid',
|
490
489
|
'longhands': [
|
491
490
|
'grid-template-rows', 'grid-template-columns', 'grid-template-areas', 'grid-auto-flow', 'grid-auto-rows',
|
492
491
|
'grid-auto-columns'
|
493
|
-
]
|
492
|
+
],
|
493
|
+
'name': 'grid'
|
494
494
|
},
|
495
495
|
{'longhands': ['grid-row-start', 'grid-column-start', 'grid-row-end', 'grid-column-end'], 'name': 'grid-area'},
|
496
496
|
{'name': 'grid-auto-columns', 'keywords': ['auto', 'min-content', 'max-content']},
|
@@ -505,7 +505,7 @@ export const generatedProperties = [
|
|
505
505
|
{'name': 'grid-row-end', 'keywords': ['auto']},
|
506
506
|
{'longhands': ['row-gap'], 'name': 'grid-row-gap'},
|
507
507
|
{'name': 'grid-row-start', 'keywords': ['auto']},
|
508
|
-
{'
|
508
|
+
{'longhands': ['grid-template-rows', 'grid-template-columns', 'grid-template-areas'], 'name': 'grid-template'},
|
509
509
|
{'keywords': ['none'], 'name': 'grid-template-areas'},
|
510
510
|
{'name': 'grid-template-columns', 'keywords': ['none']},
|
511
511
|
{'name': 'grid-template-rows', 'keywords': ['none']},
|
@@ -589,7 +589,6 @@ export const generatedProperties = [
|
|
589
589
|
},
|
590
590
|
{'name': 'negative'},
|
591
591
|
{'name': 'object-fit', 'keywords': ['fill', 'contain', 'cover', 'none', 'scale-down']},
|
592
|
-
{'name': 'object-overflow', 'keywords': ['clip', 'visible']},
|
593
592
|
{'name': 'object-position'},
|
594
593
|
{'name': 'object-view-box', 'keywords': ['none']},
|
595
594
|
{
|
@@ -1101,7 +1100,6 @@ export const generatedPropertyValues = {
|
|
1101
1100
|
]
|
1102
1101
|
},
|
1103
1102
|
'object-fit': {'values': ['fill', 'contain', 'cover', 'none', 'scale-down']},
|
1104
|
-
'object-overflow': {'values': ['clip', 'visible']},
|
1105
1103
|
'object-view-box': {'values': ['none']},
|
1106
1104
|
'offset-anchor': {'values': ['auto']},
|
1107
1105
|
'offset-path': {'values': ['none']},
|
@@ -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.
|
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.
|
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>;
|