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
|
@@ -15,38 +15,38 @@ import {TargetManager} from './TargetManager.js';
|
|
|
15
15
|
let frameManagerInstance: FrameManager|null = null;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* The FrameManager is a central storage for all frames. It collects frames from all
|
|
19
|
-
* ResourceTreeModel-instances (one per target), so that frames can be found by id
|
|
18
|
+
* The FrameManager is a central storage for all #frames. It collects #frames from all
|
|
19
|
+
* ResourceTreeModel-instances (one per target), so that #frames can be found by id
|
|
20
20
|
* without needing to know their target.
|
|
21
21
|
*/
|
|
22
22
|
export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes> implements
|
|
23
23
|
SDKModelObserver<ResourceTreeModel> {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
readonly #eventListeners: WeakMap<ResourceTreeModel, Common.EventTarget.EventDescriptor[]>;
|
|
25
|
+
#frames: Map<string, {
|
|
26
26
|
frame: ResourceTreeFrame,
|
|
27
27
|
count: number,
|
|
28
28
|
}>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
readonly #framesForTarget: Map<Protocol.Target.TargetID|'main', Set<Protocol.Page.FrameId>>;
|
|
30
|
+
#topFrame: ResourceTreeFrame|null;
|
|
31
|
+
#creationStackTraceDataForTransferringFrame:
|
|
32
32
|
Map<string, {creationStackTrace: Protocol.Runtime.StackTrace | null, creationStackTraceTarget: Target}>;
|
|
33
|
-
|
|
33
|
+
#awaitedFrames: Map<string, {notInTarget?: Target, resolve: (frame: ResourceTreeFrame) => void}[]> = new Map();
|
|
34
34
|
|
|
35
35
|
constructor() {
|
|
36
36
|
super();
|
|
37
|
-
this
|
|
37
|
+
this.#eventListeners = new WeakMap();
|
|
38
38
|
TargetManager.instance().observeModels(ResourceTreeModel, this);
|
|
39
39
|
|
|
40
|
-
// Maps frameIds to frames and a count of how many ResourceTreeModels contain this frame.
|
|
40
|
+
// Maps frameIds to #frames and a count of how many ResourceTreeModels contain this frame.
|
|
41
41
|
// (OOPIFs are usually first attached to a new target and then detached from their old target,
|
|
42
42
|
// therefore being contained in 2 models for a short period of time.)
|
|
43
|
-
this
|
|
43
|
+
this.#frames = new Map();
|
|
44
44
|
|
|
45
45
|
// Maps targetIds to a set of frameIds.
|
|
46
|
-
this
|
|
46
|
+
this.#framesForTarget = new Map();
|
|
47
47
|
|
|
48
|
-
this
|
|
49
|
-
this
|
|
48
|
+
this.#topFrame = null;
|
|
49
|
+
this.#creationStackTraceDataForTransferringFrame = new Map();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
static instance({forceNew}: {
|
|
@@ -66,51 +66,52 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
66
66
|
resourceTreeModel.addEventListener(ResourceTreeModelEvents.FrameNavigated, this.frameNavigated, this);
|
|
67
67
|
const resourceAddedListener =
|
|
68
68
|
resourceTreeModel.addEventListener(ResourceTreeModelEvents.ResourceAdded, this.resourceAdded, this);
|
|
69
|
-
this
|
|
70
|
-
|
|
69
|
+
this.#eventListeners.set(
|
|
70
|
+
resourceTreeModel, [addListener, detachListener, navigatedListener, resourceAddedListener]);
|
|
71
|
+
this.#framesForTarget.set(resourceTreeModel.target().id(), new Set());
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
modelRemoved(resourceTreeModel: ResourceTreeModel): void {
|
|
74
|
-
const listeners = this
|
|
75
|
+
const listeners = this.#eventListeners.get(resourceTreeModel);
|
|
75
76
|
if (listeners) {
|
|
76
77
|
Common.EventTarget.removeEventListeners(listeners);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
// Iterate over this model's frames and decrease their count or remove them.
|
|
80
|
+
// Iterate over this model's #frames and decrease their count or remove them.
|
|
80
81
|
// (The ResourceTreeModel does not send FrameDetached events when a model
|
|
81
82
|
// is removed.)
|
|
82
|
-
const frameSet = this
|
|
83
|
+
const frameSet = this.#framesForTarget.get(resourceTreeModel.target().id());
|
|
83
84
|
if (frameSet) {
|
|
84
85
|
for (const frameId of frameSet) {
|
|
85
86
|
this.decreaseOrRemoveFrame(frameId);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
this
|
|
89
|
+
this.#framesForTarget.delete(resourceTreeModel.target().id());
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
private frameAdded(event: Common.EventTarget.EventTargetEvent<ResourceTreeFrame>): void {
|
|
92
93
|
const frame = event.data;
|
|
93
|
-
const frameData = this
|
|
94
|
+
const frameData = this.#frames.get(frame.id);
|
|
94
95
|
// If the frame is already in the map, increase its count, otherwise add it to the map.
|
|
95
96
|
if (frameData) {
|
|
96
97
|
// In order to not lose frame creation stack trace information during
|
|
97
98
|
// an OOPIF transfer we need to copy it to the new frame
|
|
98
99
|
frame.setCreationStackTrace(frameData.frame.getCreationStackTraceData());
|
|
99
|
-
this
|
|
100
|
+
this.#frames.set(frame.id, {frame, count: frameData.count + 1});
|
|
100
101
|
} else {
|
|
101
102
|
// If the transferring frame's detached event is received before its frame added
|
|
102
103
|
// event in the new target, the persisted frame creation stacktrace is reassigned.
|
|
103
|
-
const traceData = this
|
|
104
|
+
const traceData = this.#creationStackTraceDataForTransferringFrame.get(frame.id);
|
|
104
105
|
if (traceData && traceData.creationStackTrace) {
|
|
105
106
|
frame.setCreationStackTrace(traceData);
|
|
106
107
|
}
|
|
107
|
-
this
|
|
108
|
-
this
|
|
108
|
+
this.#frames.set(frame.id, {frame, count: 1});
|
|
109
|
+
this.#creationStackTraceDataForTransferringFrame.delete(frame.id);
|
|
109
110
|
}
|
|
110
111
|
this.resetTopFrame();
|
|
111
112
|
|
|
112
113
|
// Add the frameId to the the targetId's set of frameIds.
|
|
113
|
-
const frameSet = this
|
|
114
|
+
const frameSet = this.#framesForTarget.get(frame.resourceTreeModel().target().id());
|
|
114
115
|
if (frameSet) {
|
|
115
116
|
frameSet.add(frame.id);
|
|
116
117
|
}
|
|
@@ -127,15 +128,15 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
127
128
|
// If the transferring frame's detached event is received before its frame
|
|
128
129
|
// added event in the new target, we persist the frame creation stacktrace here
|
|
129
130
|
// so that later on the frame added event in the new target it can be reassigned.
|
|
130
|
-
if (isSwap && !this
|
|
131
|
+
if (isSwap && !this.#frames.get(frame.id)) {
|
|
131
132
|
const traceData = frame.getCreationStackTraceData();
|
|
132
133
|
if (traceData.creationStackTrace) {
|
|
133
|
-
this
|
|
134
|
+
this.#creationStackTraceDataForTransferringFrame.set(frame.id, traceData);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
// Remove the frameId from the target's set of frameIds.
|
|
138
|
-
const frameSet = this
|
|
139
|
+
const frameSet = this.#framesForTarget.get(frame.resourceTreeModel().target().id());
|
|
139
140
|
if (frameSet) {
|
|
140
141
|
frameSet.delete(frame.id);
|
|
141
142
|
}
|
|
@@ -154,10 +155,10 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
private decreaseOrRemoveFrame(frameId: Protocol.Page.FrameId): void {
|
|
157
|
-
const frameData = this
|
|
158
|
+
const frameData = this.#frames.get(frameId);
|
|
158
159
|
if (frameData) {
|
|
159
160
|
if (frameData.count === 1) {
|
|
160
|
-
this
|
|
161
|
+
this.#frames.delete(frameId);
|
|
161
162
|
this.resetTopFrame();
|
|
162
163
|
this.dispatchEventToListeners(Events.FrameRemoved, {frameId});
|
|
163
164
|
} else {
|
|
@@ -167,13 +168,13 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
/**
|
|
170
|
-
* Looks for the top frame in
|
|
171
|
+
* Looks for the top frame in `#frames` and sets `#topFrame` accordingly.
|
|
171
172
|
*
|
|
172
|
-
* Important: This method needs to be called everytime
|
|
173
|
+
* Important: This method needs to be called everytime `#frames` is updated.
|
|
173
174
|
*/
|
|
174
175
|
private resetTopFrame(): void {
|
|
175
176
|
const topFrames = this.getAllFrames().filter(frame => frame.isTopFrame());
|
|
176
|
-
this
|
|
177
|
+
this.#topFrame = topFrames.length > 0 ? topFrames[0] : null;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
/**
|
|
@@ -184,7 +185,7 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
184
185
|
* immediately use the function return value and not store it for later use.
|
|
185
186
|
*/
|
|
186
187
|
getFrame(frameId: Protocol.Page.FrameId): ResourceTreeFrame|null {
|
|
187
|
-
const frameData = this
|
|
188
|
+
const frameData = this.#frames.get(frameId);
|
|
188
189
|
if (frameData) {
|
|
189
190
|
return frameData.frame;
|
|
190
191
|
}
|
|
@@ -192,11 +193,11 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
getAllFrames(): ResourceTreeFrame[] {
|
|
195
|
-
return Array.from(this
|
|
196
|
+
return Array.from(this.#frames.values(), frameData => frameData.frame);
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
getTopFrame(): ResourceTreeFrame|null {
|
|
199
|
-
return this
|
|
200
|
+
return this.#topFrame;
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
async getOrWaitForFrame(frameId: Protocol.Page.FrameId, notInTarget?: Target): Promise<ResourceTreeFrame> {
|
|
@@ -205,17 +206,17 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
205
206
|
return frame;
|
|
206
207
|
}
|
|
207
208
|
return new Promise<ResourceTreeFrame>(resolve => {
|
|
208
|
-
const waiting = this
|
|
209
|
+
const waiting = this.#awaitedFrames.get(frameId);
|
|
209
210
|
if (waiting) {
|
|
210
211
|
waiting.push({notInTarget, resolve});
|
|
211
212
|
} else {
|
|
212
|
-
this
|
|
213
|
+
this.#awaitedFrames.set(frameId, [{notInTarget, resolve}]);
|
|
213
214
|
}
|
|
214
215
|
});
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
private resolveAwaitedFrame(frame: ResourceTreeFrame): void {
|
|
218
|
-
const waiting = this
|
|
219
|
+
const waiting = this.#awaitedFrames.get(frame.id);
|
|
219
220
|
if (!waiting) {
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
@@ -227,9 +228,9 @@ export class FrameManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
|
|
|
227
228
|
return true;
|
|
228
229
|
});
|
|
229
230
|
if (newWaiting.length > 0) {
|
|
230
|
-
this
|
|
231
|
+
this.#awaitedFrames.set(frame.id, newWaiting);
|
|
231
232
|
} else {
|
|
232
|
-
this
|
|
233
|
+
this.#awaitedFrames.delete(frame.id);
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
}
|
|
@@ -13,57 +13,57 @@ import {Capability} from './Target.js';
|
|
|
13
13
|
import {SDKModel} from './SDKModel.js';
|
|
14
14
|
|
|
15
15
|
export class HeapProfilerModel extends SDKModel<EventTypes> {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
#enabled: boolean;
|
|
17
|
+
readonly #heapProfilerAgent: ProtocolProxyApi.HeapProfilerApi;
|
|
18
|
+
readonly #memoryAgent: ProtocolProxyApi.MemoryApi;
|
|
19
|
+
readonly #runtimeModelInternal: RuntimeModel;
|
|
20
|
+
#samplingProfilerDepth: number;
|
|
21
21
|
|
|
22
22
|
constructor(target: Target) {
|
|
23
23
|
super(target);
|
|
24
24
|
target.registerHeapProfilerDispatcher(new HeapProfilerDispatcher(this));
|
|
25
|
-
this
|
|
26
|
-
this
|
|
27
|
-
this
|
|
28
|
-
this
|
|
29
|
-
this
|
|
25
|
+
this.#enabled = false;
|
|
26
|
+
this.#heapProfilerAgent = target.heapProfilerAgent();
|
|
27
|
+
this.#memoryAgent = target.memoryAgent();
|
|
28
|
+
this.#runtimeModelInternal = (target.model(RuntimeModel) as RuntimeModel);
|
|
29
|
+
this.#samplingProfilerDepth = 0;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
debuggerModel(): DebuggerModel {
|
|
33
|
-
return this
|
|
33
|
+
return this.#runtimeModelInternal.debuggerModel();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
runtimeModel(): RuntimeModel {
|
|
37
|
-
return this
|
|
37
|
+
return this.#runtimeModelInternal;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async enable(): Promise<void> {
|
|
41
|
-
if (this
|
|
41
|
+
if (this.#enabled) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
this
|
|
46
|
-
await this
|
|
45
|
+
this.#enabled = true;
|
|
46
|
+
await this.#heapProfilerAgent.invoke_enable();
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async startSampling(samplingRateInBytes?: number): Promise<boolean> {
|
|
50
|
-
if (this
|
|
50
|
+
if (this.#samplingProfilerDepth++) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
const defaultSamplingIntervalInBytes = 16384;
|
|
54
|
-
const response = await this
|
|
54
|
+
const response = await this.#heapProfilerAgent.invoke_startSampling(
|
|
55
55
|
{samplingInterval: samplingRateInBytes || defaultSamplingIntervalInBytes});
|
|
56
56
|
return Boolean(response.getError());
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async stopSampling(): Promise<Protocol.HeapProfiler.SamplingHeapProfile|null> {
|
|
60
|
-
if (!this
|
|
60
|
+
if (!this.#samplingProfilerDepth) {
|
|
61
61
|
throw new Error('Sampling profiler is not running.');
|
|
62
62
|
}
|
|
63
|
-
if (--this
|
|
63
|
+
if (--this.#samplingProfilerDepth) {
|
|
64
64
|
return this.getSamplingProfile();
|
|
65
65
|
}
|
|
66
|
-
const response = await this
|
|
66
|
+
const response = await this.#heapProfilerAgent.invoke_stopSampling();
|
|
67
67
|
if (response.getError()) {
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
@@ -71,7 +71,7 @@ export class HeapProfilerModel extends SDKModel<EventTypes> {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
async getSamplingProfile(): Promise<Protocol.HeapProfiler.SamplingHeapProfile|null> {
|
|
74
|
-
const response = await this
|
|
74
|
+
const response = await this.#heapProfilerAgent.invoke_getSamplingProfile();
|
|
75
75
|
if (response.getError()) {
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
@@ -79,12 +79,12 @@ export class HeapProfilerModel extends SDKModel<EventTypes> {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
async collectGarbage(): Promise<boolean> {
|
|
82
|
-
const response = await this
|
|
82
|
+
const response = await this.#heapProfilerAgent.invoke_collectGarbage();
|
|
83
83
|
return Boolean(response.getError());
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async snapshotObjectIdForObjectId(objectId: Protocol.Runtime.RemoteObjectId): Promise<string|null> {
|
|
87
|
-
const response = await this
|
|
87
|
+
const response = await this.#heapProfilerAgent.invoke_getHeapObjectId({objectId});
|
|
88
88
|
if (response.getError()) {
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
@@ -94,31 +94,31 @@ export class HeapProfilerModel extends SDKModel<EventTypes> {
|
|
|
94
94
|
async objectForSnapshotObjectId(
|
|
95
95
|
snapshotObjectId: Protocol.HeapProfiler.HeapSnapshotObjectId,
|
|
96
96
|
objectGroupName: string): Promise<RemoteObject|null> {
|
|
97
|
-
const result = await this
|
|
97
|
+
const result = await this.#heapProfilerAgent.invoke_getObjectByHeapObjectId(
|
|
98
98
|
{objectId: snapshotObjectId, objectGroup: objectGroupName});
|
|
99
99
|
if (result.getError()) {
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
|
-
return this
|
|
102
|
+
return this.#runtimeModelInternal.createRemoteObject(result.result);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
async addInspectedHeapObject(snapshotObjectId: Protocol.HeapProfiler.HeapSnapshotObjectId): Promise<boolean> {
|
|
106
|
-
const response = await this
|
|
106
|
+
const response = await this.#heapProfilerAgent.invoke_addInspectedHeapObject({heapObjectId: snapshotObjectId});
|
|
107
107
|
return Boolean(response.getError());
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
async takeHeapSnapshot(heapSnapshotOptions: Protocol.HeapProfiler.TakeHeapSnapshotRequest): Promise<void> {
|
|
111
|
-
await this
|
|
111
|
+
await this.#heapProfilerAgent.invoke_takeHeapSnapshot(heapSnapshotOptions);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
async startTrackingHeapObjects(recordAllocationStacks: boolean): Promise<boolean> {
|
|
115
115
|
const response =
|
|
116
|
-
await this
|
|
116
|
+
await this.#heapProfilerAgent.invoke_startTrackingHeapObjects({trackAllocations: recordAllocationStacks});
|
|
117
117
|
return Boolean(response.getError());
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
async stopTrackingHeapObjects(reportProgress: boolean): Promise<boolean> {
|
|
121
|
-
const response = await this
|
|
121
|
+
const response = await this.#heapProfilerAgent.invoke_stopTrackingHeapObjects({reportProgress});
|
|
122
122
|
return Boolean(response.getError());
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -200,29 +200,29 @@ export interface CommonHeapProfile {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
class HeapProfilerDispatcher implements ProtocolProxyApi.HeapProfilerDispatcher {
|
|
203
|
-
|
|
203
|
+
readonly #heapProfilerModel: HeapProfilerModel;
|
|
204
204
|
constructor(model: HeapProfilerModel) {
|
|
205
|
-
this
|
|
205
|
+
this.#heapProfilerModel = model;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
heapStatsUpdate({statsUpdate}: Protocol.HeapProfiler.HeapStatsUpdateEvent): void {
|
|
209
|
-
this
|
|
209
|
+
this.#heapProfilerModel.heapStatsUpdate(statsUpdate);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
lastSeenObjectId({lastSeenObjectId, timestamp}: Protocol.HeapProfiler.LastSeenObjectIdEvent): void {
|
|
213
|
-
this
|
|
213
|
+
this.#heapProfilerModel.lastSeenObjectId(lastSeenObjectId, timestamp);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
addHeapSnapshotChunk({chunk}: Protocol.HeapProfiler.AddHeapSnapshotChunkEvent): void {
|
|
217
|
-
this
|
|
217
|
+
this.#heapProfilerModel.addHeapSnapshotChunk(chunk);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
reportHeapSnapshotProgress({done, total, finished}: Protocol.HeapProfiler.ReportHeapSnapshotProgressEvent): void {
|
|
221
|
-
this
|
|
221
|
+
this.#heapProfilerModel.reportHeapSnapshotProgress(done, total, finished);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
resetProfiles(): void {
|
|
225
|
-
this
|
|
225
|
+
this.#heapProfilerModel.resetProfiles();
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|