chrome-devtools-mcp-for-extension 0.19.2 → 0.20.0
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/build/node_modules/chrome-devtools-frontend/front_end/core/common/Color.js +13 -9
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/ColorConverter.js +9 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Console.js +1 -8
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Debouncer.js +2 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Gzip.js +9 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/MapWithDefault.js +5 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/ParsedURL.js +10 -20
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/ResourceType.js +0 -11
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/ReturnToPanel.js +6 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Revealer.js +5 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/SegmentedRange.js +1 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Settings.js +110 -99
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/StringOutputStream.js +1 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Throttler.js +2 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/common/common.js +1 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/AidaClient.js +21 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/DispatchHttpRequestClient.js +66 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/GdpClient.js +102 -86
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/InspectorFrontendHost.js +32 -450
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/InspectorFrontendHostAPI.js +32 -29
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/InspectorFrontendHostStub.js +430 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/Platform.js +5 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/ResourceLoader.js +10 -22
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/UserMetrics.js +26 -15
- package/build/node_modules/chrome-devtools-frontend/front_end/core/host/host.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/ArrayUtilities.js +2 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/HostRuntime.js +19 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/StringUtilities.js +34 -32
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/api/HostRuntime.js +4 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/api/api.js +5 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/browser/HostRuntime.js +63 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/browser/browser.js +5 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/node/HostRuntime.js +72 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/node/node.js +5 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/platform/platform.js +2 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/protocol_client/CDPConnection.js +17 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/protocol_client/ConnectionTransport.js +12 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/protocol_client/DevToolsCDPConnection.js +138 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/protocol_client/InspectorBackend.js +49 -312
- package/build/node_modules/chrome-devtools-frontend/front_end/core/protocol_client/protocol_client.js +4 -9
- package/build/node_modules/chrome-devtools-frontend/front_end/core/root/DevToolsContext.js +54 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/root/root.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/AnimationModel.js +2 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CPUThrottlingManager.js +0 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSMatchedStyles.js +51 -17
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSMetadata.js +21 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSModel.js +11 -5
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSProperty.js +4 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSPropertyParser.js +11 -9
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSPropertyParserMatchers.js +34 -24
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSRule.js +52 -10
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSStartingStyle.js +21 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSStyleDeclaration.js +4 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ChildTargetManager.js +39 -35
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/Connections.js +10 -47
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ConsoleModel.js +1 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/Cookie.js +1 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/DOMModel.js +29 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/DebuggerModel.js +5 -20
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/EnhancedTracesParser.js +17 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/EventBreakpointsModel.js +4 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/HttpReasonPhraseStrings.js +4 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/IOModel.js +1 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/NetworkManager.js +428 -121
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/NetworkRequest.js +8 -22
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/PageResourceLoader.js +44 -34
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/PreloadingModel.js +64 -19
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/RehydratingConnection.js +139 -12
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/RemoteObject.js +5 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ResourceTreeModel.js +3 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ScopeTreeCache.js +36 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ScreenCaptureModel.js +20 -18
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/Script.js +26 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ServerSentEventsProtocol.js +3 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/SourceMap.js +54 -14
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/SourceMapCache.js +16 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/SourceMapManager.js +19 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/SourceMapScopesInfo.js +240 -8
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/Target.js +12 -17
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/TargetManager.js +38 -29
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/TraceObject.js +11 -8
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/sdk-meta.js +80 -31
- package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/sdk.js +4 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/generated/ARIAProperties.js +1301 -174
- package/build/node_modules/chrome-devtools-frontend/front_end/generated/Deprecation.js +67 -22
- package/build/node_modules/chrome-devtools-frontend/front_end/generated/InspectorBackendCommands.js +62 -91
- package/build/node_modules/chrome-devtools-frontend/front_end/generated/SupportedCSSProperties.js +188 -100
- package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/data_formatters/NetworkRequestFormatter.js +30 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.js +50 -34
- package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.js +152 -101
- package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/performance/AICallTree.js +11 -6
- package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/performance/AIContext.js +25 -26
- package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/performance/AIQueries.js +46 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/CSSWorkspaceBinding.js +10 -8
- package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/CompilerScriptMapping.js +82 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/DebuggerWorkspaceBinding.js +33 -15
- package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/ResourceMapping.js +105 -14
- package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/ResourceScriptMapping.js +38 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/SASSSourceMapping.js +5 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/cpu_profile/CPUProfileDataModel.js +9 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/models/cpu_profile/ProfileTreeModel.js +6 -7
- package/build/node_modules/chrome-devtools-frontend/front_end/models/crux-manager/CrUXManager.js +6 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/formatter/FormatterWorkerPool.js +16 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/network_time_calculator/RequestTimeRanges.js +6 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/source_map_scopes/FunctionCodeResolver.js +192 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/models/source_map_scopes/NamesResolver.js +12 -16
- package/build/node_modules/chrome-devtools-frontend/front_end/models/source_map_scopes/source_map_scopes.js +2 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/stack_trace/StackTraceModel.js +1 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/stack_trace/Trie.js +8 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/LanternComputationData.js +1 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/ModelImpl.js +6 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/Processor.js +4 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/Styles.js +1 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/extras/TraceTree.js +11 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/FramesHandler.js +7 -5
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/LayoutShiftsHandler.js +8 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/MetaHandler.js +4 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/NetworkRequestsHandler.js +29 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/SamplesHandler.js +59 -6
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/ScriptsHandler.js +26 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/UserTimingsHandler.js +1 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/helpers.js +1 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/helpers/Timing.js +4 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/helpers/Trace.js +18 -4
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/CLSCulprits.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/Cache.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/DOMSize.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/DocumentLatency.js +12 -11
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/DuplicatedJavaScript.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/FontDisplay.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/ForcedReflow.js +3 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/INPBreakdown.js +14 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/ImageDelivery.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/LCPBreakdown.js +13 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/LCPDiscovery.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/LegacyJavaScript.js +4 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/ModernHTTP.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/NetworkDependencyTree.js +4 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/RenderBlocking.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/SlowCSSSelector.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/ThirdParties.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/Viewport.js +2 -1
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/types/TraceEvents.js +9 -3
- package/build/node_modules/chrome-devtools-frontend/front_end/models/trace_source_maps_resolver/SourceMapsResolver.js +25 -2
- package/build/node_modules/chrome-devtools-frontend/front_end/models/workspace/IgnoreListManager.js +41 -48
- package/build/node_modules/chrome-devtools-frontend/front_end/models/workspace/UISourceCode.js +38 -0
- package/build/node_modules/chrome-devtools-frontend/front_end/models/workspace/WorkspaceImpl.js +5 -8
- package/build/node_modules/chrome-devtools-frontend/front_end/models/workspace/workspace-meta.js +34 -0
- package/build/src/McpContext.js +8 -1
- package/build/src/tools/bookmarks.js +0 -1
- package/build/src/tools/gemini-web.js +17 -25
- package/build/src/tools/snapshot.js +9 -2
- package/package.json +3 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// Copyright 2011 The Chromium Authors
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
|
+
var _a;
|
|
4
5
|
import * as TextUtils from '../../models/text_utils/text_utils.js';
|
|
5
6
|
import * as Common from '../common/common.js';
|
|
6
|
-
import * as Host from '../host/host.js';
|
|
7
7
|
import * as i18n from '../i18n/i18n.js';
|
|
8
8
|
import * as Platform from '../platform/platform.js';
|
|
9
9
|
import * as Root from '../root/root.js';
|
|
10
10
|
import { Cookie } from './Cookie.js';
|
|
11
|
-
import { DirectSocketChunkType, DirectSocketStatus, DirectSocketType, Events as NetworkRequestEvents, NetworkRequest } from './NetworkRequest.js';
|
|
11
|
+
import { DirectSocketChunkType, DirectSocketStatus, DirectSocketType, Events as NetworkRequestEvents, NetworkRequest, } from './NetworkRequest.js';
|
|
12
12
|
import { SDKModel } from './SDKModel.js';
|
|
13
13
|
import { TargetManager } from './TargetManager.js';
|
|
14
14
|
const UIStrings = {
|
|
@@ -50,6 +50,10 @@ const UIStrings = {
|
|
|
50
50
|
* @description Text in Network Manager representing the "Fast 4G" throttling preset
|
|
51
51
|
*/
|
|
52
52
|
fast4G: 'Fast 4G',
|
|
53
|
+
/**
|
|
54
|
+
* @description Text in Network Manager representing the "Blocking" throttling preset
|
|
55
|
+
*/
|
|
56
|
+
block: 'Block',
|
|
53
57
|
/**
|
|
54
58
|
* @description Text in Network Manager
|
|
55
59
|
* @example {https://example.com} PH1
|
|
@@ -137,6 +141,8 @@ export class NetworkManager extends SDKModel {
|
|
|
137
141
|
}
|
|
138
142
|
void this.#networkAgent.invoke_enable({
|
|
139
143
|
maxPostDataSize: MAX_EAGER_POST_REQUEST_BODY_LENGTH,
|
|
144
|
+
enableDurableMessages: Root.Runtime.hostConfig.devToolsEnableDurableMessages?.enabled,
|
|
145
|
+
maxTotalBufferSize: MAX_RESPONSE_BODY_TOTAL_BUFFER_LENGTH,
|
|
140
146
|
reportDirectSocketTraffic: true,
|
|
141
147
|
});
|
|
142
148
|
void this.#networkAgent.invoke_setAttachDebugStack({ enabled: true });
|
|
@@ -321,13 +327,6 @@ export class NetworkManager extends SDKModel {
|
|
|
321
327
|
}
|
|
322
328
|
return result.status;
|
|
323
329
|
}
|
|
324
|
-
async getIpProtectionProxyStatus() {
|
|
325
|
-
const result = await this.#networkAgent.invoke_getIPProtectionProxyStatus();
|
|
326
|
-
if (result.getError()) {
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
return result.status;
|
|
330
|
-
}
|
|
331
330
|
async enableReportingApi(enable = true) {
|
|
332
331
|
return await this.#networkAgent.invoke_enableReportingApi({ enable });
|
|
333
332
|
}
|
|
@@ -364,6 +363,11 @@ export var Events;
|
|
|
364
363
|
* @see https://docs.google.com/document/d/10lfVdS1iDWCRKQXPfbxEn4Or99D64mvNlugP1AQuFlE/edit for historical context.
|
|
365
364
|
* @see https://crbug.com/342406608#comment10 for context around the addition of 4G presets in June 2024.
|
|
366
365
|
*/
|
|
366
|
+
export const BlockingConditions = {
|
|
367
|
+
key: "BLOCKING" /* PredefinedThrottlingConditionKey.BLOCKING */,
|
|
368
|
+
block: true,
|
|
369
|
+
title: i18nLazyString(UIStrings.block),
|
|
370
|
+
};
|
|
367
371
|
export const NoThrottlingConditions = {
|
|
368
372
|
key: "NO_THROTTLING" /* PredefinedThrottlingConditionKey.NO_THROTTLING */,
|
|
369
373
|
title: i18nLazyString(UIStrings.noThrottling),
|
|
@@ -422,6 +426,7 @@ export const Fast4GConditions = {
|
|
|
422
426
|
targetLatency: fast4GTargetLatency,
|
|
423
427
|
};
|
|
424
428
|
const MAX_EAGER_POST_REQUEST_BODY_LENGTH = 64 * 1024; // bytes
|
|
429
|
+
const MAX_RESPONSE_BODY_TOTAL_BUFFER_LENGTH = 250 * 1024 * 1024; // bytes
|
|
425
430
|
export class FetchDispatcher {
|
|
426
431
|
#fetchAgent;
|
|
427
432
|
#manager;
|
|
@@ -547,12 +552,6 @@ export class NetworkDispatcher {
|
|
|
547
552
|
if (response.securityDetails) {
|
|
548
553
|
networkRequest.setSecurityDetails(response.securityDetails);
|
|
549
554
|
}
|
|
550
|
-
// TODO(crbug.com/425645896): Remove this guard once IP Protection is fully launched.
|
|
551
|
-
if (Root.Runtime.hostConfig.devToolsIpProtectionInDevTools?.enabled) {
|
|
552
|
-
if (response.isIpProtectionUsed) {
|
|
553
|
-
networkRequest.setIsIpProtectionUsed(response.isIpProtectionUsed);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
555
|
const newResourceType = Common.ResourceType.ResourceType.fromMimeTypeOverride(networkRequest.mimeType);
|
|
557
556
|
if (newResourceType) {
|
|
558
557
|
networkRequest.setResourceType(newResourceType);
|
|
@@ -811,7 +810,7 @@ export class NetworkDispatcher {
|
|
|
811
810
|
}
|
|
812
811
|
requestIntercepted({}) {
|
|
813
812
|
}
|
|
814
|
-
requestWillBeSentExtraInfo({ requestId, associatedCookies, headers, clientSecurityState, connectTiming, siteHasCookieInOtherPartition }) {
|
|
813
|
+
requestWillBeSentExtraInfo({ requestId, associatedCookies, headers, clientSecurityState, connectTiming, siteHasCookieInOtherPartition, appliedNetworkConditionsId }) {
|
|
815
814
|
const blockedRequestCookies = [];
|
|
816
815
|
const includedRequestCookies = [];
|
|
817
816
|
for (const { blockedReasons, exemptionReason, cookie } of associatedCookies) {
|
|
@@ -829,8 +828,14 @@ export class NetworkDispatcher {
|
|
|
829
828
|
clientSecurityState,
|
|
830
829
|
connectTiming,
|
|
831
830
|
siteHasCookieInOtherPartition,
|
|
831
|
+
appliedNetworkConditionsId,
|
|
832
832
|
};
|
|
833
833
|
this.getExtraInfoBuilder(requestId).addRequestExtraInfo(extraRequestInfo);
|
|
834
|
+
const networkRequest = this.#requestsById.get(requestId);
|
|
835
|
+
if (appliedNetworkConditionsId && networkRequest) {
|
|
836
|
+
networkRequest.setAppliedNetworkConditions(appliedNetworkConditionsId);
|
|
837
|
+
this.updateNetworkRequest(networkRequest);
|
|
838
|
+
}
|
|
834
839
|
}
|
|
835
840
|
responseReceivedEarlyHints({ requestId, headers, }) {
|
|
836
841
|
this.getExtraInfoBuilder(requestId).setEarlyHintsHeaders(this.headersMapToHeadersArray(headers));
|
|
@@ -1134,7 +1139,11 @@ export class NetworkDispatcher {
|
|
|
1134
1139
|
sendBufferSize: event.options.sendBufferSize,
|
|
1135
1140
|
receiveBufferSize: event.options.receiveBufferSize,
|
|
1136
1141
|
dnsQueryType: event.options.dnsQueryType,
|
|
1137
|
-
|
|
1142
|
+
multicastLoopback: event.options.multicastLoopback,
|
|
1143
|
+
multicastTimeToLive: event.options.multicastTimeToLive,
|
|
1144
|
+
multicastAllowAddressSharing: event.options.multicastAllowAddressSharing,
|
|
1145
|
+
},
|
|
1146
|
+
joinedMulticastGroups: new Set(),
|
|
1138
1147
|
};
|
|
1139
1148
|
networkRequest.setResourceType(Common.ResourceType.resourceTypes.DirectSocket);
|
|
1140
1149
|
networkRequest.setIssueTime(event.timestamp, event.timestamp);
|
|
@@ -1220,45 +1229,35 @@ export class NetworkDispatcher {
|
|
|
1220
1229
|
networkRequest.responseReceivedTime = event.timestamp;
|
|
1221
1230
|
this.updateNetworkRequest(networkRequest);
|
|
1222
1231
|
}
|
|
1223
|
-
|
|
1224
|
-
const
|
|
1225
|
-
if (!
|
|
1226
|
-
this.#requestIdToTrustTokenEvent.set(event.requestId, event);
|
|
1232
|
+
directUDPSocketJoinedMulticastGroup(event) {
|
|
1233
|
+
const networkRequest = this.#requestsById.get(event.identifier);
|
|
1234
|
+
if (!networkRequest?.directSocketInfo) {
|
|
1227
1235
|
return;
|
|
1228
1236
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
subresourceWebBundleMetadataReceived({ requestId, urls }) {
|
|
1232
|
-
const extraInfoBuilder = this.getExtraInfoBuilder(requestId);
|
|
1233
|
-
extraInfoBuilder.setWebBundleInfo({ resourceUrls: urls });
|
|
1234
|
-
const finalRequest = extraInfoBuilder.finalRequest();
|
|
1235
|
-
if (finalRequest) {
|
|
1236
|
-
this.updateNetworkRequest(finalRequest);
|
|
1237
|
+
if (!networkRequest.directSocketInfo.joinedMulticastGroups) {
|
|
1238
|
+
networkRequest.directSocketInfo.joinedMulticastGroups = new Set();
|
|
1237
1239
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
extraInfoBuilder.setWebBundleInfo({ errorMessage });
|
|
1242
|
-
const finalRequest = extraInfoBuilder.finalRequest();
|
|
1243
|
-
if (finalRequest) {
|
|
1244
|
-
this.updateNetworkRequest(finalRequest);
|
|
1240
|
+
if (!networkRequest.directSocketInfo.joinedMulticastGroups.has(event.IPAddress)) {
|
|
1241
|
+
networkRequest.directSocketInfo.joinedMulticastGroups.add(event.IPAddress);
|
|
1242
|
+
this.updateNetworkRequest(networkRequest);
|
|
1245
1243
|
}
|
|
1246
1244
|
}
|
|
1247
|
-
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1245
|
+
directUDPSocketLeftMulticastGroup(event) {
|
|
1246
|
+
const networkRequest = this.#requestsById.get(event.identifier);
|
|
1247
|
+
if (!networkRequest?.directSocketInfo?.joinedMulticastGroups) {
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
if (networkRequest.directSocketInfo.joinedMulticastGroups.delete(event.IPAddress)) {
|
|
1251
|
+
this.updateNetworkRequest(networkRequest);
|
|
1253
1252
|
}
|
|
1254
1253
|
}
|
|
1255
|
-
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
this.updateNetworkRequest(finalRequest);
|
|
1254
|
+
trustTokenOperationDone(event) {
|
|
1255
|
+
const request = this.#requestsById.get(event.requestId);
|
|
1256
|
+
if (!request) {
|
|
1257
|
+
this.#requestIdToTrustTokenEvent.set(event.requestId, event);
|
|
1258
|
+
return;
|
|
1261
1259
|
}
|
|
1260
|
+
request.setTrustTokenOperationDoneEvent(event);
|
|
1262
1261
|
}
|
|
1263
1262
|
reportingApiReportAdded(data) {
|
|
1264
1263
|
this.#manager.dispatchEventToListeners(Events.ReportingApiReportAdded, data.report);
|
|
@@ -1287,8 +1286,335 @@ export class NetworkDispatcher {
|
|
|
1287
1286
|
return `${host}:${port}`;
|
|
1288
1287
|
}
|
|
1289
1288
|
}
|
|
1290
|
-
|
|
1289
|
+
export class RequestURLPattern {
|
|
1290
|
+
constructorString;
|
|
1291
|
+
pattern;
|
|
1292
|
+
constructor(constructorString, pattern) {
|
|
1293
|
+
this.constructorString = constructorString;
|
|
1294
|
+
this.pattern = pattern;
|
|
1295
|
+
if (pattern.hasRegExpGroups) {
|
|
1296
|
+
throw new Error('RegExp groups are not allowed');
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
static isValidPattern(pattern) {
|
|
1300
|
+
try {
|
|
1301
|
+
const urlPattern = new URLPattern(pattern);
|
|
1302
|
+
return urlPattern.hasRegExpGroups ? "has-regexp-groups" /* RequestURLPatternValidity.HAS_REGEXP_GROUPS */ : "valid" /* RequestURLPatternValidity.VALID */;
|
|
1303
|
+
}
|
|
1304
|
+
catch {
|
|
1305
|
+
return "failed-to-parse" /* RequestURLPatternValidity.FAILED_TO_PARSE */;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
static create(constructorString) {
|
|
1309
|
+
try {
|
|
1310
|
+
const urlPattern = new URLPattern(constructorString);
|
|
1311
|
+
return urlPattern.hasRegExpGroups ? null : new RequestURLPattern(constructorString, urlPattern);
|
|
1312
|
+
}
|
|
1313
|
+
catch {
|
|
1314
|
+
return null;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
static upgradeFromWildcard(pattern) {
|
|
1318
|
+
const tryCreate = (constructorString) => {
|
|
1319
|
+
const result = this.create(constructorString);
|
|
1320
|
+
if (result?.pattern.protocol === 'localhost' && result?.pattern.hostname === '') {
|
|
1321
|
+
// localhost:1234 parses as a valid pattern, do the right thing here instead
|
|
1322
|
+
return tryCreate(`*://${constructorString}`);
|
|
1323
|
+
}
|
|
1324
|
+
return result;
|
|
1325
|
+
};
|
|
1326
|
+
return tryCreate(pattern) // try as is
|
|
1327
|
+
??
|
|
1328
|
+
// Try to upgrade patterns created from the network panel, which either blocks the full url (sans
|
|
1329
|
+
// protocol) or just the domain name. In both cases the wildcard patterns had implicit wildcards at the end.
|
|
1330
|
+
// We explicitly add that here, which will match both domain names without path (implicitly setting pathname
|
|
1331
|
+
// to '*') and urls with path (appending * to the pathname).
|
|
1332
|
+
tryCreate(`*://${pattern}*`);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
export class RequestCondition extends Common.ObjectWrapper.ObjectWrapper {
|
|
1336
|
+
#pattern;
|
|
1337
|
+
#enabled;
|
|
1338
|
+
#conditions;
|
|
1339
|
+
#ruleIds = new Set();
|
|
1340
|
+
static createFromSetting(setting) {
|
|
1341
|
+
if ('urlPattern' in setting) {
|
|
1342
|
+
const pattern = RequestURLPattern.create(setting.urlPattern) ?? {
|
|
1343
|
+
wildcardURL: setting.urlPattern,
|
|
1344
|
+
upgradedPattern: RequestURLPattern.upgradeFromWildcard(setting.urlPattern) ?? undefined,
|
|
1345
|
+
};
|
|
1346
|
+
const conditions = getPredefinedOrBlockingCondition(setting.conditions) ??
|
|
1347
|
+
customUserNetworkConditionsSetting().get().find(condition => condition.key === setting.conditions) ??
|
|
1348
|
+
NoThrottlingConditions;
|
|
1349
|
+
return new this(pattern, setting.enabled, conditions);
|
|
1350
|
+
}
|
|
1351
|
+
const pattern = {
|
|
1352
|
+
wildcardURL: setting.url,
|
|
1353
|
+
upgradedPattern: RequestURLPattern.upgradeFromWildcard(setting.url) ?? undefined
|
|
1354
|
+
};
|
|
1355
|
+
return new this(pattern, setting.enabled, BlockingConditions);
|
|
1356
|
+
}
|
|
1357
|
+
static create(pattern, conditions) {
|
|
1358
|
+
return new this(pattern, /* enabled=*/ true, conditions);
|
|
1359
|
+
}
|
|
1360
|
+
constructor(pattern, enabled, conditions) {
|
|
1361
|
+
super();
|
|
1362
|
+
this.#pattern = pattern;
|
|
1363
|
+
this.#enabled = enabled;
|
|
1364
|
+
this.#conditions = conditions;
|
|
1365
|
+
}
|
|
1366
|
+
get isBlocking() {
|
|
1367
|
+
return this.conditions === BlockingConditions;
|
|
1368
|
+
}
|
|
1369
|
+
get ruleIds() {
|
|
1370
|
+
return this.#ruleIds;
|
|
1371
|
+
}
|
|
1372
|
+
get constructorString() {
|
|
1373
|
+
return this.#pattern instanceof RequestURLPattern ? this.#pattern.constructorString :
|
|
1374
|
+
this.#pattern.upgradedPattern?.constructorString;
|
|
1375
|
+
}
|
|
1376
|
+
get wildcardURL() {
|
|
1377
|
+
return 'wildcardURL' in this.#pattern ? this.#pattern.wildcardURL : undefined;
|
|
1378
|
+
}
|
|
1379
|
+
get constructorStringOrWildcardURL() {
|
|
1380
|
+
return this.#pattern instanceof RequestURLPattern ?
|
|
1381
|
+
this.#pattern.constructorString :
|
|
1382
|
+
(this.#pattern.upgradedPattern?.constructorString ?? this.#pattern.wildcardURL);
|
|
1383
|
+
}
|
|
1384
|
+
set pattern(pattern) {
|
|
1385
|
+
if (typeof pattern === 'string') {
|
|
1386
|
+
// TODO(pfaffe) Remove once the feature flag is no longer required
|
|
1387
|
+
if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
|
|
1388
|
+
throw new Error('Should not use wildcard urls');
|
|
1389
|
+
}
|
|
1390
|
+
this.#pattern = {
|
|
1391
|
+
wildcardURL: pattern,
|
|
1392
|
+
upgradedPattern: RequestURLPattern.upgradeFromWildcard(pattern) ?? undefined
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
else {
|
|
1396
|
+
this.#pattern = pattern;
|
|
1397
|
+
}
|
|
1398
|
+
this.dispatchEventToListeners("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */);
|
|
1399
|
+
}
|
|
1400
|
+
get enabled() {
|
|
1401
|
+
return this.#enabled;
|
|
1402
|
+
}
|
|
1403
|
+
set enabled(enabled) {
|
|
1404
|
+
this.#enabled = enabled;
|
|
1405
|
+
this.dispatchEventToListeners("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */);
|
|
1406
|
+
}
|
|
1407
|
+
get conditions() {
|
|
1408
|
+
return this.#conditions;
|
|
1409
|
+
}
|
|
1410
|
+
set conditions(conditions) {
|
|
1411
|
+
this.#conditions = conditions;
|
|
1412
|
+
this.#ruleIds = new Set();
|
|
1413
|
+
this.dispatchEventToListeners("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */);
|
|
1414
|
+
}
|
|
1415
|
+
toSetting() {
|
|
1416
|
+
const enabled = this.enabled;
|
|
1417
|
+
if (this.#pattern instanceof RequestURLPattern) {
|
|
1418
|
+
return { enabled, urlPattern: this.#pattern.constructorString, conditions: this.#conditions.key };
|
|
1419
|
+
}
|
|
1420
|
+
if (this.#conditions !== BlockingConditions && this.#pattern.upgradedPattern) {
|
|
1421
|
+
return { enabled, urlPattern: this.#pattern.upgradedPattern.constructorString, conditions: this.#conditions.key };
|
|
1422
|
+
}
|
|
1423
|
+
return { enabled, url: this.#pattern.wildcardURL };
|
|
1424
|
+
}
|
|
1425
|
+
get originalOrUpgradedURLPattern() {
|
|
1426
|
+
return this.#pattern instanceof RequestURLPattern ? this.#pattern.pattern : this.#pattern.upgradedPattern?.pattern;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
export class RequestConditions extends Common.ObjectWrapper.ObjectWrapper {
|
|
1430
|
+
#setting = Common.Settings.Settings.instance().createSetting('network-blocked-patterns', []);
|
|
1431
|
+
#conditionsEnabledSetting = Common.Settings.Settings.instance().moduleSetting('request-blocking-enabled');
|
|
1432
|
+
#conditions = [];
|
|
1433
|
+
#requestConditionsById = new Map();
|
|
1434
|
+
#conditionsAppliedForTestPromise = Promise.resolve();
|
|
1435
|
+
constructor() {
|
|
1436
|
+
super();
|
|
1437
|
+
for (const condition of this.#setting.get()) {
|
|
1438
|
+
try {
|
|
1439
|
+
this.#conditions.push(RequestCondition.createFromSetting(condition));
|
|
1440
|
+
}
|
|
1441
|
+
catch (e) {
|
|
1442
|
+
console.error('Error loading throttling settings: ', e);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
for (const condition of this.#conditions) {
|
|
1446
|
+
condition.addEventListener("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */, this.#conditionsChanged, this);
|
|
1447
|
+
}
|
|
1448
|
+
this.#conditionsEnabledSetting.addChangeListener(() => this.dispatchEventToListeners("request-conditions-changed" /* RequestConditions.Events.REQUEST_CONDITIONS_CHANGED */));
|
|
1449
|
+
}
|
|
1450
|
+
get count() {
|
|
1451
|
+
return this.#conditions.length;
|
|
1452
|
+
}
|
|
1453
|
+
get conditionsEnabled() {
|
|
1454
|
+
return this.#conditionsEnabledSetting.get();
|
|
1455
|
+
}
|
|
1456
|
+
set conditionsEnabled(enabled) {
|
|
1457
|
+
if (this.#conditionsEnabledSetting.get() === enabled) {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
this.#conditionsEnabledSetting.set(enabled);
|
|
1461
|
+
}
|
|
1462
|
+
findCondition(pattern) {
|
|
1463
|
+
if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
|
|
1464
|
+
return this.#conditions.find(condition => condition.constructorString === pattern);
|
|
1465
|
+
}
|
|
1466
|
+
return this.#conditions.find(condition => condition.wildcardURL === pattern);
|
|
1467
|
+
}
|
|
1468
|
+
has(url) {
|
|
1469
|
+
return Boolean(this.findCondition(url));
|
|
1470
|
+
}
|
|
1471
|
+
add(...conditions) {
|
|
1472
|
+
this.#conditions.push(...conditions);
|
|
1473
|
+
for (const condition of conditions) {
|
|
1474
|
+
condition.addEventListener("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */, this.#conditionsChanged, this);
|
|
1475
|
+
}
|
|
1476
|
+
this.#conditionsChanged();
|
|
1477
|
+
}
|
|
1478
|
+
decreasePriority(condition) {
|
|
1479
|
+
const index = this.#conditions.indexOf(condition);
|
|
1480
|
+
if (index < 0 || index >= this.#conditions.length - 1) {
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
Platform.ArrayUtilities.swap(this.#conditions, index, index + 1);
|
|
1484
|
+
this.#conditionsChanged();
|
|
1485
|
+
}
|
|
1486
|
+
increasePriority(condition) {
|
|
1487
|
+
const index = this.#conditions.indexOf(condition);
|
|
1488
|
+
if (index <= 0) {
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
Platform.ArrayUtilities.swap(this.#conditions, index - 1, index);
|
|
1492
|
+
this.#conditionsChanged();
|
|
1493
|
+
}
|
|
1494
|
+
delete(condition) {
|
|
1495
|
+
const index = this.#conditions.indexOf(condition);
|
|
1496
|
+
if (index < 0) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
condition.removeEventListener("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */, this.#conditionsChanged, this);
|
|
1500
|
+
this.#conditions.splice(index, 1);
|
|
1501
|
+
this.#conditionsChanged();
|
|
1502
|
+
}
|
|
1503
|
+
clear() {
|
|
1504
|
+
this.#conditions.splice(0);
|
|
1505
|
+
this.#conditionsChanged();
|
|
1506
|
+
for (const condition of this.#conditions) {
|
|
1507
|
+
condition.removeEventListener("request-condition-changed" /* RequestCondition.Events.REQUEST_CONDITION_CHANGED */, this.#conditionsChanged, this);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
#conditionsChanged() {
|
|
1511
|
+
this.#setting.set(this.#conditions.map(condition => condition.toSetting()));
|
|
1512
|
+
this.dispatchEventToListeners("request-conditions-changed" /* RequestConditions.Events.REQUEST_CONDITIONS_CHANGED */);
|
|
1513
|
+
}
|
|
1514
|
+
get conditions() {
|
|
1515
|
+
return this.#conditions.values();
|
|
1516
|
+
}
|
|
1517
|
+
applyConditions(offline, globalConditions, ...agents) {
|
|
1518
|
+
function isNonBlockingCondition(condition) {
|
|
1519
|
+
return !('block' in condition);
|
|
1520
|
+
}
|
|
1521
|
+
if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
|
|
1522
|
+
const urlPatterns = [];
|
|
1523
|
+
// We store all this info out-of-band to prevent races with changing conditions while the promise is still pending
|
|
1524
|
+
const matchedNetworkConditions = [];
|
|
1525
|
+
if (this.conditionsEnabled) {
|
|
1526
|
+
for (const condition of this.#conditions) {
|
|
1527
|
+
const urlPattern = condition.constructorString;
|
|
1528
|
+
const conditions = condition.conditions;
|
|
1529
|
+
if (!condition.enabled || !urlPattern || conditions === NoThrottlingConditions) {
|
|
1530
|
+
continue;
|
|
1531
|
+
}
|
|
1532
|
+
const block = !isNonBlockingCondition(conditions);
|
|
1533
|
+
urlPatterns.push({ urlPattern, block });
|
|
1534
|
+
if (!block) {
|
|
1535
|
+
const { ruleIds } = condition;
|
|
1536
|
+
matchedNetworkConditions.push({ ruleIds, urlPattern, conditions });
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if (globalConditions) {
|
|
1540
|
+
matchedNetworkConditions.push({ conditions: globalConditions });
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
const promises = [];
|
|
1544
|
+
for (const agent of agents) {
|
|
1545
|
+
promises.push(agent.invoke_setBlockedURLs({ urlPatterns }));
|
|
1546
|
+
promises.push(agent
|
|
1547
|
+
.invoke_emulateNetworkConditionsByRule({
|
|
1548
|
+
offline,
|
|
1549
|
+
matchedNetworkConditions: matchedNetworkConditions.map(({ urlPattern, conditions }) => ({
|
|
1550
|
+
urlPattern: urlPattern ?? '',
|
|
1551
|
+
latency: conditions.latency,
|
|
1552
|
+
downloadThroughput: conditions.download < 0 ? 0 : conditions.download,
|
|
1553
|
+
uploadThroughput: conditions.upload < 0 ? 0 : conditions.upload,
|
|
1554
|
+
packetLoss: (conditions.packetLoss ?? 0) < 0 ? 0 : conditions.packetLoss,
|
|
1555
|
+
packetQueueLength: conditions.packetQueueLength,
|
|
1556
|
+
packetReordering: conditions.packetReordering,
|
|
1557
|
+
connectionType: NetworkManager.connectionType(conditions),
|
|
1558
|
+
}))
|
|
1559
|
+
})
|
|
1560
|
+
.then(response => {
|
|
1561
|
+
if (!response.getError()) {
|
|
1562
|
+
for (let i = 0; i < response.ruleIds.length; ++i) {
|
|
1563
|
+
const ruleId = response.ruleIds[i];
|
|
1564
|
+
const { ruleIds, conditions, urlPattern } = matchedNetworkConditions[i];
|
|
1565
|
+
if (ruleIds) {
|
|
1566
|
+
this.#requestConditionsById.set(ruleId, { urlPattern, conditions });
|
|
1567
|
+
matchedNetworkConditions[i].ruleIds?.add(ruleId);
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}));
|
|
1572
|
+
promises.push(agent.invoke_overrideNetworkState({
|
|
1573
|
+
offline,
|
|
1574
|
+
latency: globalConditions?.latency ?? 0,
|
|
1575
|
+
downloadThroughput: globalConditions?.download ?? -1,
|
|
1576
|
+
uploadThroughput: globalConditions?.upload ?? -1,
|
|
1577
|
+
connectionType: globalConditions ? NetworkManager.connectionType(globalConditions) :
|
|
1578
|
+
"none" /* Protocol.Network.ConnectionType.None */,
|
|
1579
|
+
}));
|
|
1580
|
+
}
|
|
1581
|
+
this.#conditionsAppliedForTestPromise = this.#conditionsAppliedForTestPromise.then(() => Promise.all(promises));
|
|
1582
|
+
return urlPatterns.length > 0;
|
|
1583
|
+
}
|
|
1584
|
+
const urls = this.conditionsEnabled ?
|
|
1585
|
+
this.#conditions.filter(condition => condition.enabled && condition.wildcardURL)
|
|
1586
|
+
.map(condition => condition.wildcardURL) :
|
|
1587
|
+
[];
|
|
1588
|
+
for (const agent of agents) {
|
|
1589
|
+
void agent.invoke_setBlockedURLs({ urls });
|
|
1590
|
+
}
|
|
1591
|
+
return urls.length > 0;
|
|
1592
|
+
}
|
|
1593
|
+
conditionsAppliedForTest() {
|
|
1594
|
+
return this.#conditionsAppliedForTestPromise;
|
|
1595
|
+
}
|
|
1596
|
+
conditionsForId(appliedNetworkConditionsId) {
|
|
1597
|
+
const requestConditions = this.#requestConditionsById.get(appliedNetworkConditionsId);
|
|
1598
|
+
if (!requestConditions) {
|
|
1599
|
+
return undefined;
|
|
1600
|
+
}
|
|
1601
|
+
const { conditions, urlPattern } = requestConditions;
|
|
1602
|
+
return new AppliedNetworkConditions(conditions, appliedNetworkConditionsId, urlPattern);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
_a = RequestConditions;
|
|
1606
|
+
export class AppliedNetworkConditions {
|
|
1607
|
+
conditions;
|
|
1608
|
+
appliedNetworkConditionsId;
|
|
1609
|
+
urlPattern;
|
|
1610
|
+
constructor(conditions, appliedNetworkConditionsId, urlPattern) {
|
|
1611
|
+
this.conditions = conditions;
|
|
1612
|
+
this.appliedNetworkConditionsId = appliedNetworkConditionsId;
|
|
1613
|
+
this.urlPattern = urlPattern;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1291
1616
|
export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrapper {
|
|
1617
|
+
#targetManager;
|
|
1292
1618
|
#userAgentOverride = '';
|
|
1293
1619
|
#userAgentMetadataOverride = null;
|
|
1294
1620
|
#customAcceptedEncodings = null;
|
|
@@ -1297,33 +1623,32 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1297
1623
|
inflightMainResourceRequests = new Map();
|
|
1298
1624
|
#networkConditions = NoThrottlingConditions;
|
|
1299
1625
|
#updatingInterceptionPatternsPromise = null;
|
|
1300
|
-
#
|
|
1301
|
-
#blockedPatternsSetting = Common.Settings.Settings.instance().createSetting('network-blocked-patterns', []);
|
|
1302
|
-
#effectiveBlockedURLs = [];
|
|
1626
|
+
#requestConditions = new RequestConditions();
|
|
1303
1627
|
#urlsForRequestInterceptor = new Platform.MapUtilities.Multimap();
|
|
1304
1628
|
#extraHeaders;
|
|
1305
1629
|
#customUserAgent;
|
|
1306
|
-
|
|
1630
|
+
#isBlocking = false;
|
|
1631
|
+
constructor(targetManager) {
|
|
1307
1632
|
super();
|
|
1633
|
+
this.#targetManager = targetManager;
|
|
1308
1634
|
// TODO(allada) Remove these and merge it with request interception.
|
|
1309
1635
|
const blockedPatternChanged = () => {
|
|
1310
1636
|
this.updateBlockedPatterns();
|
|
1311
1637
|
this.dispatchEventToListeners("BlockedPatternsChanged" /* MultitargetNetworkManager.Events.BLOCKED_PATTERNS_CHANGED */);
|
|
1312
1638
|
};
|
|
1313
|
-
this.#
|
|
1314
|
-
this.#blockedPatternsSetting.addChangeListener(blockedPatternChanged);
|
|
1639
|
+
this.#requestConditions.addEventListener("request-conditions-changed" /* RequestConditions.Events.REQUEST_CONDITIONS_CHANGED */, blockedPatternChanged);
|
|
1315
1640
|
this.updateBlockedPatterns();
|
|
1316
|
-
|
|
1641
|
+
this.#targetManager.observeModels(NetworkManager, this);
|
|
1317
1642
|
}
|
|
1318
1643
|
static instance(opts = { forceNew: null }) {
|
|
1319
|
-
const { forceNew } = opts;
|
|
1320
|
-
if (!
|
|
1321
|
-
|
|
1644
|
+
const { forceNew, targetManager } = opts;
|
|
1645
|
+
if (!Root.DevToolsContext.globalInstance().has(MultitargetNetworkManager) || forceNew) {
|
|
1646
|
+
Root.DevToolsContext.globalInstance().set(MultitargetNetworkManager, new MultitargetNetworkManager(targetManager ?? TargetManager.instance()));
|
|
1322
1647
|
}
|
|
1323
|
-
return
|
|
1648
|
+
return Root.DevToolsContext.globalInstance().get(MultitargetNetworkManager);
|
|
1324
1649
|
}
|
|
1325
1650
|
static dispose() {
|
|
1326
|
-
|
|
1651
|
+
Root.DevToolsContext.globalInstance().delete(MultitargetNetworkManager);
|
|
1327
1652
|
}
|
|
1328
1653
|
static patchUserAgentWithChromeVersion(uaString) {
|
|
1329
1654
|
// Patches Chrome/ChrOS version from user #agent ("1.2.3.4" when user #agent is: "Chrome/1.2.3.4").
|
|
@@ -1367,9 +1692,7 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1367
1692
|
if (this.currentUserAgent()) {
|
|
1368
1693
|
void networkAgent.invoke_setUserAgentOverride({ userAgent: this.currentUserAgent(), userAgentMetadata: this.#userAgentMetadataOverride || undefined });
|
|
1369
1694
|
}
|
|
1370
|
-
|
|
1371
|
-
void networkAgent.invoke_setBlockedURLs({ urls: this.#effectiveBlockedURLs });
|
|
1372
|
-
}
|
|
1695
|
+
this.#requestConditions.applyConditions(this.isOffline(), this.isThrottling() ? this.#networkConditions : null, networkAgent);
|
|
1373
1696
|
if (this.isIntercepting()) {
|
|
1374
1697
|
void fetchAgent.invoke_enable({ patterns: this.#urlsForRequestInterceptor.valuesArray() });
|
|
1375
1698
|
}
|
|
@@ -1381,7 +1704,7 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1381
1704
|
}
|
|
1382
1705
|
this.#networkAgents.add(networkAgent);
|
|
1383
1706
|
this.#fetchAgents.add(fetchAgent);
|
|
1384
|
-
if (this.isThrottling()) {
|
|
1707
|
+
if (this.isThrottling() && !Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
|
|
1385
1708
|
this.updateNetworkConditions(networkAgent);
|
|
1386
1709
|
}
|
|
1387
1710
|
}
|
|
@@ -1405,8 +1728,13 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1405
1728
|
}
|
|
1406
1729
|
setNetworkConditions(conditions) {
|
|
1407
1730
|
this.#networkConditions = conditions;
|
|
1408
|
-
|
|
1409
|
-
this.
|
|
1731
|
+
if (Root.Runtime.hostConfig.devToolsIndividualRequestThrottling?.enabled) {
|
|
1732
|
+
this.#requestConditions.applyConditions(this.isOffline(), this.isThrottling() ? this.#networkConditions : null, ...this.#networkAgents);
|
|
1733
|
+
}
|
|
1734
|
+
else {
|
|
1735
|
+
for (const agent of this.#networkAgents) {
|
|
1736
|
+
this.updateNetworkConditions(agent);
|
|
1737
|
+
}
|
|
1410
1738
|
}
|
|
1411
1739
|
this.dispatchEventToListeners("ConditionsChanged" /* MultitargetNetworkManager.Events.CONDITIONS_CHANGED */);
|
|
1412
1740
|
}
|
|
@@ -1494,41 +1822,29 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1494
1822
|
}
|
|
1495
1823
|
}
|
|
1496
1824
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
return this.#blockedPatternsSetting.get().slice();
|
|
1500
|
-
}
|
|
1501
|
-
blockingEnabled() {
|
|
1502
|
-
return this.#blockingEnabledSetting.get();
|
|
1825
|
+
get requestConditions() {
|
|
1826
|
+
return this.#requestConditions;
|
|
1503
1827
|
}
|
|
1504
1828
|
isBlocking() {
|
|
1505
|
-
return
|
|
1506
|
-
}
|
|
1507
|
-
setBlockedPatterns(patterns) {
|
|
1508
|
-
this.#blockedPatternsSetting.set(patterns);
|
|
1829
|
+
return this.#isBlocking && this.requestConditions.conditionsEnabled;
|
|
1509
1830
|
}
|
|
1831
|
+
/**
|
|
1832
|
+
* @deprecated Kept for layout tests
|
|
1833
|
+
* TODO(pfaffe) remove
|
|
1834
|
+
*/
|
|
1510
1835
|
setBlockingEnabled(enabled) {
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1836
|
+
this.requestConditions.conditionsEnabled = enabled;
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* @deprecated Kept for layout tests
|
|
1840
|
+
* TODO(pfaffe) remove
|
|
1841
|
+
*/
|
|
1842
|
+
setBlockedPatterns(patterns) {
|
|
1843
|
+
this.requestConditions.clear();
|
|
1844
|
+
this.requestConditions.add(...patterns.map(pattern => RequestCondition.createFromSetting(pattern)));
|
|
1515
1845
|
}
|
|
1516
1846
|
updateBlockedPatterns() {
|
|
1517
|
-
|
|
1518
|
-
if (this.#blockingEnabledSetting.get()) {
|
|
1519
|
-
for (const pattern of this.#blockedPatternsSetting.get()) {
|
|
1520
|
-
if (pattern.enabled) {
|
|
1521
|
-
urls.push(pattern.url);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
if (!urls.length && !this.#effectiveBlockedURLs.length) {
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
this.#effectiveBlockedURLs = urls;
|
|
1529
|
-
for (const agent of this.#networkAgents) {
|
|
1530
|
-
void agent.invoke_setBlockedURLs({ urls: this.#effectiveBlockedURLs });
|
|
1531
|
-
}
|
|
1847
|
+
this.#isBlocking = this.#requestConditions.applyConditions(this.isOffline(), this.isThrottling() ? this.#networkConditions : null, ...this.#networkAgents);
|
|
1532
1848
|
}
|
|
1533
1849
|
isIntercepting() {
|
|
1534
1850
|
return Boolean(this.#urlsForRequestInterceptor.size);
|
|
@@ -1583,7 +1899,7 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1583
1899
|
}
|
|
1584
1900
|
}
|
|
1585
1901
|
async getCertificate(origin) {
|
|
1586
|
-
const target =
|
|
1902
|
+
const target = this.#targetManager.primaryPageTarget();
|
|
1587
1903
|
if (!target) {
|
|
1588
1904
|
return [];
|
|
1589
1905
|
}
|
|
@@ -1593,19 +1909,11 @@ export class MultitargetNetworkManager extends Common.ObjectWrapper.ObjectWrappe
|
|
|
1593
1909
|
}
|
|
1594
1910
|
return certificate.tableNames;
|
|
1595
1911
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
if (currentUserAgent) {
|
|
1600
|
-
headers['User-Agent'] = currentUserAgent;
|
|
1912
|
+
appliedRequestConditions(requestInternal) {
|
|
1913
|
+
if (!requestInternal.appliedNetworkConditionsId) {
|
|
1914
|
+
return undefined;
|
|
1601
1915
|
}
|
|
1602
|
-
|
|
1603
|
-
headers['Cache-Control'] = 'no-cache';
|
|
1604
|
-
}
|
|
1605
|
-
const allowRemoteFilePaths = Common.Settings.Settings.instance().moduleSetting('network.enable-remote-file-loading').get();
|
|
1606
|
-
return await new Promise(resolve => Host.ResourceLoader.load(url, headers, (success, _responseHeaders, content, errorDescription) => {
|
|
1607
|
-
resolve({ success, content, errorDescription });
|
|
1608
|
-
}, allowRemoteFilePaths));
|
|
1916
|
+
return this.requestConditions.conditionsForId(requestInternal.appliedNetworkConditionsId);
|
|
1609
1917
|
}
|
|
1610
1918
|
}
|
|
1611
1919
|
export class InterceptedRequest {
|
|
@@ -1747,8 +2055,6 @@ class ExtraInfoBuilder {
|
|
|
1747
2055
|
#responseExtraInfos = [];
|
|
1748
2056
|
#responseEarlyHintsHeaders = [];
|
|
1749
2057
|
#finished = false;
|
|
1750
|
-
#webBundleInfo = null;
|
|
1751
|
-
#webBundleInnerRequestInfo = null;
|
|
1752
2058
|
addRequest(req) {
|
|
1753
2059
|
this.#requests.push(req);
|
|
1754
2060
|
this.sync(this.#requests.length - 1);
|
|
@@ -1779,14 +2085,6 @@ class ExtraInfoBuilder {
|
|
|
1779
2085
|
this.#responseEarlyHintsHeaders = earlyHintsHeaders;
|
|
1780
2086
|
this.updateFinalRequest();
|
|
1781
2087
|
}
|
|
1782
|
-
setWebBundleInfo(info) {
|
|
1783
|
-
this.#webBundleInfo = info;
|
|
1784
|
-
this.updateFinalRequest();
|
|
1785
|
-
}
|
|
1786
|
-
setWebBundleInnerRequestInfo(info) {
|
|
1787
|
-
this.#webBundleInnerRequestInfo = info;
|
|
1788
|
-
this.updateFinalRequest();
|
|
1789
|
-
}
|
|
1790
2088
|
finished() {
|
|
1791
2089
|
this.#finished = true;
|
|
1792
2090
|
// We may have missed responseReceived event in case of failure.
|
|
@@ -1839,13 +2137,19 @@ class ExtraInfoBuilder {
|
|
|
1839
2137
|
return;
|
|
1840
2138
|
}
|
|
1841
2139
|
const finalRequest = this.finalRequest();
|
|
1842
|
-
finalRequest?.setWebBundleInfo(this.#webBundleInfo);
|
|
1843
|
-
finalRequest?.setWebBundleInnerRequestInfo(this.#webBundleInnerRequestInfo);
|
|
1844
2140
|
finalRequest?.setEarlyHintsHeaders(this.#responseEarlyHintsHeaders);
|
|
1845
2141
|
}
|
|
1846
2142
|
}
|
|
1847
2143
|
SDKModel.register(NetworkManager, { capabilities: 16 /* Capability.NETWORK */, autostart: true });
|
|
1848
2144
|
export function networkConditionsEqual(first, second) {
|
|
2145
|
+
if ('block' in first || 'block' in second) {
|
|
2146
|
+
if ('block' in first && 'block' in second) {
|
|
2147
|
+
const firstTitle = (typeof first.title === 'function' ? first.title() : first.title);
|
|
2148
|
+
const secondTitle = (typeof second.title === 'function' ? second.title() : second.title);
|
|
2149
|
+
return firstTitle === secondTitle && first.block === second.block;
|
|
2150
|
+
}
|
|
2151
|
+
return false;
|
|
2152
|
+
}
|
|
1849
2153
|
// Caution: titles might be different function instances, which produce
|
|
1850
2154
|
// the same value.
|
|
1851
2155
|
// We prefer to use the i18nTitleKey to prevent against locale changes or
|
|
@@ -1876,6 +2180,9 @@ export function getPredefinedCondition(key) {
|
|
|
1876
2180
|
}
|
|
1877
2181
|
return THROTTLING_CONDITIONS_LOOKUP.get(key) ?? null;
|
|
1878
2182
|
}
|
|
2183
|
+
export function getPredefinedOrBlockingCondition(key) {
|
|
2184
|
+
return key === "BLOCKING" /* PredefinedThrottlingConditionKey.BLOCKING */ ? BlockingConditions : getPredefinedCondition(key);
|
|
2185
|
+
}
|
|
1879
2186
|
/**
|
|
1880
2187
|
* For the given Round Trip Time (in MilliSeconds), return the best throttling conditions.
|
|
1881
2188
|
*/
|