chrome-devtools-frontend 1.0.927127 → 1.0.928589
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/AUTHORS +1 -0
- package/config/gni/all_devtools_files.gni +0 -1
- package/config/gni/devtools_grd_files.gni +30 -4
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/ic_preview_feature.svg +3 -0
- package/front_end/Tests.js +2 -3
- package/front_end/core/common/Settings.ts +26 -45
- package/front_end/core/host/UserMetrics.ts +2 -2
- package/front_end/core/i18n/locales/en-US.json +60 -15
- package/front_end/core/i18n/locales/en-XL.json +60 -15
- package/front_end/core/platform/keyboard-utilities.ts +1 -0
- package/front_end/core/root/Runtime.ts +62 -61
- package/front_end/core/sdk/AccessibilityModel.ts +73 -73
- package/front_end/core/sdk/CPUProfileDataModel.ts +14 -14
- package/front_end/core/sdk/CPUProfilerModel.ts +33 -33
- package/front_end/core/sdk/CPUThrottlingManager.ts +8 -8
- package/front_end/core/sdk/CSSFontFace.ts +10 -10
- package/front_end/core/sdk/CSSMatchedStyles.ts +114 -114
- package/front_end/core/sdk/CSSMedia.ts +22 -22
- package/front_end/core/sdk/CSSMetadata.ts +53 -49
- package/front_end/core/sdk/CSSModel.ts +139 -135
- package/front_end/core/sdk/CSSProperty.ts +18 -18
- package/front_end/core/sdk/CSSRule.ts +15 -15
- package/front_end/core/sdk/CSSStyleDeclaration.ts +49 -47
- package/front_end/core/sdk/CSSStyleSheetHeader.ts +12 -12
- package/front_end/core/sdk/ChildTargetManager.ts +41 -40
- package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +10 -10
- package/front_end/core/sdk/Connections.ts +81 -81
- package/front_end/core/sdk/ConsoleModel.ts +68 -68
- package/front_end/core/sdk/Cookie.ts +48 -48
- package/front_end/core/sdk/CookieModel.ts +13 -13
- package/front_end/core/sdk/CookieParser.ts +45 -45
- package/front_end/core/sdk/DOMDebuggerModel.ts +131 -131
- package/front_end/core/sdk/DOMModel.ts +264 -252
- package/front_end/core/sdk/DebuggerModel.ts +209 -205
- package/front_end/core/sdk/EmulationModel.ts +76 -76
- package/front_end/core/sdk/FilmStripModel.ts +29 -29
- package/front_end/core/sdk/FrameManager.ts +43 -42
- package/front_end/core/sdk/HeapProfilerModel.ts +36 -36
- package/front_end/core/sdk/IsolateManager.ts +82 -82
- package/front_end/core/sdk/IssuesModel.ts +6 -6
- package/front_end/core/sdk/LayerTreeBase.ts +37 -37
- package/front_end/core/sdk/LogModel.ts +5 -5
- package/front_end/core/sdk/NetworkManager.ts +229 -225
- package/front_end/core/sdk/NetworkRequest.ts +368 -360
- package/front_end/core/sdk/OverlayColorGenerator.ts +9 -9
- package/front_end/core/sdk/OverlayModel.ts +155 -153
- package/front_end/core/sdk/OverlayPersistentHighlighter.ts +100 -101
- package/front_end/core/sdk/PageResourceLoader.ts +30 -30
- package/front_end/core/sdk/PaintProfiler.ts +16 -16
- package/front_end/core/sdk/PerformanceMetricsModel.ts +12 -12
- package/front_end/core/sdk/ProfileTreeModel.ts +3 -3
- package/front_end/core/sdk/RemoteObject.ts +108 -104
- package/front_end/core/sdk/Resource.ts +85 -84
- package/front_end/core/sdk/ResourceTreeModel.ts +150 -145
- package/front_end/core/sdk/RuntimeModel.ts +38 -34
- package/front_end/core/sdk/SDKModel.ts +3 -3
- package/front_end/core/sdk/ScreenCaptureModel.ts +19 -19
- package/front_end/core/sdk/Script.ts +29 -29
- package/front_end/core/sdk/SecurityOriginManager.ts +19 -19
- package/front_end/core/sdk/ServerTiming.ts +2 -2
- package/front_end/core/sdk/ServiceWorkerCacheModel.ts +43 -43
- package/front_end/core/sdk/ServiceWorkerManager.ts +72 -68
- package/front_end/core/sdk/SourceMap.ts +40 -36
- package/front_end/core/sdk/SourceMapManager.ts +57 -57
- package/front_end/core/sdk/Target.ts +64 -63
- package/front_end/core/sdk/TargetManager.ts +60 -56
- package/front_end/core/sdk/TracingManager.ts +39 -39
- package/front_end/core/sdk/TracingModel.ts +125 -125
- package/front_end/core/sdk/WebAuthnModel.ts +9 -9
- package/front_end/entrypoints/lighthouse_worker/{LighthouseService.js → LighthouseService.ts} +20 -45
- package/front_end/entrypoints/lighthouse_worker/{lighthouse_worker.js → lighthouse_worker.ts} +0 -0
- package/front_end/entrypoints/main/MainImpl.ts +7 -2
- package/front_end/legacy_test_runner/elements_test_runner/ElementsTestRunner.js +4 -4
- package/front_end/legacy_test_runner/sdk_test_runner/sdk_test_runner.js +1 -1
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -6
- package/front_end/models/issues_manager/GenericIssue.ts +86 -0
- package/front_end/models/issues_manager/Issue.ts +24 -0
- package/front_end/models/issues_manager/IssuesManager.ts +18 -6
- package/front_end/models/issues_manager/descriptions/genericCrossOriginPortalPostMessageError.md +3 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +5422 -1
- package/front_end/panels/console/ConsoleSidebar.ts +0 -3
- package/front_end/panels/elements/ElementsTreeElement.ts +53 -61
- package/front_end/panels/elements/ElementsTreeOutline.ts +0 -1
- package/front_end/panels/elements/components/LayoutPane.ts +5 -1
- package/front_end/panels/issues/GenericIssueDetailsView.ts +68 -0
- package/front_end/panels/issues/IssueAggregator.ts +16 -0
- package/front_end/panels/issues/IssueKindView.ts +95 -0
- package/front_end/panels/issues/IssueView.ts +6 -0
- package/front_end/panels/issues/IssuesPane.ts +81 -18
- package/front_end/panels/issues/issuesTree.css +8 -3
- package/front_end/panels/lighthouse/LighthouseController.ts +3 -1
- package/front_end/panels/network/NetworkItemView.ts +1 -1
- package/front_end/panels/network/networkLogView.css +5 -0
- package/front_end/panels/sensors/LocationsSettingsTab.ts +1 -1
- package/front_end/panels/settings/SettingsScreen.ts +1 -0
- package/front_end/panels/settings/settingsScreen.css +24 -0
- package/front_end/panels/snippets/SnippetsQuickOpen.ts +8 -3
- package/front_end/panels/sources/TabbedEditorContainer.ts +1 -1
- package/front_end/panels/sources/sources-meta.ts +22 -7
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +4 -4
- package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +137 -0
- package/front_end/ui/components/code_highlighter/codeHighlighter.css +51 -0
- package/front_end/ui/components/code_highlighter/code_highlighter.ts +11 -0
- package/front_end/ui/components/docs/text_editor/basic.html +28 -0
- package/front_end/ui/components/docs/text_editor/basic.ts +14 -0
- package/front_end/ui/components/docs/text_prompt/basic.html +35 -0
- package/front_end/ui/components/docs/text_prompt/basic.ts +19 -0
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +1 -0
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +17 -0
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +1 -0
- package/front_end/ui/components/text_editor/TextEditor.ts +161 -0
- package/front_end/ui/components/text_editor/config.ts +264 -0
- package/front_end/{panels/console/components/components.ts → ui/components/text_editor/text_editor.ts} +2 -5
- package/front_end/ui/components/text_editor/theme.ts +113 -0
- package/front_end/ui/components/text_prompt/TextPrompt.ts +144 -0
- package/front_end/ui/components/text_prompt/textPrompt.css +33 -0
- package/front_end/ui/components/text_prompt/text_prompt.ts +9 -0
- package/front_end/ui/legacy/ARIAUtils.ts +14 -11
- package/front_end/ui/legacy/TabbedPane.ts +32 -3
- package/front_end/ui/legacy/UIUtils.ts +3 -1
- package/front_end/ui/legacy/View.ts +6 -0
- package/front_end/ui/legacy/ViewManager.ts +5 -1
- package/front_end/ui/legacy/ViewRegistration.ts +5 -0
- package/front_end/ui/legacy/XLink.ts +1 -1
- package/front_end/ui/legacy/closeButton.css +6 -0
- package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +8 -3
- package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +38 -38
- package/front_end/ui/legacy/components/quick_open/HelpQuickOpen.ts +10 -4
- package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +23 -6
- package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +14 -16
- package/front_end/ui/legacy/filter.css +1 -0
- package/front_end/ui/legacy/tabbedPane.css +24 -0
- package/front_end/ui/legacy/toolbar.css +5 -0
- package/inspector_overlay/main.ts +2 -1
- package/inspector_overlay/tool_screenshot.ts +8 -1
- package/package.json +1 -1
- package/scripts/build/rollup.config.js +9 -0
- package/scripts/migration/class-fields/migrate.js +56 -0
- package/scripts/migration/class-fields/package.json +5 -0
- package/front_end/panels/console/components/SidebarDeprecation.ts +0 -58
- package/front_end/panels/console/components/sidebarDeprecation.css +0 -17
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
1
5
|
/*
|
|
2
6
|
* Copyright (C) 2012 Google Inc. All rights reserved.
|
|
3
7
|
*
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
* copyright notice, this list of conditions and the following disclaimer
|
|
12
16
|
* in the documentation and/or other materials provided with the
|
|
13
17
|
* distribution.
|
|
14
|
-
* * Neither the name of Google Inc. nor the names of its
|
|
18
|
+
* * Neither the #name of Google Inc. nor the names of its
|
|
15
19
|
* contributors may be used to endorse or promote products derived from
|
|
16
20
|
* this software without specific prior written permission.
|
|
17
21
|
*
|
|
@@ -133,13 +137,13 @@ for (let i = 0; i < base64Digits.length; ++i) {
|
|
|
133
137
|
const sourceMapToSourceList = new WeakMap<SourceMapV3, string[]>();
|
|
134
138
|
|
|
135
139
|
export class TextSourceMap implements SourceMap {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
readonly #initiator: PageResourceLoadInitiator;
|
|
141
|
+
#json: SourceMapV3|null;
|
|
142
|
+
readonly #compiledURLInternal: string;
|
|
143
|
+
readonly #sourceMappingURL: string;
|
|
144
|
+
readonly #baseURL: string;
|
|
145
|
+
#mappingsInternal: SourceMapEntry[]|null;
|
|
146
|
+
readonly #sourceInfos: Map<string, TextSourceMap.SourceInfo>;
|
|
143
147
|
|
|
144
148
|
/**
|
|
145
149
|
* Implements Source Map V3 model. See https://github.com/google/closure-compiler/wiki/Source-Maps
|
|
@@ -147,16 +151,16 @@ export class TextSourceMap implements SourceMap {
|
|
|
147
151
|
*/
|
|
148
152
|
constructor(
|
|
149
153
|
compiledURL: string, sourceMappingURL: string, payload: SourceMapV3, initiator: PageResourceLoadInitiator) {
|
|
150
|
-
this
|
|
151
|
-
this
|
|
152
|
-
this
|
|
153
|
-
this
|
|
154
|
-
this
|
|
155
|
-
|
|
156
|
-
this
|
|
157
|
-
this
|
|
158
|
-
if (this
|
|
159
|
-
const sectionWithURL = Boolean(this
|
|
154
|
+
this.#initiator = initiator;
|
|
155
|
+
this.#json = payload;
|
|
156
|
+
this.#compiledURLInternal = compiledURL;
|
|
157
|
+
this.#sourceMappingURL = sourceMappingURL;
|
|
158
|
+
this.#baseURL = sourceMappingURL.startsWith('data:') ? compiledURL : sourceMappingURL;
|
|
159
|
+
|
|
160
|
+
this.#mappingsInternal = null;
|
|
161
|
+
this.#sourceInfos = new Map();
|
|
162
|
+
if (this.#json.sections) {
|
|
163
|
+
const sectionWithURL = Boolean(this.#json.sections.find(section => Boolean(section.url)));
|
|
160
164
|
if (sectionWithURL) {
|
|
161
165
|
Common.Console.Console.instance().warn(
|
|
162
166
|
`SourceMap "${sourceMappingURL}" contains unsupported "URL" field in one of its sections.`);
|
|
@@ -190,28 +194,28 @@ export class TextSourceMap implements SourceMap {
|
|
|
190
194
|
}
|
|
191
195
|
|
|
192
196
|
compiledURL(): string {
|
|
193
|
-
return this
|
|
197
|
+
return this.#compiledURLInternal;
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
url(): string {
|
|
197
|
-
return this
|
|
201
|
+
return this.#sourceMappingURL;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
204
|
sourceURLs(): string[] {
|
|
201
|
-
return [...this
|
|
205
|
+
return [...this.#sourceInfos.keys()];
|
|
202
206
|
}
|
|
203
207
|
|
|
204
208
|
sourceContentProvider(sourceURL: string, contentType: Common.ResourceType.ResourceType):
|
|
205
209
|
TextUtils.ContentProvider.ContentProvider {
|
|
206
|
-
const info = this
|
|
210
|
+
const info = this.#sourceInfos.get(sourceURL);
|
|
207
211
|
if (info && info.content) {
|
|
208
212
|
return TextUtils.StaticContentProvider.StaticContentProvider.fromString(sourceURL, contentType, info.content);
|
|
209
213
|
}
|
|
210
|
-
return new CompilerSourceMappingContentProvider(sourceURL, contentType, this
|
|
214
|
+
return new CompilerSourceMappingContentProvider(sourceURL, contentType, this.#initiator);
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
embeddedContentByURL(sourceURL: string): string|null {
|
|
214
|
-
const entry = this
|
|
218
|
+
const entry = this.#sourceInfos.get(sourceURL);
|
|
215
219
|
if (!entry) {
|
|
216
220
|
return null;
|
|
217
221
|
}
|
|
@@ -294,16 +298,16 @@ export class TextSourceMap implements SourceMap {
|
|
|
294
298
|
}
|
|
295
299
|
|
|
296
300
|
mappings(): SourceMapEntry[] {
|
|
297
|
-
if (this
|
|
298
|
-
this
|
|
301
|
+
if (this.#mappingsInternal === null) {
|
|
302
|
+
this.#mappingsInternal = [];
|
|
299
303
|
this.eachSection(this.parseMap.bind(this));
|
|
300
|
-
this
|
|
304
|
+
this.#json = null;
|
|
301
305
|
}
|
|
302
|
-
return /** @type {!Array<!SourceMapEntry>} */ this
|
|
306
|
+
return /** @type {!Array<!SourceMapEntry>} */ this.#mappingsInternal as SourceMapEntry[];
|
|
303
307
|
}
|
|
304
308
|
|
|
305
309
|
private reversedMappings(sourceURL: string): number[] {
|
|
306
|
-
const info = this
|
|
310
|
+
const info = this.#sourceInfos.get(sourceURL);
|
|
307
311
|
if (!info) {
|
|
308
312
|
return [];
|
|
309
313
|
}
|
|
@@ -334,14 +338,14 @@ export class TextSourceMap implements SourceMap {
|
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
private eachSection(callback: (arg0: SourceMapV3, arg1: number, arg2: number) => void): void {
|
|
337
|
-
if (!this
|
|
341
|
+
if (!this.#json) {
|
|
338
342
|
return;
|
|
339
343
|
}
|
|
340
|
-
if (!this
|
|
341
|
-
callback(this
|
|
344
|
+
if (!this.#json.sections) {
|
|
345
|
+
callback(this.#json, 0, 0);
|
|
342
346
|
return;
|
|
343
347
|
}
|
|
344
|
-
for (const section of this
|
|
348
|
+
for (const section of this.#json.sections) {
|
|
345
349
|
callback(section.map, section.offset.line, section.offset.column);
|
|
346
350
|
}
|
|
347
351
|
}
|
|
@@ -354,12 +358,12 @@ export class TextSourceMap implements SourceMap {
|
|
|
354
358
|
}
|
|
355
359
|
for (let i = 0; i < sourceMap.sources.length; ++i) {
|
|
356
360
|
const href = sourceRoot + sourceMap.sources[i];
|
|
357
|
-
let url = Common.ParsedURL.ParsedURL.completeURL(this
|
|
361
|
+
let url = Common.ParsedURL.ParsedURL.completeURL(this.#baseURL, href) || href;
|
|
358
362
|
const source = sourceMap.sourcesContent && sourceMap.sourcesContent[i];
|
|
359
|
-
if (url === this
|
|
363
|
+
if (url === this.#compiledURLInternal && source) {
|
|
360
364
|
url += '? [sm]';
|
|
361
365
|
}
|
|
362
|
-
this
|
|
366
|
+
this.#sourceInfos.set(url, new TextSourceMap.SourceInfo(source || null, null));
|
|
363
367
|
sourcesList.push(url);
|
|
364
368
|
}
|
|
365
369
|
sourceMapToSourceList.set(sourceMap, sourcesList);
|
|
@@ -23,61 +23,61 @@ const str_ = i18n.i18n.registerUIStrings('core/sdk/SourceMapManager.ts', UIStrin
|
|
|
23
23
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
24
24
|
|
|
25
25
|
export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWrapper.ObjectWrapper<EventTypes<T>> {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
readonly #target: Target;
|
|
27
|
+
#isEnabled: boolean;
|
|
28
|
+
readonly #relativeSourceURL: Map<T, string>;
|
|
29
|
+
readonly #relativeSourceMapURL: Map<T, string>;
|
|
30
|
+
#resolvedSourceMapId: Map<T, string>;
|
|
31
|
+
readonly #sourceMapById: Map<string, SourceMap>;
|
|
32
|
+
#sourceMapIdToLoadingClients: Platform.MapUtilities.Multimap<string, T>;
|
|
33
|
+
#sourceMapIdToClients: Platform.MapUtilities.Multimap<string, T>;
|
|
34
34
|
|
|
35
35
|
constructor(target: Target) {
|
|
36
36
|
super();
|
|
37
37
|
|
|
38
|
-
this
|
|
39
|
-
this
|
|
38
|
+
this.#target = target;
|
|
39
|
+
this.#isEnabled = true;
|
|
40
40
|
|
|
41
|
-
this
|
|
42
|
-
this
|
|
43
|
-
this
|
|
41
|
+
this.#relativeSourceURL = new Map();
|
|
42
|
+
this.#relativeSourceMapURL = new Map();
|
|
43
|
+
this.#resolvedSourceMapId = new Map();
|
|
44
44
|
|
|
45
|
-
this
|
|
46
|
-
this
|
|
47
|
-
this
|
|
45
|
+
this.#sourceMapById = new Map();
|
|
46
|
+
this.#sourceMapIdToLoadingClients = new Platform.MapUtilities.Multimap();
|
|
47
|
+
this.#sourceMapIdToClients = new Platform.MapUtilities.Multimap();
|
|
48
48
|
|
|
49
49
|
TargetManager.instance().addEventListener(TargetManagerEvents.InspectedURLChanged, this.inspectedURLChanged, this);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
setEnabled(isEnabled: boolean): void {
|
|
53
|
-
if (isEnabled === this
|
|
53
|
+
if (isEnabled === this.#isEnabled) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
this
|
|
57
|
-
// We need this copy, because `this
|
|
56
|
+
this.#isEnabled = isEnabled;
|
|
57
|
+
// We need this copy, because `this.#resolvedSourceMapId` is getting modified
|
|
58
58
|
// in the loop body and trying to iterate over it at the same time leads to
|
|
59
59
|
// an infinite loop.
|
|
60
|
-
const clients = [...this
|
|
60
|
+
const clients = [...this.#resolvedSourceMapId.keys()];
|
|
61
61
|
for (const client of clients) {
|
|
62
|
-
const relativeSourceURL = this
|
|
63
|
-
const relativeSourceMapURL = this
|
|
62
|
+
const relativeSourceURL = this.#relativeSourceURL.get(client);
|
|
63
|
+
const relativeSourceMapURL = this.#relativeSourceMapURL.get(client);
|
|
64
64
|
this.detachSourceMap(client);
|
|
65
65
|
this.attachSourceMap(client, relativeSourceURL, relativeSourceMapURL);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
private inspectedURLChanged(event: Common.EventTarget.EventTargetEvent<Target>): void {
|
|
70
|
-
if (event.data !== this
|
|
70
|
+
if (event.data !== this.#target) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// We need this copy, because `this
|
|
74
|
+
// We need this copy, because `this.#resolvedSourceMapId` is getting modified
|
|
75
75
|
// in the loop body and trying to iterate over it at the same time leads to
|
|
76
76
|
// an infinite loop.
|
|
77
|
-
const prevSourceMapIds = new Map(this
|
|
77
|
+
const prevSourceMapIds = new Map(this.#resolvedSourceMapId);
|
|
78
78
|
for (const [client, prevSourceMapId] of prevSourceMapIds) {
|
|
79
|
-
const relativeSourceURL = this
|
|
80
|
-
const relativeSourceMapURL = this
|
|
79
|
+
const relativeSourceURL = this.#relativeSourceURL.get(client);
|
|
80
|
+
const relativeSourceMapURL = this.#relativeSourceMapURL.get(client);
|
|
81
81
|
if (relativeSourceURL === undefined || relativeSourceMapURL === undefined) {
|
|
82
82
|
continue;
|
|
83
83
|
}
|
|
@@ -90,19 +90,19 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
sourceMapForClient(client: T): SourceMap|null {
|
|
93
|
-
const sourceMapId = this
|
|
93
|
+
const sourceMapId = this.#resolvedSourceMapId.get(client);
|
|
94
94
|
if (!sourceMapId) {
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
|
-
return this
|
|
97
|
+
return this.#sourceMapById.get(sourceMapId) || null;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
clientsForSourceMap(sourceMap: SourceMap): T[] {
|
|
101
101
|
const sourceMapId = this.getSourceMapId(sourceMap.compiledURL(), sourceMap.url());
|
|
102
|
-
if (this
|
|
103
|
-
return [...this
|
|
102
|
+
if (this.#sourceMapIdToClients.has(sourceMapId)) {
|
|
103
|
+
return [...this.#sourceMapIdToClients.get(sourceMapId)];
|
|
104
104
|
}
|
|
105
|
-
return [...this
|
|
105
|
+
return [...this.#sourceMapIdToLoadingClients.get(sourceMapId)];
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
private getSourceMapId(sourceURL: string, sourceMapURL: string): string {
|
|
@@ -114,9 +114,9 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
|
|
|
114
114
|
sourceMapURL: string,
|
|
115
115
|
sourceMapId: string,
|
|
116
116
|
}|null {
|
|
117
|
-
//
|
|
117
|
+
// |#sourceURL| can be a random string, but is generally an absolute path.
|
|
118
118
|
// Complete it to inspected page url for relative links.
|
|
119
|
-
const resolvedSourceURL = Common.ParsedURL.ParsedURL.completeURL(this
|
|
119
|
+
const resolvedSourceURL = Common.ParsedURL.ParsedURL.completeURL(this.#target.inspectedURL(), sourceURL);
|
|
120
120
|
if (!resolvedSourceURL) {
|
|
121
121
|
return null;
|
|
122
122
|
}
|
|
@@ -136,28 +136,28 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
|
|
|
136
136
|
if (relativeSourceURL === undefined || !relativeSourceMapURL) {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
-
console.assert(!this
|
|
139
|
+
console.assert(!this.#resolvedSourceMapId.has(client), 'SourceMap is already attached to client');
|
|
140
140
|
const resolvedURLs = this.resolveRelativeURLs(relativeSourceURL, relativeSourceMapURL);
|
|
141
141
|
if (!resolvedURLs) {
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
|
-
this
|
|
145
|
-
this
|
|
144
|
+
this.#relativeSourceURL.set(client, relativeSourceURL);
|
|
145
|
+
this.#relativeSourceMapURL.set(client, relativeSourceMapURL);
|
|
146
146
|
|
|
147
147
|
const {sourceURL, sourceMapURL, sourceMapId} = resolvedURLs;
|
|
148
|
-
this
|
|
148
|
+
this.#resolvedSourceMapId.set(client, sourceMapId);
|
|
149
149
|
|
|
150
|
-
if (!this
|
|
150
|
+
if (!this.#isEnabled) {
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
this.dispatchEventToListeners(Events.SourceMapWillAttach, {client});
|
|
155
155
|
|
|
156
|
-
if (this
|
|
156
|
+
if (this.#sourceMapById.has(sourceMapId)) {
|
|
157
157
|
attach.call(this, sourceMapId, client);
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
|
-
if (!this
|
|
160
|
+
if (!this.#sourceMapIdToLoadingClients.has(sourceMapId)) {
|
|
161
161
|
TextSourceMap.load(sourceMapURL, sourceURL, client.createPageResourceLoadInitiator())
|
|
162
162
|
.catch(error => {
|
|
163
163
|
Common.Console.Console.instance().warn(
|
|
@@ -166,12 +166,12 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
|
|
|
166
166
|
})
|
|
167
167
|
.then(onSourceMap.bind(this, sourceMapId));
|
|
168
168
|
}
|
|
169
|
-
this
|
|
169
|
+
this.#sourceMapIdToLoadingClients.set(sourceMapId, client);
|
|
170
170
|
|
|
171
171
|
function onSourceMap(this: SourceMapManager<T>, sourceMapId: string, sourceMap: SourceMap|null): void {
|
|
172
172
|
this.sourceMapLoadedForTest();
|
|
173
|
-
const clients = this
|
|
174
|
-
this
|
|
173
|
+
const clients = this.#sourceMapIdToLoadingClients.get(sourceMapId);
|
|
174
|
+
this.#sourceMapIdToLoadingClients.deleteAll(sourceMapId);
|
|
175
175
|
if (!clients.size) {
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
@@ -181,41 +181,41 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
|
|
|
181
181
|
}
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
this
|
|
184
|
+
this.#sourceMapById.set(sourceMapId, sourceMap);
|
|
185
185
|
for (const client of clients) {
|
|
186
186
|
attach.call(this, sourceMapId, client);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
function attach(this: SourceMapManager<T>, sourceMapId: string, client: T): void {
|
|
191
|
-
this
|
|
192
|
-
const sourceMap = this
|
|
191
|
+
this.#sourceMapIdToClients.set(sourceMapId, client);
|
|
192
|
+
const sourceMap = this.#sourceMapById.get(sourceMapId) as SourceMap;
|
|
193
193
|
this.dispatchEventToListeners(Events.SourceMapAttached, {client, sourceMap});
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
detachSourceMap(client: T): void {
|
|
198
|
-
const sourceMapId = this
|
|
199
|
-
this
|
|
200
|
-
this
|
|
201
|
-
this
|
|
198
|
+
const sourceMapId = this.#resolvedSourceMapId.get(client);
|
|
199
|
+
this.#relativeSourceURL.delete(client);
|
|
200
|
+
this.#relativeSourceMapURL.delete(client);
|
|
201
|
+
this.#resolvedSourceMapId.delete(client);
|
|
202
202
|
|
|
203
203
|
if (!sourceMapId) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
if (!this
|
|
207
|
-
if (this
|
|
206
|
+
if (!this.#sourceMapIdToClients.hasValue(sourceMapId, client)) {
|
|
207
|
+
if (this.#sourceMapIdToLoadingClients.delete(sourceMapId, client)) {
|
|
208
208
|
this.dispatchEventToListeners(Events.SourceMapFailedToAttach, {client});
|
|
209
209
|
}
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
-
this
|
|
213
|
-
const sourceMap = this
|
|
212
|
+
this.#sourceMapIdToClients.delete(sourceMapId, client);
|
|
213
|
+
const sourceMap = this.#sourceMapById.get(sourceMapId);
|
|
214
214
|
if (!sourceMap) {
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
|
-
if (!this
|
|
218
|
-
this
|
|
217
|
+
if (!this.#sourceMapIdToClients.has(sourceMapId)) {
|
|
218
|
+
this.#sourceMapById.delete(sourceMapId);
|
|
219
219
|
}
|
|
220
220
|
this.dispatchEventToListeners(Events.SourceMapDetached, {client, sourceMap});
|
|
221
221
|
}
|
|
@@ -10,18 +10,18 @@ import type {TargetManager} from './TargetManager.js';
|
|
|
10
10
|
import {SDKModel} from './SDKModel.js';
|
|
11
11
|
|
|
12
12
|
export class Target extends ProtocolClient.InspectorBackend.TargetBase {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
readonly #targetManagerInternal: TargetManager;
|
|
14
|
+
#nameInternal: string;
|
|
15
|
+
#inspectedURLInternal: string;
|
|
16
|
+
#inspectedURLName: string;
|
|
17
|
+
readonly #capabilitiesMask: number;
|
|
18
|
+
#typeInternal: Type;
|
|
19
|
+
readonly #parentTargetInternal: Target|null;
|
|
20
|
+
#idInternal: Protocol.Target.TargetID|'main';
|
|
21
|
+
#modelByConstructor: Map<new(arg1: Target) => SDKModel, SDKModel>;
|
|
22
|
+
#isSuspended: boolean;
|
|
23
|
+
#targetInfoInternal: Protocol.Target.TargetInfo|undefined;
|
|
24
|
+
#creatingModels?: boolean;
|
|
25
25
|
|
|
26
26
|
constructor(
|
|
27
27
|
targetManager: TargetManager, id: Protocol.Target.TargetID|'main', name: string, type: Type,
|
|
@@ -29,58 +29,58 @@ export class Target extends ProtocolClient.InspectorBackend.TargetBase {
|
|
|
29
29
|
connection: ProtocolClient.InspectorBackend.Connection|null, targetInfo?: Protocol.Target.TargetInfo) {
|
|
30
30
|
const needsNodeJSPatching = type === Type.Node;
|
|
31
31
|
super(needsNodeJSPatching, parentTarget, sessionId, connection);
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
35
|
-
this
|
|
36
|
-
this
|
|
32
|
+
this.#targetManagerInternal = targetManager;
|
|
33
|
+
this.#nameInternal = name;
|
|
34
|
+
this.#inspectedURLInternal = '';
|
|
35
|
+
this.#inspectedURLName = '';
|
|
36
|
+
this.#capabilitiesMask = 0;
|
|
37
37
|
switch (type) {
|
|
38
38
|
case Type.Frame:
|
|
39
|
-
this
|
|
39
|
+
this.#capabilitiesMask = Capability.Browser | Capability.Storage | Capability.DOM | Capability.JS |
|
|
40
40
|
Capability.Log | Capability.Network | Capability.Target | Capability.Tracing | Capability.Emulation |
|
|
41
41
|
Capability.Input | Capability.Inspector | Capability.Audits | Capability.WebAuthn | Capability.IO |
|
|
42
42
|
Capability.Media;
|
|
43
43
|
if (!parentTarget) {
|
|
44
44
|
// This matches backend exposing certain capabilities only for the main frame.
|
|
45
|
-
this
|
|
45
|
+
this.#capabilitiesMask |=
|
|
46
46
|
Capability.DeviceEmulation | Capability.ScreenCapture | Capability.Security | Capability.ServiceWorker;
|
|
47
47
|
// TODO(dgozman): we report service workers for the whole frame tree on the main frame,
|
|
48
48
|
// while we should be able to only cover the subtree corresponding to the target.
|
|
49
49
|
}
|
|
50
50
|
break;
|
|
51
51
|
case Type.ServiceWorker:
|
|
52
|
-
this
|
|
52
|
+
this.#capabilitiesMask = Capability.JS | Capability.Log | Capability.Network | Capability.Target |
|
|
53
53
|
Capability.Inspector | Capability.IO;
|
|
54
54
|
if (!parentTarget) {
|
|
55
|
-
this
|
|
55
|
+
this.#capabilitiesMask |= Capability.Browser;
|
|
56
56
|
}
|
|
57
57
|
break;
|
|
58
58
|
case Type.SharedWorker:
|
|
59
|
-
this
|
|
59
|
+
this.#capabilitiesMask = Capability.JS | Capability.Log | Capability.Network | Capability.Target |
|
|
60
60
|
Capability.IO | Capability.Media | Capability.Inspector;
|
|
61
61
|
break;
|
|
62
62
|
case Type.Worker:
|
|
63
|
-
this
|
|
63
|
+
this.#capabilitiesMask =
|
|
64
64
|
Capability.JS | Capability.Log | Capability.Network | Capability.Target | Capability.IO | Capability.Media;
|
|
65
65
|
break;
|
|
66
66
|
case Type.Node:
|
|
67
|
-
this
|
|
67
|
+
this.#capabilitiesMask = Capability.JS;
|
|
68
68
|
break;
|
|
69
69
|
case Type.Browser:
|
|
70
|
-
this
|
|
70
|
+
this.#capabilitiesMask = Capability.Target | Capability.IO;
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
|
-
this
|
|
74
|
-
this
|
|
75
|
-
this
|
|
73
|
+
this.#typeInternal = type;
|
|
74
|
+
this.#parentTargetInternal = parentTarget;
|
|
75
|
+
this.#idInternal = id;
|
|
76
76
|
/* } */
|
|
77
|
-
this
|
|
78
|
-
this
|
|
79
|
-
this
|
|
77
|
+
this.#modelByConstructor = new Map();
|
|
78
|
+
this.#isSuspended = suspended;
|
|
79
|
+
this.#targetInfoInternal = targetInfo;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
createModels(required: Set<new(arg1: Target) => SDKModel>): void {
|
|
83
|
-
this
|
|
83
|
+
this.#creatingModels = true;
|
|
84
84
|
const registeredModels = Array.from(SDKModel.registeredModels.entries());
|
|
85
85
|
// Create early models.
|
|
86
86
|
for (const [modelClass, info] of registeredModels) {
|
|
@@ -94,120 +94,121 @@ export class Target extends ProtocolClient.InspectorBackend.TargetBase {
|
|
|
94
94
|
this.model(modelClass);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
this
|
|
97
|
+
this.#creatingModels = false;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
id(): Protocol.Target.TargetID|'main' {
|
|
101
|
-
return this
|
|
101
|
+
return this.#idInternal;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
name(): string {
|
|
105
|
-
return this
|
|
105
|
+
return this.#nameInternal || this.#inspectedURLName;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
type(): Type {
|
|
109
|
-
return this
|
|
109
|
+
return this.#typeInternal;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
markAsNodeJSForTest(): void {
|
|
113
113
|
super.markAsNodeJSForTest();
|
|
114
|
-
this
|
|
114
|
+
this.#typeInternal = Type.Node;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
targetManager(): TargetManager {
|
|
118
|
-
return this
|
|
118
|
+
return this.#targetManagerInternal;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
hasAllCapabilities(capabilitiesMask: number): boolean {
|
|
122
122
|
// TODO(dgozman): get rid of this method, once we never observe targets with
|
|
123
123
|
// capability mask.
|
|
124
|
-
return (this
|
|
124
|
+
return (this.#capabilitiesMask & capabilitiesMask) === capabilitiesMask;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
decorateLabel(label: string): string {
|
|
128
|
-
return (this
|
|
128
|
+
return (this.#typeInternal === Type.Worker || this.#typeInternal === Type.ServiceWorker) ? '\u2699 ' + label :
|
|
129
|
+
label;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
parentTarget(): Target|null {
|
|
132
|
-
return this
|
|
133
|
+
return this.#parentTargetInternal;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
dispose(reason: string): void {
|
|
136
137
|
super.dispose(reason);
|
|
137
|
-
this
|
|
138
|
-
for (const model of this
|
|
138
|
+
this.#targetManagerInternal.removeTarget(this);
|
|
139
|
+
for (const model of this.#modelByConstructor.values()) {
|
|
139
140
|
model.dispose();
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
model<T extends SDKModel>(modelClass: new(arg1: Target) => T): T|null {
|
|
144
|
-
if (!this
|
|
145
|
+
if (!this.#modelByConstructor.get(modelClass)) {
|
|
145
146
|
const info = SDKModel.registeredModels.get(modelClass);
|
|
146
147
|
if (info === undefined) {
|
|
147
148
|
throw 'Model class is not registered @' + new Error().stack;
|
|
148
149
|
}
|
|
149
|
-
if ((this
|
|
150
|
+
if ((this.#capabilitiesMask & info.capabilities) === info.capabilities) {
|
|
150
151
|
const model = new modelClass(this);
|
|
151
|
-
this
|
|
152
|
-
if (!this
|
|
153
|
-
this
|
|
152
|
+
this.#modelByConstructor.set(modelClass, model);
|
|
153
|
+
if (!this.#creatingModels) {
|
|
154
|
+
this.#targetManagerInternal.modelAdded(this, modelClass, model);
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
|
-
return (this
|
|
158
|
+
return (this.#modelByConstructor.get(modelClass) as T) || null;
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
models(): Map<new(arg1: Target) => SDKModel, SDKModel> {
|
|
161
|
-
return this
|
|
162
|
+
return this.#modelByConstructor;
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
inspectedURL(): string {
|
|
165
|
-
return this
|
|
166
|
+
return this.#inspectedURLInternal;
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
setInspectedURL(inspectedURL: string): void {
|
|
169
|
-
this
|
|
170
|
+
this.#inspectedURLInternal = inspectedURL;
|
|
170
171
|
const parsedURL = Common.ParsedURL.ParsedURL.fromString(inspectedURL);
|
|
171
|
-
this
|
|
172
|
+
this.#inspectedURLName = parsedURL ? parsedURL.lastPathComponentWithFragment() : '#' + this.#idInternal;
|
|
172
173
|
if (!this.parentTarget()) {
|
|
173
174
|
Host.InspectorFrontendHost.InspectorFrontendHostInstance.inspectedURLChanged(inspectedURL || '');
|
|
174
175
|
}
|
|
175
|
-
this
|
|
176
|
-
if (!this
|
|
177
|
-
this
|
|
176
|
+
this.#targetManagerInternal.onInspectedURLChange(this);
|
|
177
|
+
if (!this.#nameInternal) {
|
|
178
|
+
this.#targetManagerInternal.onNameChange(this);
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
async suspend(reason?: string): Promise<void> {
|
|
182
|
-
if (this
|
|
183
|
+
if (this.#isSuspended) {
|
|
183
184
|
return;
|
|
184
185
|
}
|
|
185
|
-
this
|
|
186
|
+
this.#isSuspended = true;
|
|
186
187
|
|
|
187
188
|
await Promise.all(Array.from(this.models().values(), m => m.preSuspendModel(reason)));
|
|
188
189
|
await Promise.all(Array.from(this.models().values(), m => m.suspendModel(reason)));
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
async resume(): Promise<void> {
|
|
192
|
-
if (!this
|
|
193
|
+
if (!this.#isSuspended) {
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
195
|
-
this
|
|
196
|
+
this.#isSuspended = false;
|
|
196
197
|
|
|
197
198
|
await Promise.all(Array.from(this.models().values(), m => m.resumeModel()));
|
|
198
199
|
await Promise.all(Array.from(this.models().values(), m => m.postResumeModel()));
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
suspended(): boolean {
|
|
202
|
-
return this
|
|
203
|
+
return this.#isSuspended;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
updateTargetInfo(targetInfo: Protocol.Target.TargetInfo): void {
|
|
206
|
-
this
|
|
207
|
+
this.#targetInfoInternal = targetInfo;
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
targetInfo(): Protocol.Target.TargetInfo|undefined {
|
|
210
|
-
return this
|
|
211
|
+
return this.#targetInfoInternal;
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
|