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) 2011 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
|
*
|
|
@@ -119,26 +123,26 @@ const CONNECTION_TYPES = new Map([
|
|
|
119
123
|
|
|
120
124
|
export class NetworkManager extends SDKModel<EventTypes> {
|
|
121
125
|
readonly dispatcher: NetworkDispatcher;
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
readonly #networkAgent: ProtocolProxyApi.NetworkApi;
|
|
127
|
+
readonly #bypassServiceWorkerSetting: Common.Settings.Setting<boolean>;
|
|
124
128
|
|
|
125
129
|
constructor(target: Target) {
|
|
126
130
|
super(target);
|
|
127
131
|
this.dispatcher = new NetworkDispatcher(this);
|
|
128
|
-
this
|
|
132
|
+
this.#networkAgent = target.networkAgent();
|
|
129
133
|
target.registerNetworkDispatcher(this.dispatcher);
|
|
130
134
|
if (Common.Settings.Settings.instance().moduleSetting('cacheDisabled').get()) {
|
|
131
|
-
this
|
|
135
|
+
this.#networkAgent.invoke_setCacheDisabled({cacheDisabled: true});
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
this
|
|
135
|
-
this
|
|
138
|
+
this.#networkAgent.invoke_enable({maxPostDataSize: MAX_EAGER_POST_REQUEST_BODY_LENGTH});
|
|
139
|
+
this.#networkAgent.invoke_setAttachDebugStack({enabled: true});
|
|
136
140
|
|
|
137
|
-
this
|
|
138
|
-
if (this
|
|
141
|
+
this.#bypassServiceWorkerSetting = Common.Settings.Settings.instance().createSetting('bypassServiceWorker', false);
|
|
142
|
+
if (this.#bypassServiceWorkerSetting.get()) {
|
|
139
143
|
this.bypassServiceWorkerChanged();
|
|
140
144
|
}
|
|
141
|
-
this
|
|
145
|
+
this.#bypassServiceWorkerSetting.addChangeListener(this.bypassServiceWorkerChanged, this);
|
|
142
146
|
|
|
143
147
|
Common.Settings.Settings.instance()
|
|
144
148
|
.moduleSetting('cacheDisabled')
|
|
@@ -160,7 +164,7 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
160
164
|
if (!manager || !requestId || request.isRedirect()) {
|
|
161
165
|
return;
|
|
162
166
|
}
|
|
163
|
-
manager
|
|
167
|
+
manager.#networkAgent.invoke_replayXHR({requestId});
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
static async searchInRequest(request: NetworkRequest, query: string, caseSensitive: boolean, isRegex: boolean):
|
|
@@ -170,7 +174,7 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
170
174
|
if (!manager || !requestId || request.isRedirect()) {
|
|
171
175
|
return [];
|
|
172
176
|
}
|
|
173
|
-
const response = await manager
|
|
177
|
+
const response = await manager.#networkAgent.invoke_searchInResponseBody(
|
|
174
178
|
{requestId, query: query, caseSensitive: caseSensitive, isRegex: isRegex});
|
|
175
179
|
return response.result || [];
|
|
176
180
|
}
|
|
@@ -196,7 +200,7 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
196
200
|
if (!requestId) {
|
|
197
201
|
return {error: 'No backend request id for request', content: null, encoded: false};
|
|
198
202
|
}
|
|
199
|
-
const response = await manager
|
|
203
|
+
const response = await manager.#networkAgent.invoke_getResponseBody({requestId});
|
|
200
204
|
const error = response.getError() || null;
|
|
201
205
|
return {error: error, content: error ? null : response.body, encoded: response.base64Encoded};
|
|
202
206
|
}
|
|
@@ -213,7 +217,7 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
213
217
|
return null;
|
|
214
218
|
}
|
|
215
219
|
try {
|
|
216
|
-
const {postData} = await manager
|
|
220
|
+
const {postData} = await manager.#networkAgent.invoke_getRequestPostData({requestId});
|
|
217
221
|
return postData;
|
|
218
222
|
} catch (e) {
|
|
219
223
|
return e.message;
|
|
@@ -247,7 +251,7 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
private cacheDisabledSettingChanged({data: enabled}: Common.EventTarget.EventTargetEvent<boolean>): void {
|
|
250
|
-
this
|
|
254
|
+
this.#networkAgent.invoke_setCacheDisabled({cacheDisabled: enabled});
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
dispose(): void {
|
|
@@ -257,12 +261,12 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
private bypassServiceWorkerChanged(): void {
|
|
260
|
-
this
|
|
264
|
+
this.#networkAgent.invoke_setBypassServiceWorker({bypass: this.#bypassServiceWorkerSetting.get()});
|
|
261
265
|
}
|
|
262
266
|
|
|
263
267
|
async getSecurityIsolationStatus(frameId: Protocol.Page.FrameId|
|
|
264
268
|
null): Promise<Protocol.Network.SecurityIsolationStatus|null> {
|
|
265
|
-
const result = await this
|
|
269
|
+
const result = await this.#networkAgent.invoke_getSecurityIsolationStatus({frameId: frameId ?? undefined});
|
|
266
270
|
if (result.getError()) {
|
|
267
271
|
return null;
|
|
268
272
|
}
|
|
@@ -270,13 +274,13 @@ export class NetworkManager extends SDKModel<EventTypes> {
|
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
async enableReportingApi(enable: boolean = true): Promise<Promise<Protocol.ProtocolResponseWithError>> {
|
|
273
|
-
return this
|
|
277
|
+
return this.#networkAgent.invoke_enableReportingApi({enable});
|
|
274
278
|
}
|
|
275
279
|
|
|
276
280
|
async loadNetworkResource(
|
|
277
281
|
frameId: Protocol.Page.FrameId|null, url: string,
|
|
278
282
|
options: Protocol.Network.LoadNetworkResourceOptions): Promise<Protocol.Network.LoadNetworkResourcePageResult> {
|
|
279
|
-
const result = await this
|
|
283
|
+
const result = await this.#networkAgent.invoke_loadNetworkResource({frameId: frameId ?? undefined, url, options});
|
|
280
284
|
if (result.getError()) {
|
|
281
285
|
throw new Error(result.getError());
|
|
282
286
|
}
|
|
@@ -367,16 +371,16 @@ export const Fast3GConditions: Conditions = {
|
|
|
367
371
|
const MAX_EAGER_POST_REQUEST_BODY_LENGTH = 64 * 1024; // bytes
|
|
368
372
|
|
|
369
373
|
export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
374
|
+
readonly #manager: NetworkManager;
|
|
375
|
+
#requestsById: Map<string, NetworkRequest>;
|
|
376
|
+
#requestsByURL: Map<string, NetworkRequest>;
|
|
377
|
+
#requestIdToExtraInfoBuilder: Map<string, ExtraInfoBuilder>;
|
|
378
|
+
readonly #requestIdToTrustTokenEvent: Map<string, Protocol.Network.TrustTokenOperationDoneEvent>;
|
|
375
379
|
constructor(manager: NetworkManager) {
|
|
376
|
-
this
|
|
377
|
-
this
|
|
378
|
-
this
|
|
379
|
-
this
|
|
380
|
+
this.#manager = manager;
|
|
381
|
+
this.#requestsById = new Map();
|
|
382
|
+
this.#requestsByURL = new Map();
|
|
383
|
+
this.#requestIdToExtraInfoBuilder = new Map();
|
|
380
384
|
/**
|
|
381
385
|
* In case of an early abort or a cache hit, the Trust Token done event is
|
|
382
386
|
* reported before the request itself is created in `requestWillBeSent`.
|
|
@@ -385,7 +389,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
385
389
|
* This map caches the events temporarliy and populates the NetworKRequest
|
|
386
390
|
* once it is created in `requestWillBeSent`.
|
|
387
391
|
*/
|
|
388
|
-
this
|
|
392
|
+
this.#requestIdToTrustTokenEvent = new Map();
|
|
389
393
|
}
|
|
390
394
|
|
|
391
395
|
private headersMapToHeadersArray(headersMap: Protocol.Network.Headers): NameValue[] {
|
|
@@ -427,7 +431,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
427
431
|
if (response.requestHeaders && !networkRequest.hasExtraRequestInfo()) {
|
|
428
432
|
// TODO(http://crbug.com/1004979): Stop using response.requestHeaders and
|
|
429
433
|
// response.requestHeadersText once shared workers
|
|
430
|
-
// emit Network.*ExtraInfo events for their network requests.
|
|
434
|
+
// emit Network.*ExtraInfo events for their network #requests.
|
|
431
435
|
networkRequest.setRequestHeaders(this.headersMapToHeadersArray(response.requestHeaders));
|
|
432
436
|
networkRequest.setRequestHeadersText(response.requestHeadersText || '');
|
|
433
437
|
}
|
|
@@ -479,15 +483,15 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
479
483
|
}
|
|
480
484
|
|
|
481
485
|
requestForId(url: string): NetworkRequest|null {
|
|
482
|
-
return this
|
|
486
|
+
return this.#requestsById.get(url) || null;
|
|
483
487
|
}
|
|
484
488
|
|
|
485
489
|
requestForURL(url: string): NetworkRequest|null {
|
|
486
|
-
return this
|
|
490
|
+
return this.#requestsByURL.get(url) || null;
|
|
487
491
|
}
|
|
488
492
|
|
|
489
493
|
resourceChangedPriority({requestId, newPriority}: Protocol.Network.ResourceChangedPriorityEvent): void {
|
|
490
|
-
const networkRequest = this
|
|
494
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
491
495
|
if (networkRequest) {
|
|
492
496
|
networkRequest.setPriority(newPriority);
|
|
493
497
|
}
|
|
@@ -503,14 +507,14 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
503
507
|
// 3. The second requestWillBeSent is sent with the generated redirect
|
|
504
508
|
// response and a new redirected request which URL is the inner request
|
|
505
509
|
// URL of the signed exchange.
|
|
506
|
-
let networkRequest = this
|
|
507
|
-
// |requestId| is available only for navigation requests. If the request was
|
|
510
|
+
let networkRequest = this.#requestsById.get(requestId);
|
|
511
|
+
// |requestId| is available only for navigation #requests. If the request was
|
|
508
512
|
// sent from a renderer process for prefetching, it is not available. In the
|
|
509
513
|
// case, need to fallback to look for the URL.
|
|
510
514
|
// TODO(crbug/841076): Sends the request ID of prefetching to the browser
|
|
511
515
|
// process and DevTools to find the matching request.
|
|
512
516
|
if (!networkRequest) {
|
|
513
|
-
networkRequest = this
|
|
517
|
+
networkRequest = this.#requestsByURL.get(info.outerResponse.url);
|
|
514
518
|
if (!networkRequest) {
|
|
515
519
|
return;
|
|
516
520
|
}
|
|
@@ -520,14 +524,14 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
520
524
|
|
|
521
525
|
this.updateNetworkRequestWithResponse(networkRequest, info.outerResponse);
|
|
522
526
|
this.updateNetworkRequest(networkRequest);
|
|
523
|
-
this
|
|
527
|
+
this.#manager.dispatchEventToListeners(
|
|
524
528
|
Events.ResponseReceived, {request: networkRequest, response: info.outerResponse});
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
requestWillBeSent(
|
|
528
532
|
{requestId, loaderId, documentURL, request, timestamp, wallTime, initiator, redirectResponse, type, frameId}:
|
|
529
533
|
Protocol.Network.RequestWillBeSentEvent): void {
|
|
530
|
-
let networkRequest = this
|
|
534
|
+
let networkRequest = this.#requestsById.get(requestId);
|
|
531
535
|
if (networkRequest) {
|
|
532
536
|
// FIXME: move this check to the backend.
|
|
533
537
|
if (!redirectResponse) {
|
|
@@ -548,10 +552,10 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
548
552
|
});
|
|
549
553
|
}
|
|
550
554
|
networkRequest = this.appendRedirect(requestId, timestamp, request.url);
|
|
551
|
-
this
|
|
555
|
+
this.#manager.dispatchEventToListeners(Events.RequestRedirected, networkRequest);
|
|
552
556
|
} else {
|
|
553
557
|
networkRequest = NetworkRequest.create(requestId, request.url, documentURL, frameId ?? null, loaderId, initiator);
|
|
554
|
-
requestToManagerMap.set(networkRequest, this
|
|
558
|
+
requestToManagerMap.set(networkRequest, this.#manager);
|
|
555
559
|
}
|
|
556
560
|
networkRequest.hasNetworkData = true;
|
|
557
561
|
this.updateNetworkRequestWithRequest(networkRequest, request);
|
|
@@ -561,10 +565,10 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
561
565
|
if (request.trustTokenParams) {
|
|
562
566
|
networkRequest.setTrustTokenParams(request.trustTokenParams);
|
|
563
567
|
}
|
|
564
|
-
const maybeTrustTokenEvent = this
|
|
568
|
+
const maybeTrustTokenEvent = this.#requestIdToTrustTokenEvent.get(requestId);
|
|
565
569
|
if (maybeTrustTokenEvent) {
|
|
566
570
|
networkRequest.setTrustTokenOperationDoneEvent(maybeTrustTokenEvent);
|
|
567
|
-
this
|
|
571
|
+
this.#requestIdToTrustTokenEvent.delete(requestId);
|
|
568
572
|
}
|
|
569
573
|
|
|
570
574
|
this.getExtraInfoBuilder(requestId).addRequest(networkRequest);
|
|
@@ -573,7 +577,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
573
577
|
}
|
|
574
578
|
|
|
575
579
|
requestServedFromCache({requestId}: Protocol.Network.RequestServedFromCacheEvent): void {
|
|
576
|
-
const networkRequest = this
|
|
580
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
577
581
|
if (!networkRequest) {
|
|
578
582
|
return;
|
|
579
583
|
}
|
|
@@ -583,7 +587,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
583
587
|
|
|
584
588
|
responseReceived({requestId, loaderId, timestamp, type, response, frameId}: Protocol.Network.ResponseReceivedEvent):
|
|
585
589
|
void {
|
|
586
|
-
const networkRequest = this
|
|
590
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
587
591
|
const lowercaseHeaders = NetworkManager.lowercaseHeaders(response.headers);
|
|
588
592
|
if (!networkRequest) {
|
|
589
593
|
const lastModifiedHeader = lowercaseHeaders['last-modified'];
|
|
@@ -596,7 +600,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
596
600
|
mimeType: response.mimeType,
|
|
597
601
|
lastModified: lastModifiedHeader ? new Date(lastModifiedHeader) : null,
|
|
598
602
|
};
|
|
599
|
-
this
|
|
603
|
+
this.#manager.dispatchEventToListeners(Events.RequestUpdateDropped, eventData);
|
|
600
604
|
return;
|
|
601
605
|
}
|
|
602
606
|
|
|
@@ -606,11 +610,11 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
606
610
|
this.updateNetworkRequestWithResponse(networkRequest, response);
|
|
607
611
|
|
|
608
612
|
this.updateNetworkRequest(networkRequest);
|
|
609
|
-
this
|
|
613
|
+
this.#manager.dispatchEventToListeners(Events.ResponseReceived, {request: networkRequest, response});
|
|
610
614
|
}
|
|
611
615
|
|
|
612
616
|
dataReceived({requestId, timestamp, dataLength, encodedDataLength}: Protocol.Network.DataReceivedEvent): void {
|
|
613
|
-
let networkRequest: NetworkRequest|null|undefined = this
|
|
617
|
+
let networkRequest: NetworkRequest|null|undefined = this.#requestsById.get(requestId);
|
|
614
618
|
if (!networkRequest) {
|
|
615
619
|
networkRequest = this.maybeAdoptMainResourceRequest(requestId);
|
|
616
620
|
}
|
|
@@ -629,7 +633,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
629
633
|
|
|
630
634
|
loadingFinished({requestId, timestamp: finishTime, encodedDataLength, shouldReportCorbBlocking}:
|
|
631
635
|
Protocol.Network.LoadingFinishedEvent): void {
|
|
632
|
-
let networkRequest: NetworkRequest|null|undefined = this
|
|
636
|
+
let networkRequest: NetworkRequest|null|undefined = this.#requestsById.get(requestId);
|
|
633
637
|
if (!networkRequest) {
|
|
634
638
|
networkRequest = this.maybeAdoptMainResourceRequest(requestId);
|
|
635
639
|
}
|
|
@@ -638,7 +642,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
638
642
|
}
|
|
639
643
|
this.getExtraInfoBuilder(requestId).finished();
|
|
640
644
|
this.finishNetworkRequest(networkRequest, finishTime, encodedDataLength, shouldReportCorbBlocking);
|
|
641
|
-
this
|
|
645
|
+
this.#manager.dispatchEventToListeners(Events.LoadingFinished, networkRequest);
|
|
642
646
|
}
|
|
643
647
|
|
|
644
648
|
loadingFailed({
|
|
@@ -650,7 +654,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
650
654
|
blockedReason,
|
|
651
655
|
corsErrorStatus,
|
|
652
656
|
}: Protocol.Network.LoadingFailedEvent): void {
|
|
653
|
-
const networkRequest = this
|
|
657
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
654
658
|
if (!networkRequest) {
|
|
655
659
|
return;
|
|
656
660
|
}
|
|
@@ -662,7 +666,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
662
666
|
networkRequest.setBlockedReason(blockedReason);
|
|
663
667
|
if (blockedReason === Protocol.Network.BlockedReason.Inspector) {
|
|
664
668
|
const message = i18nString(UIStrings.requestWasBlockedByDevtoolsS, {PH1: networkRequest.url()});
|
|
665
|
-
this
|
|
669
|
+
this.#manager.dispatchEventToListeners(
|
|
666
670
|
Events.MessageGenerated, {message: message, requestId: requestId, warning: true});
|
|
667
671
|
}
|
|
668
672
|
}
|
|
@@ -676,14 +680,14 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
676
680
|
|
|
677
681
|
webSocketCreated({requestId, url: requestURL, initiator}: Protocol.Network.WebSocketCreatedEvent): void {
|
|
678
682
|
const networkRequest = NetworkRequest.createForWebSocket(requestId, requestURL, initiator);
|
|
679
|
-
requestToManagerMap.set(networkRequest, this
|
|
683
|
+
requestToManagerMap.set(networkRequest, this.#manager);
|
|
680
684
|
networkRequest.setResourceType(Common.ResourceType.resourceTypes.WebSocket);
|
|
681
685
|
this.startNetworkRequest(networkRequest, null);
|
|
682
686
|
}
|
|
683
687
|
|
|
684
688
|
webSocketWillSendHandshakeRequest({requestId, timestamp: time, wallTime, request}:
|
|
685
689
|
Protocol.Network.WebSocketWillSendHandshakeRequestEvent): void {
|
|
686
|
-
const networkRequest = this
|
|
690
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
687
691
|
if (!networkRequest) {
|
|
688
692
|
return;
|
|
689
693
|
}
|
|
@@ -697,7 +701,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
697
701
|
|
|
698
702
|
webSocketHandshakeResponseReceived({requestId, timestamp: time, response}:
|
|
699
703
|
Protocol.Network.WebSocketHandshakeResponseReceivedEvent): void {
|
|
700
|
-
const networkRequest = this
|
|
704
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
701
705
|
if (!networkRequest) {
|
|
702
706
|
return;
|
|
703
707
|
}
|
|
@@ -719,7 +723,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
719
723
|
}
|
|
720
724
|
|
|
721
725
|
webSocketFrameReceived({requestId, timestamp: time, response}: Protocol.Network.WebSocketFrameReceivedEvent): void {
|
|
722
|
-
const networkRequest = this
|
|
726
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
723
727
|
if (!networkRequest) {
|
|
724
728
|
return;
|
|
725
729
|
}
|
|
@@ -731,7 +735,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
731
735
|
}
|
|
732
736
|
|
|
733
737
|
webSocketFrameSent({requestId, timestamp: time, response}: Protocol.Network.WebSocketFrameSentEvent): void {
|
|
734
|
-
const networkRequest = this
|
|
738
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
735
739
|
if (!networkRequest) {
|
|
736
740
|
return;
|
|
737
741
|
}
|
|
@@ -743,7 +747,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
743
747
|
}
|
|
744
748
|
|
|
745
749
|
webSocketFrameError({requestId, timestamp: time, errorMessage}: Protocol.Network.WebSocketFrameErrorEvent): void {
|
|
746
|
-
const networkRequest = this
|
|
750
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
747
751
|
if (!networkRequest) {
|
|
748
752
|
return;
|
|
749
753
|
}
|
|
@@ -755,7 +759,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
755
759
|
}
|
|
756
760
|
|
|
757
761
|
webSocketClosed({requestId, timestamp: time}: Protocol.Network.WebSocketClosedEvent): void {
|
|
758
|
-
const networkRequest = this
|
|
762
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
759
763
|
if (!networkRequest) {
|
|
760
764
|
return;
|
|
761
765
|
}
|
|
@@ -764,7 +768,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
764
768
|
|
|
765
769
|
eventSourceMessageReceived({requestId, timestamp: time, eventName, eventId, data}:
|
|
766
770
|
Protocol.Network.EventSourceMessageReceivedEvent): void {
|
|
767
|
-
const networkRequest = this
|
|
771
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
768
772
|
if (!networkRequest) {
|
|
769
773
|
return;
|
|
770
774
|
}
|
|
@@ -786,7 +790,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
786
790
|
requestId,
|
|
787
791
|
}: Protocol.Network.RequestInterceptedEvent): void {
|
|
788
792
|
MultitargetNetworkManager.instance().requestIntercepted(new InterceptedRequest(
|
|
789
|
-
this
|
|
793
|
+
this.#manager.target().networkAgent(), interceptionId, request, frameId, resourceType, isNavigationRequest,
|
|
790
794
|
isDownload, redirectUrl, authChallenge, responseErrorReason, responseStatusCode, responseHeaders, requestId));
|
|
791
795
|
}
|
|
792
796
|
|
|
@@ -831,17 +835,17 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
831
835
|
|
|
832
836
|
private getExtraInfoBuilder(requestId: string): ExtraInfoBuilder {
|
|
833
837
|
let builder: ExtraInfoBuilder;
|
|
834
|
-
if (!this
|
|
838
|
+
if (!this.#requestIdToExtraInfoBuilder.has(requestId)) {
|
|
835
839
|
builder = new ExtraInfoBuilder();
|
|
836
|
-
this
|
|
840
|
+
this.#requestIdToExtraInfoBuilder.set(requestId, builder);
|
|
837
841
|
} else {
|
|
838
|
-
builder = (this
|
|
842
|
+
builder = (this.#requestIdToExtraInfoBuilder.get(requestId) as ExtraInfoBuilder);
|
|
839
843
|
}
|
|
840
844
|
return builder;
|
|
841
845
|
}
|
|
842
846
|
|
|
843
847
|
private appendRedirect(requestId: Protocol.Network.RequestId, time: number, redirectURL: string): NetworkRequest {
|
|
844
|
-
const originalNetworkRequest = this
|
|
848
|
+
const originalNetworkRequest = this.#requestsById.get(requestId);
|
|
845
849
|
if (!originalNetworkRequest) {
|
|
846
850
|
throw new Error(`Could not find original network request for ${requestId}`);
|
|
847
851
|
}
|
|
@@ -855,7 +859,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
855
859
|
const newNetworkRequest = NetworkRequest.create(
|
|
856
860
|
requestId, redirectURL, originalNetworkRequest.documentURL, originalNetworkRequest.frameId,
|
|
857
861
|
originalNetworkRequest.loaderId, originalNetworkRequest.initiator());
|
|
858
|
-
requestToManagerMap.set(newNetworkRequest, this
|
|
862
|
+
requestToManagerMap.set(newNetworkRequest, this.#manager);
|
|
859
863
|
newNetworkRequest.setRedirectSource(originalNetworkRequest);
|
|
860
864
|
originalNetworkRequest.setRedirectDestination(newNetworkRequest);
|
|
861
865
|
return newNetworkRequest;
|
|
@@ -867,28 +871,28 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
867
871
|
return null;
|
|
868
872
|
}
|
|
869
873
|
const oldDispatcher = (NetworkManager.forRequest(request) as NetworkManager).dispatcher;
|
|
870
|
-
oldDispatcher
|
|
871
|
-
oldDispatcher
|
|
872
|
-
this
|
|
873
|
-
this
|
|
874
|
-
requestToManagerMap.set(request, this
|
|
874
|
+
oldDispatcher.#requestsById.delete(requestId);
|
|
875
|
+
oldDispatcher.#requestsByURL.delete(request.url());
|
|
876
|
+
this.#requestsById.set(requestId, request);
|
|
877
|
+
this.#requestsByURL.set(request.url(), request);
|
|
878
|
+
requestToManagerMap.set(request, this.#manager);
|
|
875
879
|
return request;
|
|
876
880
|
}
|
|
877
881
|
|
|
878
882
|
private startNetworkRequest(networkRequest: NetworkRequest, originalRequest: Protocol.Network.Request|null): void {
|
|
879
|
-
this
|
|
880
|
-
this
|
|
883
|
+
this.#requestsById.set(networkRequest.requestId(), networkRequest);
|
|
884
|
+
this.#requestsByURL.set(networkRequest.url(), networkRequest);
|
|
881
885
|
// The following relies on the fact that loaderIds and requestIds are
|
|
882
886
|
// globally unique and that the main request has them equal.
|
|
883
887
|
if (networkRequest.loaderId === networkRequest.requestId()) {
|
|
884
888
|
MultitargetNetworkManager.instance().inflightMainResourceRequests.set(networkRequest.requestId(), networkRequest);
|
|
885
889
|
}
|
|
886
890
|
|
|
887
|
-
this
|
|
891
|
+
this.#manager.dispatchEventToListeners(Events.RequestStarted, {request: networkRequest, originalRequest});
|
|
888
892
|
}
|
|
889
893
|
|
|
890
894
|
private updateNetworkRequest(networkRequest: NetworkRequest): void {
|
|
891
|
-
this
|
|
895
|
+
this.#manager.dispatchEventToListeners(Events.RequestUpdated, networkRequest);
|
|
892
896
|
}
|
|
893
897
|
|
|
894
898
|
private finishNetworkRequest(
|
|
@@ -906,13 +910,13 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
906
910
|
networkRequest.setTransferSize(encodedDataLength);
|
|
907
911
|
}
|
|
908
912
|
}
|
|
909
|
-
this
|
|
913
|
+
this.#manager.dispatchEventToListeners(Events.RequestFinished, networkRequest);
|
|
910
914
|
MultitargetNetworkManager.instance().inflightMainResourceRequests.delete(networkRequest.requestId());
|
|
911
915
|
|
|
912
916
|
if (shouldReportCorbBlocking) {
|
|
913
917
|
const message =
|
|
914
918
|
i18nString(UIStrings.crossoriginReadBlockingCorb, {PH1: networkRequest.url(), PH2: networkRequest.mimeType});
|
|
915
|
-
this
|
|
919
|
+
this.#manager.dispatchEventToListeners(
|
|
916
920
|
Events.MessageGenerated, {message: message, requestId: networkRequest.requestId(), warning: true});
|
|
917
921
|
}
|
|
918
922
|
|
|
@@ -930,22 +934,22 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
930
934
|
{PH1: networkRequest.resourceType().title(), PH2: networkRequest.requestMethod, PH3: networkRequest.url()});
|
|
931
935
|
}
|
|
932
936
|
|
|
933
|
-
this
|
|
937
|
+
this.#manager.dispatchEventToListeners(
|
|
934
938
|
Events.MessageGenerated, {message: message, requestId: networkRequest.requestId(), warning: false});
|
|
935
939
|
}
|
|
936
940
|
}
|
|
937
941
|
|
|
938
942
|
clearRequests(): void {
|
|
939
|
-
this
|
|
940
|
-
this
|
|
941
|
-
this
|
|
943
|
+
this.#requestsById.clear();
|
|
944
|
+
this.#requestsByURL.clear();
|
|
945
|
+
this.#requestIdToExtraInfoBuilder.clear();
|
|
942
946
|
}
|
|
943
947
|
|
|
944
948
|
webTransportCreated({transportId, url: requestURL, timestamp: time, initiator}:
|
|
945
949
|
Protocol.Network.WebTransportCreatedEvent): void {
|
|
946
950
|
const networkRequest = NetworkRequest.createForWebSocket(transportId, requestURL, initiator);
|
|
947
951
|
networkRequest.hasNetworkData = true;
|
|
948
|
-
requestToManagerMap.set(networkRequest, this
|
|
952
|
+
requestToManagerMap.set(networkRequest, this.#manager);
|
|
949
953
|
networkRequest.setResourceType(Common.ResourceType.resourceTypes.WebTransport);
|
|
950
954
|
networkRequest.setIssueTime(time, 0);
|
|
951
955
|
// TODO(yoichio): Add appropreate events to address abort cases.
|
|
@@ -954,7 +958,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
954
958
|
|
|
955
959
|
webTransportConnectionEstablished({transportId, timestamp: time}:
|
|
956
960
|
Protocol.Network.WebTransportConnectionEstablishedEvent): void {
|
|
957
|
-
const networkRequest = this
|
|
961
|
+
const networkRequest = this.#requestsById.get(transportId);
|
|
958
962
|
if (!networkRequest) {
|
|
959
963
|
return;
|
|
960
964
|
}
|
|
@@ -969,7 +973,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
969
973
|
}
|
|
970
974
|
|
|
971
975
|
webTransportClosed({transportId, timestamp: time}: Protocol.Network.WebTransportClosedEvent): void {
|
|
972
|
-
const networkRequest = this
|
|
976
|
+
const networkRequest = this.#requestsById.get(transportId);
|
|
973
977
|
if (!networkRequest) {
|
|
974
978
|
return;
|
|
975
979
|
}
|
|
@@ -979,9 +983,9 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
979
983
|
}
|
|
980
984
|
|
|
981
985
|
trustTokenOperationDone(event: Protocol.Network.TrustTokenOperationDoneEvent): void {
|
|
982
|
-
const request = this
|
|
986
|
+
const request = this.#requestsById.get(event.requestId);
|
|
983
987
|
if (!request) {
|
|
984
|
-
this
|
|
988
|
+
this.#requestIdToTrustTokenEvent.set(event.requestId, event);
|
|
985
989
|
return;
|
|
986
990
|
}
|
|
987
991
|
request.setTrustTokenOperationDoneEvent(event);
|
|
@@ -1028,11 +1032,11 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
1028
1032
|
}
|
|
1029
1033
|
|
|
1030
1034
|
reportingApiReportAdded(data: Protocol.Network.ReportingApiReportAddedEvent): void {
|
|
1031
|
-
this
|
|
1035
|
+
this.#manager.dispatchEventToListeners(Events.ReportingApiReportAdded, data.report);
|
|
1032
1036
|
}
|
|
1033
1037
|
|
|
1034
1038
|
reportingApiReportUpdated(data: Protocol.Network.ReportingApiReportUpdatedEvent): void {
|
|
1035
|
-
this
|
|
1039
|
+
this.#manager.dispatchEventToListeners(Events.ReportingApiReportUpdated, data.report);
|
|
1036
1040
|
}
|
|
1037
1041
|
|
|
1038
1042
|
/**
|
|
@@ -1043,7 +1047,7 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
|
|
|
1043
1047
|
requestId: Protocol.Network.RequestId, frameId: Protocol.Page.FrameId, loaderId: Protocol.Network.LoaderId,
|
|
1044
1048
|
url: string, documentURL: string, initiator: Protocol.Network.Initiator|null): NetworkRequest {
|
|
1045
1049
|
const request = NetworkRequest.create(requestId, url, documentURL, frameId, loaderId, initiator);
|
|
1046
|
-
requestToManagerMap.set(request, this
|
|
1050
|
+
requestToManagerMap.set(request, this.#manager);
|
|
1047
1051
|
return request;
|
|
1048
1052
|
}
|
|
1049
1053
|
}
|
|
@@ -1052,38 +1056,38 @@ let multiTargetNetworkManagerInstance: MultitargetNetworkManager|null;
|
|
|
1052
1056
|
|
|
1053
1057
|
export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrapper<MultitargetNetworkManager.EventTypes>
|
|
1054
1058
|
implements SDKModelObserver<NetworkManager> {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
+
#userAgentOverrideInternal: string;
|
|
1060
|
+
#userAgentMetadataOverride: Protocol.Emulation.UserAgentMetadata|null;
|
|
1061
|
+
#customAcceptedEncodings: Protocol.Network.ContentEncoding[]|null;
|
|
1062
|
+
readonly #agents: Set<ProtocolProxyApi.NetworkApi>;
|
|
1059
1063
|
readonly inflightMainResourceRequests: Map<string, NetworkRequest>;
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1064
|
+
#networkConditionsInternal: Conditions;
|
|
1065
|
+
#updatingInterceptionPatternsPromise: Promise<void>|null;
|
|
1066
|
+
readonly #blockingEnabledSetting: Common.Settings.Setting<boolean>;
|
|
1067
|
+
readonly #blockedPatternsSetting: Common.Settings.Setting<BlockedPattern[]>;
|
|
1068
|
+
#effectiveBlockedURLs: string[];
|
|
1069
|
+
readonly #urlsForRequestInterceptor:
|
|
1066
1070
|
Platform.MapUtilities.Multimap<(arg0: InterceptedRequest) => Promise<void>, InterceptionPattern>;
|
|
1067
|
-
|
|
1068
|
-
|
|
1071
|
+
#extraHeaders?: Protocol.Network.Headers;
|
|
1072
|
+
#customUserAgent?: string;
|
|
1069
1073
|
|
|
1070
1074
|
constructor() {
|
|
1071
1075
|
super();
|
|
1072
|
-
this
|
|
1073
|
-
this
|
|
1074
|
-
this
|
|
1075
|
-
this
|
|
1076
|
+
this.#userAgentOverrideInternal = '';
|
|
1077
|
+
this.#userAgentMetadataOverride = null;
|
|
1078
|
+
this.#customAcceptedEncodings = null;
|
|
1079
|
+
this.#agents = new Set();
|
|
1076
1080
|
this.inflightMainResourceRequests = new Map();
|
|
1077
|
-
this
|
|
1078
|
-
this
|
|
1081
|
+
this.#networkConditionsInternal = NoThrottlingConditions;
|
|
1082
|
+
this.#updatingInterceptionPatternsPromise = null;
|
|
1079
1083
|
|
|
1080
1084
|
// TODO(allada) Remove these and merge it with request interception.
|
|
1081
|
-
this
|
|
1082
|
-
this
|
|
1083
|
-
this
|
|
1085
|
+
this.#blockingEnabledSetting = Common.Settings.Settings.instance().moduleSetting('requestBlockingEnabled');
|
|
1086
|
+
this.#blockedPatternsSetting = Common.Settings.Settings.instance().createSetting('networkBlockedPatterns', []);
|
|
1087
|
+
this.#effectiveBlockedURLs = [];
|
|
1084
1088
|
this.updateBlockedPatterns();
|
|
1085
1089
|
|
|
1086
|
-
this
|
|
1090
|
+
this.#urlsForRequestInterceptor = new Platform.MapUtilities.Multimap();
|
|
1087
1091
|
|
|
1088
1092
|
TargetManager.instance().observeModels(NetworkManager, this);
|
|
1089
1093
|
}
|
|
@@ -1109,7 +1113,7 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1109
1113
|
}
|
|
1110
1114
|
|
|
1111
1115
|
static patchUserAgentWithChromeVersion(uaString: string): string {
|
|
1112
|
-
// Patches Chrome/ChrOS version from user agent ("1.2.3.4" when user agent is: "Chrome/1.2.3.4").
|
|
1116
|
+
// Patches Chrome/ChrOS version from user #agent ("1.2.3.4" when user #agent is: "Chrome/1.2.3.4").
|
|
1113
1117
|
// Otherwise, ignore it. This assumes additional appVersions appear after the Chrome version.
|
|
1114
1118
|
const chromeVersion = MultitargetNetworkManager.getChromeVersion();
|
|
1115
1119
|
if (chromeVersion.length > 0) {
|
|
@@ -1121,7 +1125,7 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1121
1125
|
}
|
|
1122
1126
|
|
|
1123
1127
|
static patchUserAgentMetadataWithChromeVersion(userAgentMetadata: Protocol.Emulation.UserAgentMetadata): void {
|
|
1124
|
-
// Patches Chrome/ChrOS version from user agent metadata ("1.2.3.4" when user agent is: "Chrome/1.2.3.4").
|
|
1128
|
+
// Patches Chrome/ChrOS version from user #agent metadata ("1.2.3.4" when user #agent is: "Chrome/1.2.3.4").
|
|
1125
1129
|
// Otherwise, ignore it. This assumes additional appVersions appear after the Chrome version.
|
|
1126
1130
|
if (!userAgentMetadata.brands) {
|
|
1127
1131
|
return;
|
|
@@ -1147,25 +1151,25 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1147
1151
|
|
|
1148
1152
|
modelAdded(networkManager: NetworkManager): void {
|
|
1149
1153
|
const networkAgent = networkManager.target().networkAgent();
|
|
1150
|
-
if (this
|
|
1151
|
-
networkAgent.invoke_setExtraHTTPHeaders({headers: this
|
|
1154
|
+
if (this.#extraHeaders) {
|
|
1155
|
+
networkAgent.invoke_setExtraHTTPHeaders({headers: this.#extraHeaders});
|
|
1152
1156
|
}
|
|
1153
1157
|
if (this.currentUserAgent()) {
|
|
1154
1158
|
networkAgent.invoke_setUserAgentOverride(
|
|
1155
|
-
{userAgent: this.currentUserAgent(), userAgentMetadata: this
|
|
1159
|
+
{userAgent: this.currentUserAgent(), userAgentMetadata: this.#userAgentMetadataOverride || undefined});
|
|
1156
1160
|
}
|
|
1157
|
-
if (this
|
|
1158
|
-
networkAgent.invoke_setBlockedURLs({urls: this
|
|
1161
|
+
if (this.#effectiveBlockedURLs.length) {
|
|
1162
|
+
networkAgent.invoke_setBlockedURLs({urls: this.#effectiveBlockedURLs});
|
|
1159
1163
|
}
|
|
1160
1164
|
if (this.isIntercepting()) {
|
|
1161
|
-
networkAgent.invoke_setRequestInterception({patterns: this
|
|
1165
|
+
networkAgent.invoke_setRequestInterception({patterns: this.#urlsForRequestInterceptor.valuesArray()});
|
|
1162
1166
|
}
|
|
1163
|
-
if (this
|
|
1167
|
+
if (this.#customAcceptedEncodings === null) {
|
|
1164
1168
|
networkAgent.invoke_clearAcceptedEncodingsOverride();
|
|
1165
1169
|
} else {
|
|
1166
|
-
networkAgent.invoke_setAcceptedEncodings({encodings: this
|
|
1170
|
+
networkAgent.invoke_setAcceptedEncodings({encodings: this.#customAcceptedEncodings});
|
|
1167
1171
|
}
|
|
1168
|
-
this
|
|
1172
|
+
this.#agents.add(networkAgent);
|
|
1169
1173
|
if (this.isThrottling()) {
|
|
1170
1174
|
this.updateNetworkConditions(networkAgent);
|
|
1171
1175
|
}
|
|
@@ -1179,32 +1183,32 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1179
1183
|
}
|
|
1180
1184
|
this.inflightMainResourceRequests.delete((entry[0] as string));
|
|
1181
1185
|
}
|
|
1182
|
-
this
|
|
1186
|
+
this.#agents.delete(networkManager.target().networkAgent());
|
|
1183
1187
|
}
|
|
1184
1188
|
|
|
1185
1189
|
isThrottling(): boolean {
|
|
1186
|
-
return this
|
|
1187
|
-
this
|
|
1190
|
+
return this.#networkConditionsInternal.download >= 0 || this.#networkConditionsInternal.upload >= 0 ||
|
|
1191
|
+
this.#networkConditionsInternal.latency > 0;
|
|
1188
1192
|
}
|
|
1189
1193
|
|
|
1190
1194
|
isOffline(): boolean {
|
|
1191
|
-
return !this
|
|
1195
|
+
return !this.#networkConditionsInternal.download && !this.#networkConditionsInternal.upload;
|
|
1192
1196
|
}
|
|
1193
1197
|
|
|
1194
1198
|
setNetworkConditions(conditions: Conditions): void {
|
|
1195
|
-
this
|
|
1196
|
-
for (const agent of this
|
|
1199
|
+
this.#networkConditionsInternal = conditions;
|
|
1200
|
+
for (const agent of this.#agents) {
|
|
1197
1201
|
this.updateNetworkConditions(agent);
|
|
1198
1202
|
}
|
|
1199
1203
|
this.dispatchEventToListeners(MultitargetNetworkManager.Events.ConditionsChanged);
|
|
1200
1204
|
}
|
|
1201
1205
|
|
|
1202
1206
|
networkConditions(): Conditions {
|
|
1203
|
-
return this
|
|
1207
|
+
return this.#networkConditionsInternal;
|
|
1204
1208
|
}
|
|
1205
1209
|
|
|
1206
1210
|
private updateNetworkConditions(networkAgent: ProtocolProxyApi.NetworkApi): void {
|
|
1207
|
-
const conditions = this
|
|
1211
|
+
const conditions = this.#networkConditionsInternal;
|
|
1208
1212
|
if (!this.isThrottling()) {
|
|
1209
1213
|
networkAgent.invoke_emulateNetworkConditions(
|
|
1210
1214
|
{offline: false, latency: 0, downloadThroughput: 0, uploadThroughput: 0});
|
|
@@ -1220,32 +1224,32 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1220
1224
|
}
|
|
1221
1225
|
|
|
1222
1226
|
setExtraHTTPHeaders(headers: Protocol.Network.Headers): void {
|
|
1223
|
-
this
|
|
1224
|
-
for (const agent of this
|
|
1225
|
-
agent.invoke_setExtraHTTPHeaders({headers: this
|
|
1227
|
+
this.#extraHeaders = headers;
|
|
1228
|
+
for (const agent of this.#agents) {
|
|
1229
|
+
agent.invoke_setExtraHTTPHeaders({headers: this.#extraHeaders});
|
|
1226
1230
|
}
|
|
1227
1231
|
}
|
|
1228
1232
|
|
|
1229
1233
|
currentUserAgent(): string {
|
|
1230
|
-
return this
|
|
1234
|
+
return this.#customUserAgent ? this.#customUserAgent : this.#userAgentOverrideInternal;
|
|
1231
1235
|
}
|
|
1232
1236
|
|
|
1233
1237
|
private updateUserAgentOverride(): void {
|
|
1234
1238
|
const userAgent = this.currentUserAgent();
|
|
1235
|
-
for (const agent of this
|
|
1239
|
+
for (const agent of this.#agents) {
|
|
1236
1240
|
agent.invoke_setUserAgentOverride(
|
|
1237
|
-
{userAgent: userAgent, userAgentMetadata: this
|
|
1241
|
+
{userAgent: userAgent, userAgentMetadata: this.#userAgentMetadataOverride || undefined});
|
|
1238
1242
|
}
|
|
1239
1243
|
}
|
|
1240
1244
|
|
|
1241
1245
|
setUserAgentOverride(userAgent: string, userAgentMetadataOverride: Protocol.Emulation.UserAgentMetadata|null): void {
|
|
1242
|
-
const uaChanged = (this
|
|
1243
|
-
this
|
|
1244
|
-
if (!this
|
|
1245
|
-
this
|
|
1246
|
+
const uaChanged = (this.#userAgentOverrideInternal !== userAgent);
|
|
1247
|
+
this.#userAgentOverrideInternal = userAgent;
|
|
1248
|
+
if (!this.#customUserAgent) {
|
|
1249
|
+
this.#userAgentMetadataOverride = userAgentMetadataOverride;
|
|
1246
1250
|
this.updateUserAgentOverride();
|
|
1247
1251
|
} else {
|
|
1248
|
-
this
|
|
1252
|
+
this.#userAgentMetadataOverride = null;
|
|
1249
1253
|
}
|
|
1250
1254
|
|
|
1251
1255
|
if (uaChanged) {
|
|
@@ -1254,35 +1258,35 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1254
1258
|
}
|
|
1255
1259
|
|
|
1256
1260
|
userAgentOverride(): string {
|
|
1257
|
-
return this
|
|
1261
|
+
return this.#userAgentOverrideInternal;
|
|
1258
1262
|
}
|
|
1259
1263
|
|
|
1260
1264
|
setCustomUserAgentOverride(
|
|
1261
1265
|
userAgent: string, userAgentMetadataOverride: Protocol.Emulation.UserAgentMetadata|null = null): void {
|
|
1262
|
-
this
|
|
1263
|
-
this
|
|
1266
|
+
this.#customUserAgent = userAgent;
|
|
1267
|
+
this.#userAgentMetadataOverride = userAgentMetadataOverride;
|
|
1264
1268
|
this.updateUserAgentOverride();
|
|
1265
1269
|
}
|
|
1266
1270
|
|
|
1267
1271
|
setCustomAcceptedEncodingsOverride(acceptedEncodings: Protocol.Network.ContentEncoding[]): void {
|
|
1268
|
-
this
|
|
1272
|
+
this.#customAcceptedEncodings = acceptedEncodings;
|
|
1269
1273
|
this.updateAcceptedEncodingsOverride();
|
|
1270
1274
|
this.dispatchEventToListeners(MultitargetNetworkManager.Events.AcceptedEncodingsChanged);
|
|
1271
1275
|
}
|
|
1272
1276
|
|
|
1273
1277
|
clearCustomAcceptedEncodingsOverride(): void {
|
|
1274
|
-
this
|
|
1278
|
+
this.#customAcceptedEncodings = null;
|
|
1275
1279
|
this.updateAcceptedEncodingsOverride();
|
|
1276
1280
|
this.dispatchEventToListeners(MultitargetNetworkManager.Events.AcceptedEncodingsChanged);
|
|
1277
1281
|
}
|
|
1278
1282
|
|
|
1279
1283
|
isAcceptedEncodingOverrideSet(): boolean {
|
|
1280
|
-
return this
|
|
1284
|
+
return this.#customAcceptedEncodings !== null;
|
|
1281
1285
|
}
|
|
1282
1286
|
|
|
1283
1287
|
private updateAcceptedEncodingsOverride(): void {
|
|
1284
|
-
const customAcceptedEncodings = this
|
|
1285
|
-
for (const agent of this
|
|
1288
|
+
const customAcceptedEncodings = this.#customAcceptedEncodings;
|
|
1289
|
+
for (const agent of this.#agents) {
|
|
1286
1290
|
if (customAcceptedEncodings === null) {
|
|
1287
1291
|
agent.invoke_clearAcceptedEncodingsOverride();
|
|
1288
1292
|
} else {
|
|
@@ -1293,88 +1297,88 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1293
1297
|
|
|
1294
1298
|
// TODO(allada) Move all request blocking into interception and let view manage blocking.
|
|
1295
1299
|
blockedPatterns(): BlockedPattern[] {
|
|
1296
|
-
return this
|
|
1300
|
+
return this.#blockedPatternsSetting.get().slice();
|
|
1297
1301
|
}
|
|
1298
1302
|
|
|
1299
1303
|
blockingEnabled(): boolean {
|
|
1300
|
-
return this
|
|
1304
|
+
return this.#blockingEnabledSetting.get();
|
|
1301
1305
|
}
|
|
1302
1306
|
|
|
1303
1307
|
isBlocking(): boolean {
|
|
1304
|
-
return Boolean(this
|
|
1308
|
+
return Boolean(this.#effectiveBlockedURLs.length);
|
|
1305
1309
|
}
|
|
1306
1310
|
|
|
1307
1311
|
setBlockedPatterns(patterns: BlockedPattern[]): void {
|
|
1308
|
-
this
|
|
1312
|
+
this.#blockedPatternsSetting.set(patterns);
|
|
1309
1313
|
this.updateBlockedPatterns();
|
|
1310
1314
|
this.dispatchEventToListeners(MultitargetNetworkManager.Events.BlockedPatternsChanged);
|
|
1311
1315
|
}
|
|
1312
1316
|
|
|
1313
1317
|
setBlockingEnabled(enabled: boolean): void {
|
|
1314
|
-
if (this
|
|
1318
|
+
if (this.#blockingEnabledSetting.get() === enabled) {
|
|
1315
1319
|
return;
|
|
1316
1320
|
}
|
|
1317
|
-
this
|
|
1321
|
+
this.#blockingEnabledSetting.set(enabled);
|
|
1318
1322
|
this.updateBlockedPatterns();
|
|
1319
1323
|
this.dispatchEventToListeners(MultitargetNetworkManager.Events.BlockedPatternsChanged);
|
|
1320
1324
|
}
|
|
1321
1325
|
|
|
1322
1326
|
private updateBlockedPatterns(): void {
|
|
1323
1327
|
const urls = [];
|
|
1324
|
-
if (this
|
|
1325
|
-
for (const pattern of this
|
|
1328
|
+
if (this.#blockingEnabledSetting.get()) {
|
|
1329
|
+
for (const pattern of this.#blockedPatternsSetting.get()) {
|
|
1326
1330
|
if (pattern.enabled) {
|
|
1327
1331
|
urls.push(pattern.url);
|
|
1328
1332
|
}
|
|
1329
1333
|
}
|
|
1330
1334
|
}
|
|
1331
1335
|
|
|
1332
|
-
if (!urls.length && !this
|
|
1336
|
+
if (!urls.length && !this.#effectiveBlockedURLs.length) {
|
|
1333
1337
|
return;
|
|
1334
1338
|
}
|
|
1335
|
-
this
|
|
1336
|
-
for (const agent of this
|
|
1337
|
-
agent.invoke_setBlockedURLs({urls: this
|
|
1339
|
+
this.#effectiveBlockedURLs = urls;
|
|
1340
|
+
for (const agent of this.#agents) {
|
|
1341
|
+
agent.invoke_setBlockedURLs({urls: this.#effectiveBlockedURLs});
|
|
1338
1342
|
}
|
|
1339
1343
|
}
|
|
1340
1344
|
|
|
1341
1345
|
isIntercepting(): boolean {
|
|
1342
|
-
return Boolean(this
|
|
1346
|
+
return Boolean(this.#urlsForRequestInterceptor.size);
|
|
1343
1347
|
}
|
|
1344
1348
|
|
|
1345
1349
|
setInterceptionHandlerForPatterns(
|
|
1346
1350
|
patterns: InterceptionPattern[], requestInterceptor: (arg0: InterceptedRequest) => Promise<void>): Promise<void> {
|
|
1347
|
-
// Note: requestInterceptors may recieve interception requests for patterns they did not subscribe to.
|
|
1348
|
-
this
|
|
1351
|
+
// Note: requestInterceptors may recieve interception #requests for patterns they did not subscribe to.
|
|
1352
|
+
this.#urlsForRequestInterceptor.deleteAll(requestInterceptor);
|
|
1349
1353
|
for (const newPattern of patterns) {
|
|
1350
|
-
this
|
|
1354
|
+
this.#urlsForRequestInterceptor.set(requestInterceptor, newPattern);
|
|
1351
1355
|
}
|
|
1352
1356
|
return this.updateInterceptionPatternsOnNextTick();
|
|
1353
1357
|
}
|
|
1354
1358
|
|
|
1355
1359
|
private updateInterceptionPatternsOnNextTick(): Promise<void> {
|
|
1356
1360
|
// This is used so we can register and unregister patterns in loops without sending lots of protocol messages.
|
|
1357
|
-
if (!this
|
|
1358
|
-
this
|
|
1361
|
+
if (!this.#updatingInterceptionPatternsPromise) {
|
|
1362
|
+
this.#updatingInterceptionPatternsPromise = Promise.resolve().then(this.updateInterceptionPatterns.bind(this));
|
|
1359
1363
|
}
|
|
1360
|
-
return this
|
|
1364
|
+
return this.#updatingInterceptionPatternsPromise;
|
|
1361
1365
|
}
|
|
1362
1366
|
|
|
1363
1367
|
private async updateInterceptionPatterns(): Promise<void> {
|
|
1364
1368
|
if (!Common.Settings.Settings.instance().moduleSetting('cacheDisabled').get()) {
|
|
1365
1369
|
Common.Settings.Settings.instance().moduleSetting('cacheDisabled').set(true);
|
|
1366
1370
|
}
|
|
1367
|
-
this
|
|
1371
|
+
this.#updatingInterceptionPatternsPromise = null;
|
|
1368
1372
|
const promises = ([] as Promise<unknown>[]);
|
|
1369
|
-
for (const agent of this
|
|
1370
|
-
promises.push(agent.invoke_setRequestInterception({patterns: this
|
|
1373
|
+
for (const agent of this.#agents) {
|
|
1374
|
+
promises.push(agent.invoke_setRequestInterception({patterns: this.#urlsForRequestInterceptor.valuesArray()}));
|
|
1371
1375
|
}
|
|
1372
1376
|
this.dispatchEventToListeners(MultitargetNetworkManager.Events.InterceptorsChanged);
|
|
1373
1377
|
await Promise.all(promises);
|
|
1374
1378
|
}
|
|
1375
1379
|
|
|
1376
1380
|
async requestIntercepted(interceptedRequest: InterceptedRequest): Promise<void> {
|
|
1377
|
-
for (const requestInterceptor of this
|
|
1381
|
+
for (const requestInterceptor of this.#urlsForRequestInterceptor.keysArray()) {
|
|
1378
1382
|
await requestInterceptor(interceptedRequest);
|
|
1379
1383
|
if (interceptedRequest.hasResponded()) {
|
|
1380
1384
|
return;
|
|
@@ -1386,13 +1390,13 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1386
1390
|
}
|
|
1387
1391
|
|
|
1388
1392
|
clearBrowserCache(): void {
|
|
1389
|
-
for (const agent of this
|
|
1393
|
+
for (const agent of this.#agents) {
|
|
1390
1394
|
agent.invoke_clearBrowserCache();
|
|
1391
1395
|
}
|
|
1392
1396
|
}
|
|
1393
1397
|
|
|
1394
1398
|
clearBrowserCookies(): void {
|
|
1395
|
-
for (const agent of this
|
|
1399
|
+
for (const agent of this.#agents) {
|
|
1396
1400
|
agent.invoke_clearBrowserCookies();
|
|
1397
1401
|
}
|
|
1398
1402
|
}
|
|
@@ -1455,9 +1459,9 @@ export namespace MultitargetNetworkManager {
|
|
|
1455
1459
|
}
|
|
1456
1460
|
|
|
1457
1461
|
export class InterceptedRequest {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1462
|
+
readonly #networkAgent: ProtocolProxyApi.NetworkApi;
|
|
1463
|
+
readonly #interceptionId: Protocol.Network.InterceptionId;
|
|
1464
|
+
#hasRespondedInternal: boolean;
|
|
1461
1465
|
request: Protocol.Network.Request;
|
|
1462
1466
|
frameId: Protocol.Page.FrameId;
|
|
1463
1467
|
resourceType: Protocol.Network.ResourceType;
|
|
@@ -1476,9 +1480,9 @@ export class InterceptedRequest {
|
|
|
1476
1480
|
isNavigationRequest: boolean, isDownload?: boolean, redirectUrl?: string,
|
|
1477
1481
|
authChallenge?: Protocol.Network.AuthChallenge, responseErrorReason?: Protocol.Network.ErrorReason,
|
|
1478
1482
|
responseStatusCode?: number, responseHeaders?: Protocol.Network.Headers, requestId?: string) {
|
|
1479
|
-
this
|
|
1480
|
-
this
|
|
1481
|
-
this
|
|
1483
|
+
this.#networkAgent = networkAgent;
|
|
1484
|
+
this.#interceptionId = interceptionId;
|
|
1485
|
+
this.#hasRespondedInternal = false;
|
|
1482
1486
|
this.request = request;
|
|
1483
1487
|
this.frameId = frameId;
|
|
1484
1488
|
this.resourceType = resourceType;
|
|
@@ -1493,11 +1497,11 @@ export class InterceptedRequest {
|
|
|
1493
1497
|
}
|
|
1494
1498
|
|
|
1495
1499
|
hasResponded(): boolean {
|
|
1496
|
-
return this
|
|
1500
|
+
return this.#hasRespondedInternal;
|
|
1497
1501
|
}
|
|
1498
1502
|
|
|
1499
1503
|
async continueRequestWithContent(contentBlob: Blob): Promise<void> {
|
|
1500
|
-
this
|
|
1504
|
+
this.#hasRespondedInternal = true;
|
|
1501
1505
|
const headers = [
|
|
1502
1506
|
'HTTP/1.1 200 OK',
|
|
1503
1507
|
'Date: ' + (new Date()).toUTCString(),
|
|
@@ -1507,8 +1511,8 @@ export class InterceptedRequest {
|
|
|
1507
1511
|
'Content-Type: ' + contentBlob.type || 'text/x-unknown',
|
|
1508
1512
|
];
|
|
1509
1513
|
const encodedResponse = await blobToBase64(new Blob([headers.join('\r\n'), '\r\n\r\n', contentBlob]));
|
|
1510
|
-
this
|
|
1511
|
-
{interceptionId: this
|
|
1514
|
+
this.#networkAgent.invoke_continueInterceptedRequest(
|
|
1515
|
+
{interceptionId: this.#interceptionId, rawResponse: encodedResponse});
|
|
1512
1516
|
|
|
1513
1517
|
async function blobToBase64(blob: Blob): Promise<string> {
|
|
1514
1518
|
const reader = new FileReader();
|
|
@@ -1531,113 +1535,113 @@ export class InterceptedRequest {
|
|
|
1531
1535
|
}
|
|
1532
1536
|
|
|
1533
1537
|
continueRequestWithoutChange(): void {
|
|
1534
|
-
console.assert(!this
|
|
1535
|
-
this
|
|
1536
|
-
this
|
|
1538
|
+
console.assert(!this.#hasRespondedInternal);
|
|
1539
|
+
this.#hasRespondedInternal = true;
|
|
1540
|
+
this.#networkAgent.invoke_continueInterceptedRequest({interceptionId: this.#interceptionId});
|
|
1537
1541
|
}
|
|
1538
1542
|
|
|
1539
1543
|
continueRequestWithError(errorReason: Protocol.Network.ErrorReason): void {
|
|
1540
|
-
console.assert(!this
|
|
1541
|
-
this
|
|
1542
|
-
this
|
|
1544
|
+
console.assert(!this.#hasRespondedInternal);
|
|
1545
|
+
this.#hasRespondedInternal = true;
|
|
1546
|
+
this.#networkAgent.invoke_continueInterceptedRequest({interceptionId: this.#interceptionId, errorReason});
|
|
1543
1547
|
}
|
|
1544
1548
|
|
|
1545
1549
|
async responseBody(): Promise<ContentData> {
|
|
1546
1550
|
const response =
|
|
1547
|
-
await this
|
|
1551
|
+
await this.#networkAgent.invoke_getResponseBodyForInterception({interceptionId: this.#interceptionId});
|
|
1548
1552
|
const error = response.getError() || null;
|
|
1549
1553
|
return {error: error, content: error ? null : response.body, encoded: response.base64Encoded};
|
|
1550
1554
|
}
|
|
1551
1555
|
}
|
|
1552
1556
|
|
|
1553
1557
|
/**
|
|
1554
|
-
* Helper class to match requests created from requestWillBeSent with
|
|
1558
|
+
* Helper class to match #requests created from requestWillBeSent with
|
|
1555
1559
|
* requestWillBeSentExtraInfo and responseReceivedExtraInfo when they have the
|
|
1556
1560
|
* same requestId due to redirects.
|
|
1557
1561
|
*/
|
|
1558
1562
|
class ExtraInfoBuilder {
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1563
|
+
readonly #requests: NetworkRequest[];
|
|
1564
|
+
#requestExtraInfos: (ExtraRequestInfo|null)[];
|
|
1565
|
+
#responseExtraInfos: (ExtraResponseInfo|null)[];
|
|
1566
|
+
#finishedInternal: boolean;
|
|
1567
|
+
#hasExtraInfo: boolean;
|
|
1568
|
+
#webBundleInfo: WebBundleInfo|null;
|
|
1569
|
+
#webBundleInnerRequestInfo: WebBundleInnerRequestInfo|null;
|
|
1566
1570
|
|
|
1567
1571
|
constructor() {
|
|
1568
|
-
this
|
|
1569
|
-
this
|
|
1570
|
-
this
|
|
1571
|
-
this
|
|
1572
|
-
this
|
|
1573
|
-
this
|
|
1574
|
-
this
|
|
1572
|
+
this.#requests = [];
|
|
1573
|
+
this.#requestExtraInfos = [];
|
|
1574
|
+
this.#responseExtraInfos = [];
|
|
1575
|
+
this.#finishedInternal = false;
|
|
1576
|
+
this.#hasExtraInfo = false;
|
|
1577
|
+
this.#webBundleInfo = null;
|
|
1578
|
+
this.#webBundleInnerRequestInfo = null;
|
|
1575
1579
|
}
|
|
1576
1580
|
|
|
1577
1581
|
addRequest(req: NetworkRequest): void {
|
|
1578
|
-
this
|
|
1579
|
-
this.sync(this
|
|
1582
|
+
this.#requests.push(req);
|
|
1583
|
+
this.sync(this.#requests.length - 1);
|
|
1580
1584
|
}
|
|
1581
1585
|
|
|
1582
1586
|
addRequestExtraInfo(info: ExtraRequestInfo): void {
|
|
1583
|
-
this
|
|
1584
|
-
this
|
|
1585
|
-
this.sync(this
|
|
1587
|
+
this.#hasExtraInfo = true;
|
|
1588
|
+
this.#requestExtraInfos.push(info);
|
|
1589
|
+
this.sync(this.#requestExtraInfos.length - 1);
|
|
1586
1590
|
}
|
|
1587
1591
|
|
|
1588
1592
|
addResponseExtraInfo(info: ExtraResponseInfo): void {
|
|
1589
|
-
this
|
|
1590
|
-
this.sync(this
|
|
1593
|
+
this.#responseExtraInfos.push(info);
|
|
1594
|
+
this.sync(this.#responseExtraInfos.length - 1);
|
|
1591
1595
|
}
|
|
1592
1596
|
|
|
1593
1597
|
setWebBundleInfo(info: WebBundleInfo): void {
|
|
1594
|
-
this
|
|
1598
|
+
this.#webBundleInfo = info;
|
|
1595
1599
|
this.updateFinalRequest();
|
|
1596
1600
|
}
|
|
1597
1601
|
|
|
1598
1602
|
setWebBundleInnerRequestInfo(info: WebBundleInnerRequestInfo): void {
|
|
1599
|
-
this
|
|
1603
|
+
this.#webBundleInnerRequestInfo = info;
|
|
1600
1604
|
this.updateFinalRequest();
|
|
1601
1605
|
}
|
|
1602
1606
|
|
|
1603
1607
|
finished(): void {
|
|
1604
|
-
this
|
|
1608
|
+
this.#finishedInternal = true;
|
|
1605
1609
|
this.updateFinalRequest();
|
|
1606
1610
|
}
|
|
1607
1611
|
|
|
1608
1612
|
private sync(index: number): void {
|
|
1609
|
-
const req = this
|
|
1613
|
+
const req = this.#requests[index];
|
|
1610
1614
|
if (!req) {
|
|
1611
1615
|
return;
|
|
1612
1616
|
}
|
|
1613
1617
|
|
|
1614
|
-
const requestExtraInfo = this
|
|
1618
|
+
const requestExtraInfo = this.#requestExtraInfos[index];
|
|
1615
1619
|
if (requestExtraInfo) {
|
|
1616
1620
|
req.addExtraRequestInfo(requestExtraInfo);
|
|
1617
|
-
this
|
|
1621
|
+
this.#requestExtraInfos[index] = null;
|
|
1618
1622
|
}
|
|
1619
1623
|
|
|
1620
|
-
const responseExtraInfo = this
|
|
1624
|
+
const responseExtraInfo = this.#responseExtraInfos[index];
|
|
1621
1625
|
if (responseExtraInfo) {
|
|
1622
1626
|
req.addExtraResponseInfo(responseExtraInfo);
|
|
1623
|
-
this
|
|
1627
|
+
this.#responseExtraInfos[index] = null;
|
|
1624
1628
|
}
|
|
1625
1629
|
}
|
|
1626
1630
|
|
|
1627
1631
|
finalRequest(): NetworkRequest|null {
|
|
1628
|
-
if (!this
|
|
1632
|
+
if (!this.#finishedInternal) {
|
|
1629
1633
|
return null;
|
|
1630
1634
|
}
|
|
1631
|
-
return this
|
|
1635
|
+
return this.#requests[this.#requests.length - 1] || null;
|
|
1632
1636
|
}
|
|
1633
1637
|
|
|
1634
1638
|
private updateFinalRequest(): void {
|
|
1635
|
-
if (!this
|
|
1639
|
+
if (!this.#finishedInternal) {
|
|
1636
1640
|
return;
|
|
1637
1641
|
}
|
|
1638
1642
|
const finalRequest = this.finalRequest();
|
|
1639
|
-
finalRequest?.setWebBundleInfo(this
|
|
1640
|
-
finalRequest?.setWebBundleInnerRequestInfo(this
|
|
1643
|
+
finalRequest?.setWebBundleInfo(this.#webBundleInfo);
|
|
1644
|
+
finalRequest?.setWebBundleInnerRequestInfo(this.#webBundleInnerRequestInfo);
|
|
1641
1645
|
}
|
|
1642
1646
|
}
|
|
1643
1647
|
|