chrome-devtools-frontend 1.0.970539 → 1.0.972865
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/gni/devtools_grd_files.gni +12 -7
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/ic_changes.svg +5 -0
- package/front_end/core/common/ParsedURL.ts +11 -5
- package/front_end/core/host/UserMetrics.ts +4 -1
- package/front_end/core/i18n/locales/en-US.json +45 -0
- package/front_end/core/i18n/locales/en-XL.json +45 -0
- package/front_end/core/platform/UserVisibleError.ts +28 -0
- package/front_end/core/platform/platform.ts +2 -0
- package/front_end/core/sdk/CSSModel.ts +21 -0
- package/front_end/core/sdk/CSSStyleSheetHeader.ts +10 -10
- package/front_end/core/sdk/ChildTargetManager.ts +0 -1
- package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +6 -4
- package/front_end/core/sdk/DOMDebuggerModel.ts +4 -3
- package/front_end/core/sdk/DebuggerModel.ts +17 -16
- package/front_end/core/sdk/NetworkManager.ts +32 -10
- package/front_end/core/sdk/NetworkRequest.ts +29 -16
- package/front_end/core/sdk/Resource.ts +10 -10
- package/front_end/core/sdk/ResourceTreeModel.ts +16 -13
- package/front_end/core/sdk/Script.ts +10 -10
- package/front_end/core/sdk/SourceMap.ts +8 -6
- package/front_end/entrypoints/lighthouse_worker/LighthouseService.ts +35 -12
- package/front_end/entrypoints/main/MainImpl.ts +8 -0
- package/front_end/generated/InspectorBackendCommands.js +14 -8
- package/front_end/generated/SupportedCSSProperties.js +2 -0
- package/front_end/generated/protocol-mapping.d.ts +5 -0
- package/front_end/generated/protocol-proxy-api.d.ts +5 -0
- package/front_end/generated/protocol.ts +20 -12
- package/front_end/models/bindings/BreakpointManager.ts +7 -5
- package/front_end/models/bindings/CSSWorkspaceBinding.ts +10 -3
- package/front_end/models/bindings/DebuggerLanguagePlugins.ts +2 -1
- package/front_end/models/bindings/ResourceMapping.ts +2 -1
- package/front_end/models/bindings/ResourceScriptMapping.ts +2 -1
- package/front_end/models/bindings/SASSSourceMapping.ts +4 -3
- package/front_end/models/bindings/StylesSourceMapping.ts +2 -1
- package/front_end/models/har/HARFormat.ts +4 -2
- package/front_end/models/har/Importer.ts +0 -1
- package/front_end/models/issues_manager/FederatedAuthRequestIssue.ts +12 -12
- package/front_end/models/issues_manager/descriptions/{federatedAuthRequestClientIdMetadataHttpNotFound.md → federatedAuthRequestClientMetadataHttpNotFound.md} +0 -0
- package/front_end/models/issues_manager/descriptions/{federatedAuthRequestClientIdMetadataInvalidResponse.md → federatedAuthRequestClientMetadataInvalidResponse.md} +0 -0
- package/front_end/models/issues_manager/descriptions/{federatedAuthRequestClientIdMetadataNoResponse.md → federatedAuthRequestClientMetadataNoResponse.md} +0 -0
- package/front_end/models/issues_manager/descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
- package/front_end/models/issues_manager/descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
- package/front_end/models/issues_manager/descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
- package/front_end/models/persistence/Automapping.ts +1 -1
- package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +7 -7
- package/front_end/models/persistence/IsolatedFileSystem.ts +10 -13
- package/front_end/models/persistence/PersistenceActions.ts +1 -4
- package/front_end/models/persistence/PlatformFileSystem.ts +3 -3
- package/front_end/{panels/sources/SourceMapNamesResolver.ts → models/source_map_scopes/NamesResolver.ts} +5 -5
- package/front_end/models/source_map_scopes/source_map_scopes.ts +7 -0
- package/front_end/models/text_utils/ContentProvider.ts +2 -1
- package/front_end/models/text_utils/StaticContentProvider.ts +7 -5
- package/front_end/models/workspace/UISourceCode.ts +7 -7
- package/front_end/models/workspace/WorkspaceImpl.ts +1 -3
- package/front_end/models/workspace_diff/WorkspaceDiff.ts +20 -8
- package/front_end/panels/application/ServiceWorkerCacheViews.ts +3 -2
- package/front_end/panels/browser_debugger/categorizedBreakpointsSidebarPane.css +0 -1
- package/front_end/panels/changes/ChangesView.ts +4 -4
- package/front_end/panels/console/ConsolePrompt.ts +25 -2
- package/front_end/panels/console/ConsoleViewMessage.ts +41 -8
- package/front_end/panels/coverage/CoverageModel.ts +1 -1
- package/front_end/panels/elements/ElementsPanel.ts +25 -11
- package/front_end/panels/elements/ElementsTreeElement.ts +0 -6
- package/front_end/panels/elements/StylesSidebarPane.ts +236 -51
- package/front_end/panels/elements/elementsTreeOutline.css +0 -1
- package/front_end/panels/issues/AffectedResourcesView.ts +1 -1
- package/front_end/panels/issues/AffectedSourcesView.ts +1 -1
- package/front_end/panels/lighthouse/LighthouseController.ts +41 -0
- package/front_end/panels/lighthouse/LighthousePanel.ts +64 -9
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +32 -4
- package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +0 -5
- package/front_end/panels/lighthouse/LighthouseStartView.ts +8 -4
- package/front_end/panels/lighthouse/LighthouseStartViewFR.ts +100 -0
- package/front_end/panels/lighthouse/LighthouseTimespanView.ts +99 -0
- package/front_end/panels/network/NetworkDataGridNode.ts +1 -1
- package/front_end/panels/profiler/CPUProfileView.ts +1 -1
- package/front_end/panels/profiler/HeapProfileView.ts +0 -2
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +0 -1
- package/front_end/panels/profiler/HeapSnapshotView.ts +2 -3
- package/front_end/panels/sensors/sensors.css +0 -1
- package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
- package/front_end/panels/sources/DebuggerPlugin.ts +5 -4
- package/front_end/panels/sources/NavigatorView.ts +14 -10
- package/front_end/panels/sources/ScopeChainSidebarPane.ts +6 -3
- package/front_end/panels/sources/SourcesNavigator.ts +7 -1
- package/front_end/panels/sources/sources-legacy.ts +5 -16
- package/front_end/panels/sources/sources.ts +0 -2
- package/front_end/panels/sources/sourcesView.css +0 -4
- package/front_end/panels/timeline/TimelineUIUtils.ts +4 -47
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/json.js +2 -1
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +3 -1
- package/front_end/third_party/codemirror.next/package.json +9 -9
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1047 -1158
- package/front_end/third_party/lighthouse/locales/en-US.json +7 -1
- package/front_end/third_party/lighthouse/locales/en-XL.json +7 -1
- package/front_end/third_party/lighthouse/report/bundle.d.ts +0 -3
- package/front_end/third_party/lighthouse/report/bundle.js +38 -24
- package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
- package/front_end/ui/legacy/ViewManager.ts +2 -1
- package/front_end/ui/legacy/closeButton.css +0 -1
- package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +7 -4
- package/front_end/ui/legacy/components/source_frame/FontView.ts +1 -1
- package/front_end/ui/legacy/components/source_frame/ImageView.ts +1 -1
- package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +2 -3
- package/front_end/ui/legacy/components/utils/Linkifier.ts +20 -59
- package/front_end/ui/legacy/tabbedPane.css +0 -2
- package/front_end/ui/legacy/toolbar.css +28 -3
- package/package.json +1 -1
- package/scripts/hosted_mode/server.js +13 -0
- package/scripts/npm_test.js +1 -1
- package/front_end/models/issues_manager/descriptions/federatedAuthRequestWellKnownHttpNotFound.md +0 -1
- package/front_end/models/issues_manager/descriptions/federatedAuthRequestWellKnownInvalidResponse.md +0 -1
- package/front_end/models/issues_manager/descriptions/federatedAuthRequestWellKnownNoResponse.md +0 -1
@@ -1,13 +1,13 @@
|
|
1
|
-
// Copyright
|
1
|
+
// Copyright 2022 The Chromium Authors. All rights reserved.
|
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
5
|
import * as Platform from '../../core/platform/platform.js';
|
6
6
|
import * as SDK from '../../core/sdk/sdk.js';
|
7
|
-
import * as Bindings from '
|
8
|
-
import * as Formatter from '
|
9
|
-
import * as TextUtils from '
|
10
|
-
import type * as Workspace from '
|
7
|
+
import * as Bindings from '../bindings/bindings.js';
|
8
|
+
import * as Formatter from '../formatter/formatter.js';
|
9
|
+
import * as TextUtils from '../text_utils/text_utils.js';
|
10
|
+
import type * as Workspace from '../workspace/workspace.js';
|
11
11
|
import * as Protocol from '../../generated/protocol.js';
|
12
12
|
|
13
13
|
interface CachedScopeMap {
|
@@ -29,9 +29,10 @@
|
|
29
29
|
*/
|
30
30
|
|
31
31
|
import type * as Common from '../../core/common/common.js';
|
32
|
+
import type * as Platform from '../../core/platform/platform.js';
|
32
33
|
|
33
34
|
export abstract class ContentProvider {
|
34
|
-
abstract contentURL():
|
35
|
+
abstract contentURL(): Platform.DevToolsPath.UrlString;
|
35
36
|
abstract contentType(): Common.ResourceType.ResourceType;
|
36
37
|
abstract contentEncoded(): Promise<boolean>;
|
37
38
|
abstract requestContent(): Promise<DeferredContent>;
|
@@ -3,17 +3,19 @@
|
|
3
3
|
// found in the LICENSE file.
|
4
4
|
|
5
5
|
import type * as Common from '../../core/common/common.js';
|
6
|
+
import type * as Platform from '../../core/platform/platform.js';
|
6
7
|
|
7
8
|
import type {ContentProvider, DeferredContent, SearchMatch} from './ContentProvider.js';
|
8
9
|
import {performSearchInContent} from './TextUtils.js';
|
9
10
|
|
10
11
|
export class StaticContentProvider implements ContentProvider {
|
11
|
-
private readonly contentURLInternal:
|
12
|
+
private readonly contentURLInternal: Platform.DevToolsPath.UrlString;
|
12
13
|
private readonly contentTypeInternal: Common.ResourceType.ResourceType;
|
13
14
|
private readonly lazyContent: () => Promise<DeferredContent>;
|
14
15
|
|
15
16
|
constructor(
|
16
|
-
contentURL:
|
17
|
+
contentURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType,
|
18
|
+
lazyContent: () => Promise<DeferredContent>) {
|
17
19
|
this.contentURLInternal = contentURL;
|
18
20
|
this.contentTypeInternal = contentType;
|
19
21
|
this.lazyContent = lazyContent;
|
@@ -25,11 +27,11 @@ export class StaticContentProvider implements ContentProvider {
|
|
25
27
|
content: string,
|
26
28
|
isEncoded: boolean,
|
27
29
|
}> => Promise.resolve({content, isEncoded: false});
|
28
|
-
|
30
|
+
// TODO(crbug.com/1253323): Cast to UrlString will be removed when migration to branded types is complete.
|
31
|
+
return new StaticContentProvider(contentURL as Platform.DevToolsPath.UrlString, contentType, lazyContent);
|
29
32
|
}
|
30
33
|
|
31
|
-
|
32
|
-
contentURL(): string {
|
34
|
+
contentURL(): Platform.DevToolsPath.UrlString {
|
33
35
|
return this.contentURLInternal;
|
34
36
|
}
|
35
37
|
|
@@ -56,7 +56,7 @@ export class UISourceCode extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
56
56
|
private projectInternal: Project;
|
57
57
|
private urlInternal: string;
|
58
58
|
private readonly originInternal: string;
|
59
|
-
private readonly parentURLInternal:
|
59
|
+
private readonly parentURLInternal: Platform.DevToolsPath.UrlString;
|
60
60
|
private nameInternal: string;
|
61
61
|
private contentTypeInternal: Common.ResourceType.ResourceType;
|
62
62
|
private requestContentPromise: Promise<TextUtils.ContentProvider.DeferredContent>|null;
|
@@ -81,7 +81,7 @@ export class UISourceCode extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
81
81
|
const parsedURL = Common.ParsedURL.ParsedURL.fromString(url);
|
82
82
|
if (parsedURL) {
|
83
83
|
this.originInternal = parsedURL.securityOrigin();
|
84
|
-
this.parentURLInternal = this.originInternal + parsedURL.folderPathComponents;
|
84
|
+
this.parentURLInternal = this.originInternal + parsedURL.folderPathComponents as Platform.DevToolsPath.UrlString;
|
85
85
|
if (parsedURL.queryParams) {
|
86
86
|
// in case file name contains query params, it doesn't look like a normal file name anymore
|
87
87
|
// so it can as well remain encoded
|
@@ -92,7 +92,7 @@ export class UISourceCode extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
92
92
|
}
|
93
93
|
} else {
|
94
94
|
this.originInternal = '';
|
95
|
-
this.parentURLInternal = '';
|
95
|
+
this.parentURLInternal = '' as Platform.DevToolsPath.UrlString;
|
96
96
|
this.nameInternal = url;
|
97
97
|
}
|
98
98
|
|
@@ -122,11 +122,11 @@ export class UISourceCode extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
122
122
|
return this.projectInternal.mimeType(this);
|
123
123
|
}
|
124
124
|
|
125
|
-
url():
|
126
|
-
return this.urlInternal;
|
125
|
+
url(): Platform.DevToolsPath.UrlString {
|
126
|
+
return this.urlInternal as Platform.DevToolsPath.UrlString;
|
127
127
|
}
|
128
128
|
|
129
|
-
parentURL():
|
129
|
+
parentURL(): Platform.DevToolsPath.UrlString {
|
130
130
|
return this.parentURLInternal;
|
131
131
|
}
|
132
132
|
|
@@ -189,7 +189,7 @@ export class UISourceCode extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
189
189
|
WorkspaceImplEvents.UISourceCodeRenamed, {oldURL: oldURL, uiSourceCode: this});
|
190
190
|
}
|
191
191
|
|
192
|
-
contentURL():
|
192
|
+
contentURL(): Platform.DevToolsPath.UrlString {
|
193
193
|
return this.url();
|
194
194
|
}
|
195
195
|
|
@@ -29,7 +29,6 @@
|
|
29
29
|
*/
|
30
30
|
|
31
31
|
import * as Common from '../../core/common/common.js';
|
32
|
-
import type * as Platform from '../../core/platform/platform.js';
|
33
32
|
import type * as TextUtils from '../text_utils/text_utils.js';
|
34
33
|
|
35
34
|
import type {UISourceCodeMetadata} from './UISourceCode.js';
|
@@ -177,8 +176,7 @@ export abstract class ProjectStore implements Project {
|
|
177
176
|
renameUISourceCode(uiSourceCode: UISourceCode, newName: string): void {
|
178
177
|
const oldPath = uiSourceCode.url();
|
179
178
|
const newPath = uiSourceCode.parentURL() ?
|
180
|
-
Common.ParsedURL.ParsedURL.urlFromParentUrlAndName(
|
181
|
-
uiSourceCode.parentURL() as Platform.DevToolsPath.UrlString, newName) :
|
179
|
+
Common.ParsedURL.ParsedURL.urlFromParentUrlAndName(uiSourceCode.parentURL(), newName) :
|
182
180
|
encodeURIComponent(newName);
|
183
181
|
const value = this.uiSourceCodesMap.get(oldPath) as {
|
184
182
|
uiSourceCode: UISourceCode,
|
@@ -13,6 +13,11 @@ interface DiffRequestOptions {
|
|
13
13
|
shouldFormatDiff: boolean;
|
14
14
|
}
|
15
15
|
|
16
|
+
interface DiffResponse {
|
17
|
+
diff: Diff.Diff.DiffArray;
|
18
|
+
formattedCurrentMapping?: FormatterModule.ScriptFormatter.FormatterSourceMapping;
|
19
|
+
}
|
20
|
+
|
16
21
|
export class WorkspaceDiffImpl extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
17
22
|
private readonly uiSourceCodeDiffs: WeakMap<Workspace.UISourceCode.UISourceCode, UISourceCodeDiff>;
|
18
23
|
private readonly loadingUISourceCodes:
|
@@ -35,7 +40,7 @@ export class WorkspaceDiffImpl extends Common.ObjectWrapper.ObjectWrapper<EventT
|
|
35
40
|
}
|
36
41
|
|
37
42
|
requestDiff(uiSourceCode: Workspace.UISourceCode.UISourceCode, diffRequestOptions: DiffRequestOptions):
|
38
|
-
Promise<
|
43
|
+
Promise<DiffResponse|null> {
|
39
44
|
return this.uiSourceCodeDiff(uiSourceCode).requestDiff(diffRequestOptions);
|
40
45
|
}
|
41
46
|
|
@@ -185,7 +190,7 @@ export type EventTypes = {
|
|
185
190
|
|
186
191
|
export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourceCodeDiffEventTypes> {
|
187
192
|
private uiSourceCode: Workspace.UISourceCode.UISourceCode;
|
188
|
-
private requestDiffPromise: Promise<
|
193
|
+
private requestDiffPromise: Promise<DiffResponse|null>|null;
|
189
194
|
private pendingChanges: number|null;
|
190
195
|
dispose: boolean;
|
191
196
|
constructor(uiSourceCode: Workspace.UISourceCode.UISourceCode) {
|
@@ -218,7 +223,7 @@ export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourc
|
|
218
223
|
}
|
219
224
|
}
|
220
225
|
|
221
|
-
requestDiff(diffRequestOptions: DiffRequestOptions): Promise<
|
226
|
+
requestDiff(diffRequestOptions: DiffRequestOptions): Promise<DiffResponse|null> {
|
222
227
|
if (!this.requestDiffPromise) {
|
223
228
|
this.requestDiffPromise = this.innerRequestDiff(diffRequestOptions);
|
224
229
|
}
|
@@ -237,7 +242,7 @@ export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourc
|
|
237
242
|
return content.content || ('error' in content && content.error) || '';
|
238
243
|
}
|
239
244
|
|
240
|
-
private async innerRequestDiff({shouldFormatDiff}: DiffRequestOptions): Promise<
|
245
|
+
private async innerRequestDiff({shouldFormatDiff}: DiffRequestOptions): Promise<DiffResponse|null> {
|
241
246
|
if (this.dispose) {
|
242
247
|
return null;
|
243
248
|
}
|
@@ -270,15 +275,22 @@ export class UISourceCodeDiff extends Common.ObjectWrapper.ObjectWrapper<UISourc
|
|
270
275
|
if (current === null || baseline === null) {
|
271
276
|
return null;
|
272
277
|
}
|
278
|
+
let formattedCurrentMapping;
|
273
279
|
if (shouldFormatDiff) {
|
274
280
|
baseline = (await FormatterModule.ScriptFormatter.format(
|
275
281
|
this.uiSourceCode.contentType(), this.uiSourceCode.mimeType(), baseline))
|
276
282
|
.formattedContent;
|
277
|
-
|
278
|
-
|
279
|
-
|
283
|
+
const formatCurrentResult = await FormatterModule.ScriptFormatter.format(
|
284
|
+
this.uiSourceCode.contentType(), this.uiSourceCode.mimeType(), current);
|
285
|
+
current = formatCurrentResult.formattedContent;
|
286
|
+
formattedCurrentMapping = formatCurrentResult.formattedMapping;
|
280
287
|
}
|
281
|
-
|
288
|
+
const reNewline = /\r\n?|\n/;
|
289
|
+
const diff = Diff.Diff.DiffWrapper.lineDiff(baseline.split(reNewline), current.split(reNewline));
|
290
|
+
return {
|
291
|
+
diff,
|
292
|
+
formattedCurrentMapping,
|
293
|
+
};
|
282
294
|
}
|
283
295
|
}
|
284
296
|
|
@@ -381,7 +381,8 @@ export class ServiceWorkerCacheView extends UI.View.SimpleView {
|
|
381
381
|
|
382
382
|
private createRequest(entry: Protocol.CacheStorage.DataEntry): SDK.NetworkRequest.NetworkRequest {
|
383
383
|
const request = SDK.NetworkRequest.NetworkRequest.createWithoutBackendRequest(
|
384
|
-
'cache-storage-' + entry.requestURL, entry.requestURL
|
384
|
+
'cache-storage-' + entry.requestURL, entry.requestURL as Platform.DevToolsPath.UrlString,
|
385
|
+
'' as Platform.DevToolsPath.UrlString, null);
|
385
386
|
request.requestMethod = entry.requestMethod;
|
386
387
|
request.setRequestHeaders(entry.requestHeaders);
|
387
388
|
request.statusCode = entry.responseStatus;
|
@@ -454,7 +455,7 @@ export class DataGridNode extends DataGrid.DataGrid.DataGridNode<DataGridNode> {
|
|
454
455
|
createCell(columnId: string): HTMLElement {
|
455
456
|
const cell = this.createTD(columnId);
|
456
457
|
let value;
|
457
|
-
let tooltip = this.request.url();
|
458
|
+
let tooltip = this.request.url() as string;
|
458
459
|
if (columnId === 'number') {
|
459
460
|
value = String(this.number);
|
460
461
|
} else if (columnId === 'name') {
|
@@ -173,7 +173,7 @@ export class ChangesView extends UI.Widget.VBox {
|
|
173
173
|
}
|
174
174
|
|
175
175
|
if (!this.selectedUISourceCode) {
|
176
|
-
this.renderDiffRows(
|
176
|
+
this.renderDiffRows();
|
177
177
|
return;
|
178
178
|
}
|
179
179
|
const uiSourceCode = this.selectedUISourceCode;
|
@@ -181,12 +181,12 @@ export class ChangesView extends UI.Widget.VBox {
|
|
181
181
|
this.hideDiff(i18nString(UIStrings.binaryData));
|
182
182
|
return;
|
183
183
|
}
|
184
|
-
const
|
184
|
+
const diffResponse = await this.workspaceDiff.requestDiff(
|
185
185
|
uiSourceCode, {shouldFormatDiff: Root.Runtime.experiments.isEnabled('preciseChanges')});
|
186
186
|
if (this.selectedUISourceCode !== uiSourceCode) {
|
187
187
|
return;
|
188
188
|
}
|
189
|
-
this.renderDiffRows(diff);
|
189
|
+
this.renderDiffRows(diffResponse?.diff);
|
190
190
|
}
|
191
191
|
|
192
192
|
private hideDiff(message: string): void {
|
@@ -197,7 +197,7 @@ export class ChangesView extends UI.Widget.VBox {
|
|
197
197
|
this.emptyWidget.showWidget();
|
198
198
|
}
|
199
199
|
|
200
|
-
private renderDiffRows(diff
|
200
|
+
private renderDiffRows(diff?: Diff.Diff.DiffArray): void {
|
201
201
|
if (!diff || (diff.length === 1 && diff[0][0] === Diff.Diff.Operation.Equal)) {
|
202
202
|
this.hideDiff(i18nString(UIStrings.noChanges));
|
203
203
|
} else {
|
@@ -5,7 +5,9 @@
|
|
5
5
|
import * as Common from '../../core/common/common.js';
|
6
6
|
import * as Host from '../../core/host/host.js';
|
7
7
|
import * as i18n from '../../core/i18n/i18n.js';
|
8
|
+
import * as Root from '../../core/root/root.js';
|
8
9
|
import * as SDK from '../../core/sdk/sdk.js';
|
10
|
+
import * as SourceMapScopes from '../../models/source_map_scopes/source_map_scopes.js';
|
9
11
|
import * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js';
|
10
12
|
import * as TextEditor from '../../ui/components/text_editor/text_editor.js';
|
11
13
|
import * as ObjectUI from '../../ui/legacy/components/object_ui/object_ui.js';
|
@@ -280,14 +282,35 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
280
282
|
const executionContext = currentExecutionContext;
|
281
283
|
const message = SDK.ConsoleModel.ConsoleModel.instance().addCommandMessage(executionContext, text);
|
282
284
|
const expression = ObjectUI.JavaScriptREPL.JavaScriptREPL.preprocessExpression(text);
|
283
|
-
void
|
284
|
-
executionContext, message, expression, useCommandLineAPI);
|
285
|
+
void this.evaluateCommandInConsole(executionContext, message, expression, useCommandLineAPI);
|
285
286
|
if (ConsolePanel.instance().isShowing()) {
|
286
287
|
Host.userMetrics.actionTaken(Host.UserMetrics.Action.CommandEvaluatedInConsolePanel);
|
287
288
|
}
|
288
289
|
}
|
289
290
|
}
|
290
291
|
|
292
|
+
private async evaluateCommandInConsole(
|
293
|
+
executionContext: SDK.RuntimeModel.ExecutionContext, message: SDK.ConsoleModel.ConsoleMessage, expression: string,
|
294
|
+
useCommandLineAPI: boolean): Promise<void> {
|
295
|
+
if (Root.Runtime.experiments.isEnabled('evaluateExpressionsWithSourceMaps')) {
|
296
|
+
const callFrame = executionContext.debuggerModel.selectedCallFrame();
|
297
|
+
if (callFrame) {
|
298
|
+
const nameMap = await SourceMapScopes.NamesResolver.allVariablesInCallFrame(callFrame);
|
299
|
+
expression = this.substituteNames(expression, nameMap);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
await SDK.ConsoleModel.ConsoleModel.instance().evaluateCommandInConsole(
|
304
|
+
executionContext, message, expression, useCommandLineAPI);
|
305
|
+
}
|
306
|
+
|
307
|
+
private substituteNames(expression: string, mapping: Map<string, string>): string {
|
308
|
+
// TODO(jarin) Build a more reliable replacer, based on the parsed AST.
|
309
|
+
// Here, we just replace exact occurrences.
|
310
|
+
const replacement = mapping.get(expression);
|
311
|
+
return replacement ?? expression;
|
312
|
+
}
|
313
|
+
|
291
314
|
private editorUpdate(update: CodeMirror.ViewUpdate): void {
|
292
315
|
if (update.docChanged ||
|
293
316
|
CodeMirror.selectedCompletion(update.state) !== CodeMirror.selectedCompletion(update.startState)) {
|
@@ -548,8 +548,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
|
|
548
548
|
return null;
|
549
549
|
}
|
550
550
|
return this.linkifier.linkifyScriptLocation(
|
551
|
-
runtimeModel.target(), /* scriptId */ null, url, lineNumber,
|
552
|
-
{columnNumber, className: undefined, tabStop: undefined, inlineFrameIndex: 0});
|
551
|
+
runtimeModel.target(), /* scriptId */ null, url, lineNumber, {columnNumber, inlineFrameIndex: 0});
|
553
552
|
}
|
554
553
|
|
555
554
|
private linkifyStackTraceTopFrame(stackTrace: Protocol.Runtime.StackTrace): HTMLElement|null {
|
@@ -567,8 +566,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
|
|
567
566
|
return null;
|
568
567
|
}
|
569
568
|
return this.linkifier.linkifyScriptLocation(
|
570
|
-
runtimeModel.target(), scriptId, url, lineNumber,
|
571
|
-
{columnNumber, className: undefined, tabStop: undefined, inlineFrameIndex: 0});
|
569
|
+
runtimeModel.target(), scriptId, url, lineNumber, {columnNumber, inlineFrameIndex: 0});
|
572
570
|
}
|
573
571
|
|
574
572
|
private format(rawParameters: (string|SDK.RemoteObject.RemoteObject|Protocol.Runtime.RemoteObject|undefined)[]):
|
@@ -1435,8 +1433,7 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
|
|
1435
1433
|
const formattedLine = document.createElement('span');
|
1436
1434
|
formattedLine.appendChild(this.linkifyStringAsFragment(`${prefix} ${name} (`));
|
1437
1435
|
const scriptLocationLink = this.linkifier.linkifyScriptLocation(
|
1438
|
-
debuggerModel.target(), null, url, lineNumber,
|
1439
|
-
{columnNumber, className: undefined, tabStop: undefined, inlineFrameIndex: f});
|
1436
|
+
debuggerModel.target(), null, url, lineNumber, {columnNumber, inlineFrameIndex: f});
|
1440
1437
|
scriptLocationLink.tabIndex = -1;
|
1441
1438
|
this.selectableChildren.push({element: scriptLocationLink, forceSelect: (): void => scriptLocationLink.focus()});
|
1442
1439
|
formattedLine.appendChild(scriptLocationLink);
|
@@ -1446,6 +1443,30 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
|
|
1446
1443
|
return true;
|
1447
1444
|
}
|
1448
1445
|
|
1446
|
+
private createScriptLocationLinkForSyntaxError(
|
1447
|
+
debuggerModel: SDK.DebuggerModel.DebuggerModel, exceptionDetails: Protocol.Runtime.ExceptionDetails): HTMLElement
|
1448
|
+
|undefined {
|
1449
|
+
const {scriptId, lineNumber, columnNumber} = exceptionDetails;
|
1450
|
+
if (!scriptId) {
|
1451
|
+
return;
|
1452
|
+
}
|
1453
|
+
|
1454
|
+
// SyntaxErrors might not populate the URL field. Try to resolve it via scriptId.
|
1455
|
+
const url = exceptionDetails.url || debuggerModel.scriptForId(scriptId)?.sourceURL;
|
1456
|
+
if (!url) {
|
1457
|
+
return;
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
const scriptLocationLink = this.linkifier.linkifyScriptLocation(
|
1461
|
+
debuggerModel.target(), exceptionDetails.scriptId || null, url, lineNumber, {
|
1462
|
+
columnNumber,
|
1463
|
+
inlineFrameIndex: 0,
|
1464
|
+
showColumnNumber: true,
|
1465
|
+
});
|
1466
|
+
scriptLocationLink.tabIndex = -1;
|
1467
|
+
return scriptLocationLink;
|
1468
|
+
}
|
1469
|
+
|
1449
1470
|
private tryFormatAsError(string: string, exceptionDetails?: Protocol.Runtime.ExceptionDetails): HTMLElement|null {
|
1450
1471
|
const runtimeModel = this.message.runtimeModel();
|
1451
1472
|
if (!runtimeModel) {
|
@@ -1465,6 +1486,20 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
|
|
1465
1486
|
for (let i = 0; i < linkInfos.length; ++i) {
|
1466
1487
|
const newline = i < linkInfos.length - 1 ? '\n' : '';
|
1467
1488
|
const {line, link} = linkInfos[i];
|
1489
|
+
// Syntax errors don't have a stack frame that points to the source position
|
1490
|
+
// where the error occurred. We use the source location from the
|
1491
|
+
// exceptionDetails and append it to the end of the message instead.
|
1492
|
+
if (!link && exceptionDetails && line.startsWith('SyntaxError')) {
|
1493
|
+
formattedResult.appendChild(this.linkifyStringAsFragment(line));
|
1494
|
+
const maybeScriptLocation = this.createScriptLocationLinkForSyntaxError(debuggerModel, exceptionDetails);
|
1495
|
+
if (maybeScriptLocation) {
|
1496
|
+
formattedResult.append(' (at ');
|
1497
|
+
formattedResult.appendChild(maybeScriptLocation);
|
1498
|
+
formattedResult.append(')');
|
1499
|
+
}
|
1500
|
+
formattedResult.append(newline);
|
1501
|
+
continue;
|
1502
|
+
}
|
1468
1503
|
if (!link) {
|
1469
1504
|
formattedResult.appendChild(this.linkifyStringAsFragment(`${line}${newline}`));
|
1470
1505
|
continue;
|
@@ -1475,8 +1510,6 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
|
|
1475
1510
|
const scriptLocationLink = this.linkifier.linkifyScriptLocation(
|
1476
1511
|
debuggerModel.target(), link.scriptId || null, link.url, link.lineNumber, {
|
1477
1512
|
columnNumber: link.columnNumber,
|
1478
|
-
className: undefined,
|
1479
|
-
tabStop: undefined,
|
1480
1513
|
inlineFrameIndex: 0,
|
1481
1514
|
showColumnNumber: true,
|
1482
1515
|
});
|
@@ -35,6 +35,7 @@
|
|
35
35
|
import * as Common from '../../core/common/common.js';
|
36
36
|
import * as Host from '../../core/host/host.js';
|
37
37
|
import * as i18n from '../../core/i18n/i18n.js';
|
38
|
+
import * as Platform from '../../core/platform/platform.js';
|
38
39
|
import * as Root from '../../core/root/root.js';
|
39
40
|
import * as SDK from '../../core/sdk/sdk.js';
|
40
41
|
import * as Extensions from '../../models/extensions/extensions.js';
|
@@ -1269,9 +1270,22 @@ export class DOMNodeRevealer implements Common.Revealer.Revealer {
|
|
1269
1270
|
const panel = ElementsPanel.instance();
|
1270
1271
|
panel.pendingNodeReveal = true;
|
1271
1272
|
|
1272
|
-
return new Promise(revealPromise)
|
1273
|
+
return (new Promise<void>(revealPromise)).catch((reason: Error) => {
|
1274
|
+
let message: string;
|
1275
|
+
if (Platform.UserVisibleError.isUserVisibleError(reason)) {
|
1276
|
+
message = reason.message;
|
1277
|
+
} else {
|
1278
|
+
message = i18nString(UIStrings.nodeCannotBeFoundInTheCurrent);
|
1279
|
+
}
|
1273
1280
|
|
1274
|
-
|
1281
|
+
Common.Console.Console.instance().warn(message);
|
1282
|
+
// Blink tests expect an exception to be raised and unhandled here to detect that the node
|
1283
|
+
// was actually not successfully viewed.
|
1284
|
+
throw reason;
|
1285
|
+
});
|
1286
|
+
|
1287
|
+
function revealPromise(
|
1288
|
+
resolve: () => void, reject: (arg0: Platform.UserVisibleError.UserVisibleError) => void): void {
|
1275
1289
|
if (node instanceof SDK.DOMModel.DOMNode) {
|
1276
1290
|
onNodeResolved((node as SDK.DOMModel.DOMNode));
|
1277
1291
|
} else if (node instanceof SDK.DOMModel.DeferredDOMNode) {
|
@@ -1281,10 +1295,12 @@ export class DOMNodeRevealer implements Common.Revealer.Revealer {
|
|
1281
1295
|
if (domModel) {
|
1282
1296
|
void domModel.pushObjectAsNodeToFrontend(node).then(checkRemoteObjectThenReveal);
|
1283
1297
|
} else {
|
1284
|
-
|
1298
|
+
const msg = i18nString(UIStrings.nodeCannotBeFoundInTheCurrent);
|
1299
|
+
reject(new Platform.UserVisibleError.UserVisibleError(msg));
|
1285
1300
|
}
|
1286
1301
|
} else {
|
1287
|
-
|
1302
|
+
const msg = i18nString(UIStrings.theRemoteObjectCouldNotBe);
|
1303
|
+
reject(new Platform.UserVisibleError.UserVisibleError(msg));
|
1288
1304
|
panel.pendingNodeReveal = false;
|
1289
1305
|
}
|
1290
1306
|
|
@@ -1304,8 +1320,7 @@ export class DOMNodeRevealer implements Common.Revealer.Revealer {
|
|
1304
1320
|
const isDocument = node instanceof SDK.DOMModel.DOMDocument;
|
1305
1321
|
if (!isDocument && isDetached) {
|
1306
1322
|
const msg = i18nString(UIStrings.nodeCannotBeFoundInTheCurrent);
|
1307
|
-
|
1308
|
-
reject(new Error(msg));
|
1323
|
+
reject(new Platform.UserVisibleError.UserVisibleError(msg));
|
1309
1324
|
return;
|
1310
1325
|
}
|
1311
1326
|
|
@@ -1313,14 +1328,14 @@ export class DOMNodeRevealer implements Common.Revealer.Revealer {
|
|
1313
1328
|
void panel.revealAndSelectNode(resolvedNode, !omitFocus).then(resolve);
|
1314
1329
|
return;
|
1315
1330
|
}
|
1316
|
-
|
1331
|
+
const msg = i18nString(UIStrings.nodeCannotBeFoundInTheCurrent);
|
1332
|
+
reject(new Platform.UserVisibleError.UserVisibleError(msg));
|
1317
1333
|
}
|
1318
1334
|
|
1319
1335
|
function checkRemoteObjectThenReveal(resolvedNode: SDK.DOMModel.DOMNode|null): void {
|
1320
1336
|
if (!resolvedNode) {
|
1321
1337
|
const msg = i18nString(UIStrings.theRemoteObjectCouldNotBe);
|
1322
|
-
|
1323
|
-
reject(new Error(msg));
|
1338
|
+
reject(new Platform.UserVisibleError.UserVisibleError(msg));
|
1324
1339
|
return;
|
1325
1340
|
}
|
1326
1341
|
onNodeResolved(resolvedNode);
|
@@ -1329,8 +1344,7 @@ export class DOMNodeRevealer implements Common.Revealer.Revealer {
|
|
1329
1344
|
function checkDeferredDOMNodeThenReveal(resolvedNode: SDK.DOMModel.DOMNode|null): void {
|
1330
1345
|
if (!resolvedNode) {
|
1331
1346
|
const msg = i18nString(UIStrings.theDeferredDomNodeCouldNotBe);
|
1332
|
-
|
1333
|
-
reject(new Error(msg));
|
1347
|
+
reject(new Platform.UserVisibleError.UserVisibleError(msg));
|
1334
1348
|
return;
|
1335
1349
|
}
|
1336
1350
|
onNodeResolved(resolvedNode);
|
@@ -1514,14 +1514,8 @@ export class ElementsTreeElement extends UI.TreeOutline.TreeElement {
|
|
1514
1514
|
Components.Linkifier.Linkifier.linkifyURL(rewrittenHref, {
|
1515
1515
|
text: value,
|
1516
1516
|
preventClick: true,
|
1517
|
-
className: undefined,
|
1518
|
-
lineNumber: undefined,
|
1519
|
-
columnNumber: undefined,
|
1520
1517
|
showColumnNumber: false,
|
1521
1518
|
inlineFrameIndex: 0,
|
1522
|
-
maxLength: undefined,
|
1523
|
-
tabStop: undefined,
|
1524
|
-
bypassURLTrimming: undefined,
|
1525
1519
|
});
|
1526
1520
|
return ImagePreviewPopover.setImageUrl(link, rewrittenHref);
|
1527
1521
|
}
|