chrome-devtools-frontend 1.0.1726686 → 1.0.1730971
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/.agents/rules/tests/test-strict-assertions-and-literal-expectations.md +1 -1
- package/.agents/rules/tests/test-view-and-presenter-isolation.md +1 -1
- package/.agents/rules/ui-and-widgets/ui-accessibility-and-semantic-html.md +1 -1
- package/.agents/rules/ui-and-widgets/ui-css-scoping-and-flex-layout.md +2 -2
- package/.agents/rules/ui-and-widgets/ui-declarative-child-widget-composition.md +5 -5
- package/.agents/rules/ui-and-widgets/ui-lit-declarative-templates-and-directives.md +2 -2
- package/.agents/rules/ui-and-widgets/ui-localization-and-uistrings-hygiene.md +2 -2
- package/.agents/rules/ui-and-widgets/ui-modern-component-and-encapsulation-standards.md +3 -3
- package/.agents/rules/ui-and-widgets/ui-pure-view-and-presenter-separation.md +2 -2
- package/.agents/rules/ui-and-widgets/ui-reactive-widget-update-lifecycle.md +2 -2
- package/.agents/rules/ui-and-widgets/ui-view-output-and-callback-contracts.md +2 -2
- package/.agents/rules/ui-and-widgets/ui-widget-dom-and-listener-lifecycle.md +2 -2
- package/.agents/skills/code-review/SKILL.md +63 -12
- package/.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md +38 -10
- package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +1 -0
- package/.agents/skills/ui-widgets/SKILL.md +8 -2
- package/.agents/skills/write-ai-eval-test/SKILL.md +106 -0
- package/AUTHORS +2 -0
- package/DIR_METADATA +1 -2
- package/README.md +48 -26
- package/config/typescript/tsconfig.base.json +1 -0
- package/config/typescript/tsconfig.eslint.json +1 -0
- package/docs/contributing/changes.md +25 -0
- package/docs/ui_engineering.md +13 -4
- package/eslint.config.mjs +323 -41
- package/front_end/core/common/Color.ts +7 -7
- package/front_end/core/common/ParsedURL.ts +3 -3
- package/front_end/core/common/ResolverBase.ts +3 -3
- package/front_end/core/common/SegmentedRange.ts +3 -3
- package/front_end/core/common/SimpleHistoryManager.ts +14 -14
- package/front_end/core/common/Trie.ts +3 -3
- package/front_end/core/common/VersionController.ts +7 -7
- package/front_end/core/host/InspectorFrontendHost.ts +2 -2
- package/front_end/core/host/InspectorFrontendHostAPI.ts +9 -1
- package/front_end/core/host/InspectorFrontendHostStub.ts +1 -1
- package/front_end/core/host/UserMetrics.ts +4 -0
- package/front_end/core/host/UserMetricsEnums.ts +2 -1
- package/front_end/core/platform/StringUtilities.ts +54 -13
- package/front_end/core/platform/node/HostRuntime.ts +13 -7
- package/front_end/core/protocol_client/DevToolsCDPConnection.ts +4 -5
- package/front_end/core/root/Runtime.ts +5 -0
- package/front_end/core/sdk/AccessibilityModel.ts +5 -5
- package/front_end/core/sdk/AnimationModel.ts +17 -19
- package/front_end/core/sdk/CPUProfilerModel.ts +3 -3
- package/front_end/core/sdk/CPUThrottlingManager.ts +7 -0
- package/front_end/core/sdk/CSSMatchedStyles.ts +73 -13
- package/front_end/core/sdk/CSSMetadata.ts +7 -7
- package/front_end/core/sdk/CSSModel.ts +33 -33
- package/front_end/core/sdk/CSSProperty.ts +5 -5
- package/front_end/core/sdk/CSSRule.ts +6 -6
- package/front_end/core/sdk/CSSStyleSheetHeader.ts +4 -4
- package/front_end/core/sdk/Connections.ts +16 -16
- package/front_end/core/sdk/ConsoleModel.ts +44 -47
- package/front_end/core/sdk/CookieParser.ts +11 -11
- package/front_end/core/sdk/EmulationModel.ts +35 -36
- package/front_end/core/sdk/EventBreakpointsModel.ts +11 -11
- package/front_end/core/sdk/FrameManager.ts +16 -16
- package/front_end/core/sdk/IsolateManager.ts +2 -2
- package/front_end/core/sdk/IssuesModel.ts +2 -2
- package/front_end/core/sdk/OverlayModel.ts +19 -19
- package/front_end/core/sdk/PageResourceLoader.ts +14 -16
- package/front_end/core/sdk/RemoteObject.ts +9 -9
- package/front_end/core/sdk/Resource.ts +2 -2
- package/front_end/core/sdk/RuntimeModel.ts +7 -7
- package/front_end/core/sdk/Script.ts +6 -6
- package/front_end/core/sdk/ServiceWorkerManager.ts +36 -10
- package/front_end/core/sdk/SourceMap.ts +18 -20
- package/front_end/core/sdk/SourceMapManager.ts +2 -2
- package/front_end/core/sdk/TargetManager.ts +2 -2
- package/front_end/devtools_compatibility.js +7 -3
- package/front_end/entrypoints/inspector_main/InspectorMain.ts +2 -2
- package/front_end/entrypoints/node_app/app/NodeConnectionsPanel.ts +203 -115
- package/front_end/generated/InspectorBackendCommands.ts +1 -1
- package/front_end/generated/SupportedCSSProperties.ts +1 -3
- package/front_end/generated/protocol.ts +1 -0
- package/front_end/models/ai_assistance/AiAgent2.ts +36 -12
- package/front_end/models/ai_assistance/AiConversation.ts +8 -2
- package/front_end/models/ai_assistance/agents/AiAgent.ts +137 -62
- package/front_end/models/ai_assistance/agents/ExecuteJavascript.ts +2 -2
- package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +149 -2
- package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +269 -42
- package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +3 -0
- package/front_end/models/ai_assistance/tools/GetLighthouseAudits.ts +9 -0
- package/front_end/models/ai_assistance/tools/ResolveDevtoolsNodePath.ts +13 -2
- package/front_end/models/ai_assistance/tools/RunLighthouse.ts +23 -7
- package/front_end/models/ai_assistance/tools/Tool.ts +7 -5
- package/front_end/models/bindings/CSSWorkspaceBinding.ts +22 -24
- package/front_end/models/bindings/DebuggerLanguagePlugins.ts +60 -60
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +24 -24
- package/front_end/models/bindings/DefaultScriptMapping.ts +8 -8
- package/front_end/models/bindings/FileUtils.ts +13 -13
- package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +3 -3
- package/front_end/models/bindings/ResourceScriptMapping.ts +23 -23
- package/front_end/models/comment_manager/CommentManager.ts +3 -3
- package/front_end/models/comment_manager/CommentThread.ts +50 -5
- package/front_end/models/cpu_profile/CPUProfileDataModel.ts +14 -14
- package/front_end/models/cpu_profile/ProfileTreeModel.ts +4 -4
- package/front_end/models/elements/StyleChanges.ts +38 -0
- package/front_end/models/emulation/EmulatedDevices.ts +12 -12
- package/front_end/models/har/HARFormat.ts +4 -4
- package/front_end/models/javascript_metadata/NativeFunctions.ts +5 -1
- package/front_end/models/lighthouse/LighthouseReporterTypes.ts +57 -3
- package/front_end/models/lighthouse/RunTypes.ts +9 -1
- package/front_end/models/logs/LogManager.ts +2 -2
- package/front_end/models/persistence/AutomaticFileSystemManager.ts +3 -0
- package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +24 -24
- package/front_end/models/persistence/IsolatedFileSystemManager.ts +6 -0
- package/front_end/models/persistence/NetworkPersistenceManager.ts +8 -3
- package/front_end/models/trace/LanternComputationData.ts +37 -11
- package/front_end/models/trace/Processor.ts +2 -1
- package/front_end/models/trace/extras/TraceTree.ts +36 -10
- package/front_end/models/trace/handlers/InitiatorsHandler.ts +27 -34
- package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +2 -6
- package/front_end/models/trace/handlers/SamplesHandler.ts +9 -6
- package/front_end/models/workspace/FileManager.ts +6 -0
- package/front_end/panels/accessibility/ARIAAttributesView.ts +4 -4
- package/front_end/panels/accessibility/AccessibilityAnnouncementRecordingView.ts +8 -1
- package/front_end/panels/accessibility/AccessibilityNodeView.ts +15 -17
- package/front_end/panels/accessibility/AccessibilitySubPane.ts +1 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +5 -5
- package/front_end/panels/ai_assistance/ExternalHandler.ts +10 -1
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +27 -22
- package/front_end/panels/ai_assistance/components/DisabledWidget.ts +19 -23
- package/front_end/panels/ai_assistance/components/ExploreWidget.ts +2 -2
- package/front_end/panels/ai_assistance/components/PermissionPrompt.ts +23 -9
- package/front_end/panels/ai_assistance/components/chatInput.css +1 -1
- package/front_end/panels/animation/AnimationTimeline.ts +37 -17
- package/front_end/panels/animation/animationTimeline.css +19 -3
- package/front_end/panels/application/AppManifestView.ts +1 -2
- package/front_end/panels/application/ApplicationPanelSidebar.ts +143 -128
- package/front_end/panels/application/DOMStorageItemsView.ts +14 -14
- package/front_end/panels/application/DeviceBoundSessionsView.ts +10 -13
- package/front_end/panels/application/ExtensionStorageItemsView.ts +3 -4
- package/front_end/panels/application/IndexedDBViews.ts +8 -4
- package/front_end/panels/application/KeyValueStorageItemsView.ts +4 -5
- package/front_end/panels/application/PrivateVerificationTokensView.ts +53 -0
- package/front_end/panels/application/ServiceWorkerCacheViews.ts +12 -8
- package/front_end/panels/application/ServiceWorkersView.ts +1 -2
- package/front_end/panels/application/StorageItemsToolbar.ts +3 -3
- package/front_end/panels/application/StorageView.ts +2 -2
- package/front_end/panels/application/WebMCPView.ts +91 -109
- package/front_end/panels/application/application.ts +2 -0
- package/front_end/panels/application/components/StorageMetadataView.ts +6 -6
- package/front_end/panels/application/preloading/PreloadingView.ts +70 -37
- package/front_end/panels/application/preloading/components/MismatchedPreloadingGrid.ts +2 -2
- package/front_end/panels/application/preloading/components/PreloadingDisabledInfobar.ts +3 -3
- package/front_end/panels/application/preloading/components/PreloadingGrid.ts +12 -0
- package/front_end/panels/application/preloading/components/RuleSetDetailsView.ts +10 -11
- package/front_end/panels/application/privateVerificationTokensView.css +20 -0
- package/front_end/panels/application/serviceWorkersView.css +2 -2
- package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +24 -24
- package/front_end/panels/changes/ChangesSidebar.ts +5 -5
- package/front_end/panels/changes/ChangesView.ts +10 -11
- package/front_end/panels/comments/CommentsPane.ts +292 -102
- package/front_end/panels/comments/commentsPane.css +93 -12
- package/front_end/panels/common/CommentThreadWidget.ts +69 -0
- package/front_end/panels/common/CommentsOverlayWidget.ts +108 -29
- package/front_end/panels/common/CommentsStatusBarPill.ts +17 -6
- package/front_end/panels/common/DOMLinkifier.ts +37 -12
- package/front_end/panels/common/ExtensionPanel.ts +13 -4
- package/front_end/panels/common/ExtensionServer.ts +27 -3
- package/front_end/panels/common/PersistenceUtils.ts +3 -3
- package/front_end/panels/common/commentThreadWidget.css +25 -1
- package/front_end/panels/common/common-meta.ts +10 -0
- package/front_end/panels/console/ConsolePinPane.ts +13 -15
- package/front_end/panels/console/ConsolePrompt.ts +173 -95
- package/front_end/panels/console/ConsoleSidebar.ts +2 -2
- package/front_end/panels/console/ConsoleView.ts +75 -79
- package/front_end/panels/console/ConsoleViewMessage.ts +52 -4
- package/front_end/panels/console/SymbolizedErrorWidget.ts +8 -4
- package/front_end/panels/console/consolePrompt.css +1 -1
- package/front_end/panels/console/consoleView.css +1 -1
- package/front_end/panels/console_counters/WarningErrorCounter.ts +3 -4
- package/front_end/panels/coverage/CoverageListView.ts +2 -2
- package/front_end/panels/coverage/CoverageView.ts +20 -5
- package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +4 -3
- package/front_end/panels/css_overview/CSSOverviewPanel.ts +2 -2
- package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +2 -2
- package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +2 -2
- package/front_end/panels/css_overview/CSSOverviewStartView.ts +2 -2
- package/front_end/panels/css_overview/CSSOverviewUnusedDeclarations.ts +8 -8
- package/front_end/panels/developer_resources/DeveloperResourcesListView.ts +2 -3
- package/front_end/panels/developer_resources/DeveloperResourcesView.ts +4 -5
- package/front_end/panels/elements/AccessibilityTreeUtils.ts +6 -7
- package/front_end/panels/elements/CSSValueTraceView.ts +3 -3
- package/front_end/panels/elements/ClassesPaneWidget.ts +1 -2
- package/front_end/panels/elements/ComputedStyleWidget.ts +15 -14
- package/front_end/panels/elements/DOMTreeElementWidget.ts +5 -4
- package/front_end/panels/elements/DOMTreeWidget.ts +2 -1
- package/front_end/panels/elements/ElementStatePaneWidget.ts +2 -2
- package/front_end/panels/elements/ElementsPanel.ts +1 -0
- package/front_end/panels/elements/EventListenersWidget.ts +2 -2
- package/front_end/panels/elements/LayoutPane.ts +2 -2
- package/front_end/panels/elements/PlatformFontsWidget.ts +3 -3
- package/front_end/panels/elements/PropertiesWidget.ts +9 -10
- package/front_end/panels/elements/PropertyRenderer.ts +72 -11
- package/front_end/panels/elements/StandaloneStylesContainer.ts +5 -10
- package/front_end/panels/elements/StyleEditorWidget.ts +30 -16
- package/front_end/panels/elements/StylePropertiesSection.ts +93 -44
- package/front_end/panels/elements/StylePropertyTreeElement.ts +230 -302
- package/front_end/panels/elements/StylesContainer.ts +2 -3
- package/front_end/panels/elements/StylesSidebarPane.ts +4 -13
- package/front_end/panels/elements/components/AccessibilityTreeNode.ts +66 -37
- package/front_end/panels/elements/components/CSSHintDetailsView.ts +51 -41
- package/front_end/panels/elements/components/CSSPropertyDocsView.ts +75 -65
- package/front_end/panels/elements/components/CSSQuery.ts +112 -74
- package/front_end/panels/elements/components/CSSVariableValueView.ts +109 -68
- package/front_end/panels/elements/components/ComputedStyleProperty.ts +64 -45
- package/front_end/panels/elements/components/ElementsTreeExpandButton.ts +35 -28
- package/front_end/panels/elements/components/QueryContainer.ts +104 -74
- package/front_end/panels/elements/components/accessibilityTreeNode.css +22 -20
- package/front_end/panels/elements/components/computedStyleProperty.css +2 -0
- package/front_end/panels/elements/components/cssHintDetailsView.css +23 -21
- package/front_end/panels/elements/components/cssPropertyDocsView.css +38 -36
- package/front_end/panels/elements/components/cssVariableValueView.css +42 -40
- package/front_end/panels/elements/components/elementsTreeExpandButton.css +5 -2
- package/front_end/panels/elements/components/queryContainer.css +23 -21
- package/front_end/panels/elements/stylesSidebarPane.css +3 -3
- package/front_end/panels/emulation/DeviceModeToolbar.ts +2 -2
- package/front_end/panels/emulation/InspectedPagePlaceholder.ts +2 -2
- package/front_end/panels/emulation/MediaQueryInspector.ts +9 -10
- package/front_end/panels/emulation/mediaQueryInspector.css +1 -1
- package/front_end/panels/event_listeners/EventListenersView.ts +2 -2
- package/front_end/panels/issues/AffectedCookiesView.ts +144 -101
- package/front_end/panels/issues/AffectedDescendantsWithinSelectElementView.ts +83 -31
- package/front_end/panels/issues/AffectedDirectivesView.ts +218 -135
- package/front_end/panels/issues/AffectedDocumentsInQuirksModeView.ts +84 -34
- package/front_end/panels/issues/AffectedElementsView.ts +86 -23
- package/front_end/panels/issues/AffectedLazyLoadImagesView.ts +2 -2
- package/front_end/panels/issues/AffectedMetadataAllowedSitesView.ts +2 -2
- package/front_end/panels/issues/AffectedPartitioningBlobURLView.ts +36 -11
- package/front_end/panels/issues/AffectedSharedArrayBufferIssueDetailsView.ts +135 -58
- package/front_end/panels/issues/AffectedSourcesView.ts +49 -28
- package/front_end/panels/issues/AffectedTrackingSitesView.ts +3 -4
- package/front_end/panels/issues/CorsIssueDetailsView.ts +490 -269
- package/front_end/panels/issues/GenericIssueDetailsView.ts +2 -2
- package/front_end/panels/issues/IssueKindView.ts +63 -48
- package/front_end/panels/issues/IssueView.ts +14 -18
- package/front_end/panels/issues/components/ElementsPanelLink.ts +70 -34
- package/front_end/panels/issues/components/HideIssuesMenu.ts +56 -32
- package/front_end/panels/issues/components/elementsPanelLink.css +10 -6
- package/front_end/panels/issues/components/hideIssuesMenu.css +16 -14
- package/front_end/panels/issues/issues.ts +2 -0
- package/front_end/panels/issues/issuesTree.css +4 -4
- package/front_end/panels/lighthouse/LighthouseController.ts +6 -6
- package/front_end/panels/lighthouse/LighthouseStatusView.ts +12 -13
- package/front_end/panels/lighthouse/lighthouseStartView.css +1 -1
- package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.ts +159 -161
- package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorView.ts +228 -0
- package/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.ts +32 -41
- package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +2 -2
- package/front_end/panels/linear_memory_inspector/linear_memory_inspector.ts +2 -0
- package/front_end/panels/media/EventDisplayTable.ts +2 -2
- package/front_end/panels/media/MainView.ts +132 -66
- package/front_end/panels/media/PlayerDetailView.ts +32 -14
- package/front_end/panels/media/PlayerListView.ts +83 -23
- package/front_end/panels/media/PlayerPropertiesView.ts +2 -2
- package/front_end/panels/media/TickingFlameChart.ts +153 -63
- package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +2 -2
- package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +615 -464
- package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +43 -0
- package/front_end/panels/network/EventSourceMessagesView.ts +3 -3
- package/front_end/panels/network/NetworkConfigView.ts +6 -2
- package/front_end/panels/network/NetworkDataGridNode.ts +2 -1
- package/front_end/panels/network/NetworkItemView.ts +27 -26
- package/front_end/panels/network/NetworkManageCustomHeadersView.ts +236 -97
- package/front_end/panels/network/NetworkOverview.ts +8 -10
- package/front_end/panels/network/RequestConditionsDrawer.ts +8 -4
- package/front_end/panels/network/RequestDeviceBoundSessionsView.ts +2 -4
- package/front_end/panels/network/RequestHTMLView.ts +26 -7
- package/front_end/panels/network/RequestHeadersView.ts +2 -2
- package/front_end/panels/network/RequestInitiatorView.ts +21 -22
- package/front_end/panels/network/RequestPayloadView.ts +2 -16
- package/front_end/panels/network/RequestPreviewView.ts +5 -5
- package/front_end/panels/network/RequestTimingView.ts +6 -6
- package/front_end/panels/network/ResourceDirectSocketChunkView.ts +5 -6
- package/front_end/panels/network/ResourceWebSocketFrameView.ts +4 -3
- package/front_end/panels/network/ShowMoreDetailsWidget.ts +11 -12
- package/front_end/panels/network/SignedExchangeInfoView.ts +2 -2
- package/front_end/panels/network/networkLogView.css +2 -2
- package/front_end/panels/network/networkManageCustomHeadersView.css +27 -6
- package/front_end/panels/network/requestConditionsDrawer.css +1 -1
- package/front_end/panels/network/requestInitiatorView.css +5 -3
- package/front_end/panels/performance_monitor/PerformanceMonitor.ts +2 -2
- package/front_end/panels/profiler/HeapDetachedElementsView.ts +1 -2
- package/front_end/panels/profiler/HeapTimelineOverview.ts +77 -15
- package/front_end/panels/profiler/IsolateSelector.ts +258 -187
- package/front_end/panels/profiler/ProfileLauncherView.ts +7 -29
- package/front_end/panels/profiler/profileLauncherView.css +6 -1
- package/front_end/panels/protocol_monitor/JSONEditor.ts +4 -5
- package/front_end/panels/recorder/ControlButton.ts +1 -1
- package/front_end/panels/recorder/RecordingListView.ts +2 -4
- package/front_end/panels/recorder/RecordingView.ts +1 -2
- package/front_end/panels/recorder/SelectorPicker.ts +2 -4
- package/front_end/panels/recorder/StepView.ts +24 -10
- package/front_end/panels/recorder/TimelineSection.ts +1 -1
- package/front_end/panels/recorder/recordingView.css +1 -1
- package/front_end/panels/screencast/ScreencastApp.ts +1 -1
- package/front_end/panels/search/SearchResultsPane.ts +11 -12
- package/front_end/panels/search/SearchView.ts +8 -10
- package/front_end/panels/security/SecurityPanel.ts +1 -8
- package/front_end/panels/security/SecurityPanelSidebar.ts +2 -2
- package/front_end/panels/security/mainView.css +1 -1
- package/front_end/panels/sensors/LocationsSettingsTab.ts +1 -2
- package/front_end/panels/settings/AISettingsTab.ts +1 -1
- package/front_end/panels/settings/BackendLinkingSettingsTab.ts +34 -20
- package/front_end/panels/settings/EditFileSystemView.ts +2 -2
- package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +375 -197
- package/front_end/panels/settings/KeybindsSettingsTab.ts +570 -414
- package/front_end/panels/settings/SettingsScreen.ts +312 -114
- package/front_end/panels/settings/WorkspaceSettingsTab.ts +2 -2
- package/front_end/panels/settings/aiSettingsTab.css +1 -4
- package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +924 -578
- package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +9 -2
- package/front_end/panels/settings/emulation/devicesSettingsTab.css +39 -0
- package/front_end/panels/settings/frameworkIgnoreListSettingsTab.css +37 -8
- package/front_end/panels/settings/settingsScreen.css +0 -24
- package/front_end/panels/sources/BreakpointEditDialog.ts +9 -6
- package/front_end/panels/sources/BreakpointsView.ts +25 -4
- package/front_end/panels/sources/CallStackSidebarPane.ts +7 -1
- package/front_end/panels/sources/DebuggerPlugin.ts +1 -0
- package/front_end/panels/sources/GoToLineQuickOpen.ts +8 -8
- package/front_end/panels/sources/NavigatorView.ts +521 -439
- package/front_end/panels/sources/PersistenceActions.ts +11 -12
- package/front_end/panels/sources/ProfilePlugin.ts +28 -17
- package/front_end/panels/sources/ScopeChainSidebarPane.ts +3 -4
- package/front_end/panels/sources/SourcesNavigator.ts +9 -9
- package/front_end/panels/sources/SourcesPanel.ts +2 -2
- package/front_end/panels/sources/SourcesView.ts +3 -3
- package/front_end/panels/sources/ThreadsSidebarPane.ts +2 -2
- package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +2 -2
- package/front_end/panels/sources/components/HeadersView.ts +1 -2
- package/front_end/panels/timeline/CompatibilityTracksAppender.ts +5 -6
- package/front_end/panels/timeline/EventsTimelineTreeView.ts +73 -34
- package/front_end/panels/timeline/IsolateSelector.ts +25 -37
- package/front_end/panels/timeline/StatusDialog.ts +5 -7
- package/front_end/panels/timeline/ThirdPartyTreeView.ts +10 -13
- package/front_end/panels/timeline/TimelineDetailsView.ts +40 -21
- package/front_end/panels/timeline/TimelineEventOverview.ts +130 -34
- package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +1 -1
- package/front_end/panels/timeline/TimelineMiniMap.ts +255 -103
- package/front_end/panels/timeline/TimelinePaintProfilerView.ts +19 -11
- package/front_end/panels/timeline/TimelinePanel.ts +1 -0
- package/front_end/panels/timeline/TimelineSelectorStatsView.ts +11 -12
- package/front_end/panels/timeline/TimelineTreeView.ts +240 -122
- package/front_end/panels/timeline/TimelineUIUtils.ts +12 -0
- package/front_end/panels/timeline/components/BreadcrumbsUI.ts +5 -4
- package/front_end/panels/timeline/components/DetailsView.ts +97 -65
- package/front_end/panels/timeline/components/LayoutShiftDetails.ts +2 -2
- package/front_end/panels/timeline/components/MetricCard.ts +2 -2
- package/front_end/panels/timeline/components/NetworkRequestDetails.ts +11 -12
- package/front_end/panels/timeline/components/NetworkTrackWidget.ts +57 -50
- package/front_end/panels/timeline/components/RelatedInsightChips.ts +2 -2
- package/front_end/panels/timeline/components/Sidebar.ts +161 -109
- package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +33 -12
- package/front_end/panels/timeline/components/SidebarInsightsTab.ts +3 -0
- package/front_end/panels/timeline/components/insights/LCPDiscovery.ts +11 -11
- package/front_end/panels/timeline/components/insights/SlowCSSSelector.ts +6 -7
- package/front_end/panels/timeline/components/networkTrackWidget.css +24 -22
- package/front_end/panels/timeline/components/sidebarInsightsTab.css +1 -1
- package/front_end/panels/timeline/overlays/components/TimespanBreakdownOverlay.ts +15 -10
- package/front_end/panels/timeline/overlays/components/entryLabelOverlay.css +1 -1
- package/front_end/panels/timeline/timelinePanel.css +5 -0
- package/front_end/panels/timeline/timelineStatusDialog.css +1 -1
- package/front_end/panels/web_audio/WebAudioView.ts +2 -2
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/legacy-javascript/README.chromium +2 -2
- package/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +2 -2
- package/front_end/third_party/legacy-javascript/package.json +1 -1
- package/front_end/third_party/lighthouse/README.chromium +2 -2
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1983 -2022
- package/front_end/third_party/lighthouse/locales/ar-XB.json +157 -142
- package/front_end/third_party/lighthouse/locales/ar.json +157 -142
- package/front_end/third_party/lighthouse/locales/bg.json +154 -139
- package/front_end/third_party/lighthouse/locales/ca.json +157 -142
- package/front_end/third_party/lighthouse/locales/cs.json +148 -133
- package/front_end/third_party/lighthouse/locales/da.json +153 -138
- package/front_end/third_party/lighthouse/locales/de.json +152 -137
- package/front_end/third_party/lighthouse/locales/el.json +153 -138
- package/front_end/third_party/lighthouse/locales/en-GB.json +160 -145
- package/front_end/third_party/lighthouse/locales/en-US.json +239 -218
- package/front_end/third_party/lighthouse/locales/en-XL.json +239 -218
- package/front_end/third_party/lighthouse/locales/es-419.json +150 -135
- package/front_end/third_party/lighthouse/locales/es.json +149 -134
- package/front_end/third_party/lighthouse/locales/fi.json +151 -136
- package/front_end/third_party/lighthouse/locales/fil.json +154 -139
- package/front_end/third_party/lighthouse/locales/fr.json +150 -135
- package/front_end/third_party/lighthouse/locales/he.json +160 -145
- package/front_end/third_party/lighthouse/locales/hi.json +156 -141
- package/front_end/third_party/lighthouse/locales/hr.json +154 -139
- package/front_end/third_party/lighthouse/locales/hu.json +111 -96
- package/front_end/third_party/lighthouse/locales/id.json +153 -138
- package/front_end/third_party/lighthouse/locales/it.json +153 -138
- package/front_end/third_party/lighthouse/locales/ja.json +150 -135
- package/front_end/third_party/lighthouse/locales/ko.json +42 -27
- package/front_end/third_party/lighthouse/locales/lt.json +152 -137
- package/front_end/third_party/lighthouse/locales/lv.json +93 -78
- package/front_end/third_party/lighthouse/locales/nl.json +149 -134
- package/front_end/third_party/lighthouse/locales/no.json +152 -137
- package/front_end/third_party/lighthouse/locales/pl.json +153 -138
- package/front_end/third_party/lighthouse/locales/pt-PT.json +152 -137
- package/front_end/third_party/lighthouse/locales/pt.json +157 -142
- package/front_end/third_party/lighthouse/locales/ro.json +149 -134
- package/front_end/third_party/lighthouse/locales/ru.json +76 -61
- package/front_end/third_party/lighthouse/locales/sk.json +153 -138
- package/front_end/third_party/lighthouse/locales/sl.json +149 -134
- package/front_end/third_party/lighthouse/locales/sr-Latn.json +151 -136
- package/front_end/third_party/lighthouse/locales/sr.json +151 -136
- package/front_end/third_party/lighthouse/locales/sv.json +152 -137
- package/front_end/third_party/lighthouse/locales/ta.json +156 -141
- package/front_end/third_party/lighthouse/locales/te.json +157 -142
- package/front_end/third_party/lighthouse/locales/th.json +111 -96
- package/front_end/third_party/lighthouse/locales/tr.json +153 -138
- package/front_end/third_party/lighthouse/locales/uk.json +149 -134
- package/front_end/third_party/lighthouse/locales/vi.json +162 -147
- package/front_end/third_party/lighthouse/locales/zh-HK.json +150 -135
- package/front_end/third_party/lighthouse/locales/zh-TW.json +154 -139
- package/front_end/third_party/lighthouse/locales/zh.json +152 -137
- package/front_end/third_party/lighthouse/report/bundle.d.ts +9 -8
- package/front_end/third_party/lighthouse/report/bundle.js +10 -10
- package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +2 -7
- package/front_end/tsconfig.compatibility.json +1 -0
- package/front_end/tsconfig.json +3 -2
- package/front_end/ui/components/dialogs/TypeToAllowDialog.ts +0 -2
- package/front_end/ui/components/dialogs/typeToAllowDialog.css +0 -4
- package/front_end/ui/components/icon_button/fileSourceIcon.css +1 -1
- package/front_end/ui/components/input/textInput.css +1 -1
- package/front_end/ui/components/lists/List.ts +26 -14
- package/front_end/ui/components/menus/menus.ts +0 -2
- package/front_end/ui/components/suggestion_input/SuggestionInput.ts +351 -138
- package/front_end/ui/components/survey_link/surveyLink.css +3 -3
- package/front_end/ui/components/switch/switch.css +6 -6
- package/front_end/ui/components/text_editor/AiCodeCompletionTeaser.ts +2 -3
- package/front_end/ui/components/text_editor/TextEditor.ts +1 -1
- package/front_end/ui/components/tooltips/Tooltip.ts +53 -4
- package/front_end/ui/components/tree_outline/treeOutline.css +7 -7
- package/front_end/ui/helpers/OpenInNewTab.ts +8 -3
- package/front_end/ui/legacy/EmptyWidget.ts +4 -4
- package/front_end/ui/legacy/ForwardedInputEventHandler.ts +2 -2
- package/front_end/ui/legacy/GlassPane.ts +1 -1
- package/front_end/ui/legacy/KeyboardShortcut.ts +7 -7
- package/front_end/ui/legacy/RemoteDebuggingTerminatedScreen.ts +2 -2
- package/front_end/ui/legacy/TabbedPane.ts +198 -66
- package/front_end/ui/legacy/TargetCrashedScreen.ts +2 -2
- package/front_end/ui/legacy/UIUtils.ts +71 -68
- package/front_end/ui/legacy/View.ts +7 -4
- package/front_end/ui/legacy/ViewManager.ts +49 -37
- package/front_end/ui/legacy/Widget.ts +32 -12
- package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +2 -3
- package/front_end/ui/legacy/components/inline_editor/AnimationTimingUI.ts +8 -8
- package/front_end/ui/legacy/components/inline_editor/BezierUI.ts +8 -9
- package/front_end/ui/legacy/components/inline_editor/LinkSwatch.ts +2 -2
- package/front_end/ui/legacy/components/inline_editor/cssAngleEditor.css +1 -1
- package/front_end/ui/legacy/components/inline_editor/cssAngleSwatch.css +1 -1
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +45 -11
- package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +10 -12
- package/front_end/ui/legacy/components/perf_ui/ChartViewport.ts +102 -29
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +148 -122
- package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +20 -14
- package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +1 -1
- package/front_end/ui/legacy/components/source_frame/FontView.ts +29 -5
- package/front_end/ui/legacy/components/source_frame/ImageView.ts +79 -12
- package/front_end/ui/legacy/components/source_frame/JSONView.ts +20 -2
- package/front_end/ui/legacy/components/source_frame/PreviewFactory.ts +2 -2
- package/front_end/ui/legacy/components/source_frame/StreamingContentHexView.ts +6 -10
- package/front_end/ui/legacy/components/source_frame/XMLView.ts +11 -11
- package/front_end/ui/legacy/components/source_frame/fontView.css +7 -0
- package/front_end/ui/legacy/components/source_frame/imageView.css +7 -0
- package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +14 -3
- package/front_end/ui/legacy/components/utils/Linkifier.ts +126 -2
- package/front_end/ui/legacy/emptyWidget.css +2 -1
- package/front_end/ui/legacy/inspectorCommon.css +3 -3
- package/front_end/ui/legacy/smallBubble.css +1 -1
- package/front_end/ui/legacy/tabbedPane.css +6 -0
- package/front_end/ui/lit/Directives.ts +35 -18
- package/front_end/ui/lit/lit.ts +0 -2
- package/front_end/ui/lit/render.ts +0 -7
- package/front_end/ui/visual_logging/KnownContextValues.ts +5 -0
- package/package.json +1 -1
- package/vpython.toml +8 -0
- package/vpython.toml.uv.lock +3 -0
- package/.agents/skills/review-models-core/SKILL.md +0 -73
- package/.agents/skills/review-tests/SKILL.md +0 -67
- package/.agents/skills/review-ui-widgets/SKILL.md +0 -115
- package/front_end/generated/ARIAProperties.ts +0 -2686
- package/front_end/ui/components/menus/README.md +0 -119
- package/front_end/ui/components/menus/SelectMenu.ts +0 -473
- package/front_end/ui/components/menus/selectMenu.css +0 -54
- package/front_end/ui/components/menus/selectMenuButton.css +0 -108
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// Copyright 2017 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
|
-
/* eslint-disable @devtools/no-imperative-dom-api */
|
|
5
4
|
|
|
5
|
+
import '../../ui/components/lists/lists.js';
|
|
6
6
|
import '../../ui/kit/kit.js';
|
|
7
7
|
|
|
8
8
|
import * as Common from '../../core/common/common.js';
|
|
9
9
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
10
|
+
import * as Platform from '../../core/platform/platform.js';
|
|
10
11
|
import * as SDK from '../../core/sdk/sdk.js';
|
|
11
12
|
import * as Buttons from '../../ui/components/buttons/buttons.js';
|
|
12
|
-
import
|
|
13
|
+
import type * as Lists from '../../ui/components/lists/lists.js';
|
|
13
14
|
import * as UI from '../../ui/legacy/legacy.js';
|
|
15
|
+
import {Directives, html, type LitTemplate, nothing, render} from '../../ui/lit/lit.js';
|
|
14
16
|
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
|
|
15
17
|
import * as PanelsCommon from '../common/common.js';
|
|
16
18
|
|
|
@@ -18,6 +20,8 @@ import {CalibrationController} from './CalibrationController.js';
|
|
|
18
20
|
import {ThrottlingPresets} from './ThrottlingPresets.js';
|
|
19
21
|
import throttlingSettingsTabStyles from './throttlingSettingsTab.css.js';
|
|
20
22
|
|
|
23
|
+
const {widget} = UI.Widget;
|
|
24
|
+
|
|
21
25
|
const UIStrings = {
|
|
22
26
|
/**
|
|
23
27
|
* @description Title for default network throttling profiles card.
|
|
@@ -151,6 +155,14 @@ const UIStrings = {
|
|
|
151
155
|
* @description Button text to allow the user to cancel the CPU calibration process.
|
|
152
156
|
*/
|
|
153
157
|
cancel: 'Cancel',
|
|
158
|
+
/**
|
|
159
|
+
* @description Button text to save changes when editing a custom profile in the throttling settings tab.
|
|
160
|
+
*/
|
|
161
|
+
save: 'Save',
|
|
162
|
+
/**
|
|
163
|
+
* @description Button text to add a new custom profile in the throttling settings tab.
|
|
164
|
+
*/
|
|
165
|
+
add: 'Add',
|
|
154
166
|
/**
|
|
155
167
|
* @description Text to use to indicate that a CPU calibration has not been run yet.
|
|
156
168
|
*/
|
|
@@ -220,125 +232,146 @@ function createComputePressurePromise(): Promise<{state: string}> {
|
|
|
220
232
|
});
|
|
221
233
|
}
|
|
222
234
|
|
|
223
|
-
export
|
|
224
|
-
|
|
235
|
+
export interface CPUThrottlingCardViewInput {
|
|
236
|
+
state: 'cta'|'prompting'|'calibrating';
|
|
237
|
+
hasCalibrated: boolean;
|
|
238
|
+
lowResultText: string;
|
|
239
|
+
lowNotCalibrated: boolean;
|
|
240
|
+
midResultText: string;
|
|
241
|
+
midNotCalibrated: boolean;
|
|
242
|
+
warnings: string[];
|
|
243
|
+
progressWorked: number;
|
|
244
|
+
onCalibrateClick: () => void;
|
|
245
|
+
onCancelClick: () => void;
|
|
246
|
+
}
|
|
225
247
|
|
|
226
|
-
|
|
248
|
+
export type CPUThrottlingCardView = (input: CPUThrottlingCardViewInput, output: undefined, target: HTMLElement) => void;
|
|
249
|
+
|
|
250
|
+
export const CPU_THROTTLING_CARD_DEFAULT_VIEW: CPUThrottlingCardView = (input, _output, target) => {
|
|
251
|
+
const renderTextWithIcon = (text: string, icon: string): LitTemplate => html`
|
|
252
|
+
<div class="text-with-icon">
|
|
253
|
+
<devtools-icon name=${icon}></devtools-icon>
|
|
254
|
+
${text}
|
|
255
|
+
</div>
|
|
256
|
+
`;
|
|
257
|
+
|
|
258
|
+
const showCalibrateButton = input.state === 'cta' || input.state === 'prompting';
|
|
259
|
+
const calibrateButtonText = input.state === 'prompting' ?
|
|
260
|
+
i18nString(UIStrings.continue) :
|
|
261
|
+
(input.hasCalibrated ? i18nString(UIStrings.recalibrate) : i18nString(UIStrings.calibrate));
|
|
262
|
+
const showCancelButton = input.state === 'prompting' || input.state === 'calibrating';
|
|
263
|
+
const showTextContainer = (input.state === 'cta' && !input.hasCalibrated) || input.state === 'prompting';
|
|
264
|
+
const showProgress = input.state === 'calibrating';
|
|
265
|
+
|
|
266
|
+
// clang-format off
|
|
267
|
+
render(
|
|
268
|
+
html`
|
|
269
|
+
<devtools-card heading=${i18nString(UIStrings.cpuThrottlingPresets)}>
|
|
270
|
+
<span>${i18nString(UIStrings.cpuCalibrationDescription)}</span>
|
|
271
|
+
<div class="cpu-preset-section">
|
|
272
|
+
${i18nString(UIStrings.calibratedLowTierMobile)}
|
|
273
|
+
<div class=${Directives.classMap({
|
|
274
|
+
'cpu-preset-result': true,
|
|
275
|
+
'not-calibrated': input.lowNotCalibrated,
|
|
276
|
+
})}>
|
|
277
|
+
${input.lowResultText}
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
<div class="cpu-preset-section">
|
|
281
|
+
${i18nString(UIStrings.calibratedMidTierMobile)}
|
|
282
|
+
<div class=${Directives.classMap({
|
|
283
|
+
'cpu-preset-result': true,
|
|
284
|
+
'not-calibrated': input.midNotCalibrated,
|
|
285
|
+
})}>
|
|
286
|
+
${input.midResultText}
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
<div class="cpu-preset-section cpu-preset-calibrate">
|
|
290
|
+
<div class="button-container">
|
|
291
|
+
<devtools-button
|
|
292
|
+
class="calibrate-button"
|
|
293
|
+
style=${showCalibrateButton ? '' : 'display: none'}
|
|
294
|
+
.variant=${Buttons.Button.Variant.PRIMARY}
|
|
295
|
+
.jslogContext=${'throttling.calibrate'}
|
|
296
|
+
@click=${input.onCalibrateClick}>
|
|
297
|
+
${calibrateButtonText}
|
|
298
|
+
</devtools-button>
|
|
299
|
+
<devtools-button
|
|
300
|
+
class="cancel-button"
|
|
301
|
+
style=${showCancelButton ? '' : 'display: none'}
|
|
302
|
+
.variant=${Buttons.Button.Variant.OUTLINED}
|
|
303
|
+
.jslogContext=${'throttling.calibrate-cancel'}
|
|
304
|
+
@click=${input.onCancelClick}>
|
|
305
|
+
${i18nString(UIStrings.cancel)}
|
|
306
|
+
</devtools-button>
|
|
307
|
+
</div>
|
|
308
|
+
<div
|
|
309
|
+
class="text-container"
|
|
310
|
+
style=${showTextContainer ? '' : 'display: none'}>
|
|
311
|
+
${input.state === 'cta' && !input.hasCalibrated
|
|
312
|
+
? renderTextWithIcon(i18nString(UIStrings.calibrationCTA), 'info')
|
|
313
|
+
: nothing}
|
|
314
|
+
${input.state === 'prompting' ? html`
|
|
315
|
+
${input.warnings.map(warning => renderTextWithIcon(warning, 'warning'))}
|
|
316
|
+
${renderTextWithIcon(i18nString(UIStrings.calibrationConfirmationPrompt), 'info')}
|
|
317
|
+
` : nothing}
|
|
318
|
+
</div>
|
|
319
|
+
<devtools-progress
|
|
320
|
+
no-stop-button
|
|
321
|
+
style=${showProgress ? '' : 'display: none'}
|
|
322
|
+
.worked=${input.progressWorked}
|
|
323
|
+
.totalWork=${1}>
|
|
324
|
+
</devtools-progress>
|
|
325
|
+
</div>
|
|
326
|
+
</devtools-card>
|
|
327
|
+
`,
|
|
328
|
+
target);
|
|
329
|
+
// clang-format on
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export class CPUThrottlingCard extends UI.Widget.Widget {
|
|
333
|
+
#setting?: Common.Settings.Setting<PanelsCommon.CPUThrottlingOption.CalibratedCPUThrottling>;
|
|
227
334
|
private computePressurePromise?: ReturnType<typeof createComputePressurePromise>;
|
|
228
335
|
private controller?: CalibrationController;
|
|
229
|
-
|
|
230
|
-
// UI stuff.
|
|
231
|
-
private lowTierMobileDeviceEl: HTMLElement;
|
|
232
|
-
private midTierMobileDeviceEl: HTMLElement;
|
|
233
|
-
private calibrateEl: HTMLElement;
|
|
234
|
-
private textEl: HTMLElement;
|
|
235
|
-
private calibrateButton: Buttons.Button.Button;
|
|
236
|
-
private cancelButton: Buttons.Button.Button;
|
|
237
|
-
private progress: UI.ProgressIndicator.ProgressIndicator;
|
|
238
336
|
private state: 'cta'|'prompting'|'calibrating' = 'cta';
|
|
239
337
|
private warnings: string[] = [];
|
|
338
|
+
readonly #view: CPUThrottlingCardView;
|
|
339
|
+
#progressWorked = 0;
|
|
240
340
|
|
|
241
|
-
constructor(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
this.element = document.createElement('devtools-card');
|
|
246
|
-
this.element.heading = i18nString(UIStrings.cpuThrottlingPresets);
|
|
247
|
-
|
|
248
|
-
const descriptionEl = this.element.createChild('span');
|
|
249
|
-
descriptionEl.textContent = i18nString(UIStrings.cpuCalibrationDescription);
|
|
250
|
-
|
|
251
|
-
this.lowTierMobileDeviceEl = this.element.createChild('div', 'cpu-preset-section');
|
|
252
|
-
this.lowTierMobileDeviceEl.append(i18nString(UIStrings.calibratedLowTierMobile));
|
|
253
|
-
this.lowTierMobileDeviceEl.createChild('div', 'cpu-preset-result');
|
|
254
|
-
|
|
255
|
-
this.midTierMobileDeviceEl = this.element.createChild('div', 'cpu-preset-section');
|
|
256
|
-
this.midTierMobileDeviceEl.append(i18nString(UIStrings.calibratedMidTierMobile));
|
|
257
|
-
this.midTierMobileDeviceEl.createChild('div', 'cpu-preset-result');
|
|
258
|
-
|
|
259
|
-
this.calibrateEl = this.element.createChild('div', 'cpu-preset-section cpu-preset-calibrate');
|
|
260
|
-
|
|
261
|
-
const buttonContainerEl = this.calibrateEl.createChild('div', 'button-container');
|
|
262
|
-
|
|
263
|
-
this.calibrateButton = new Buttons.Button.Button();
|
|
264
|
-
this.calibrateButton.classList.add('calibrate-button');
|
|
265
|
-
this.calibrateButton.data = {
|
|
266
|
-
variant: Buttons.Button.Variant.PRIMARY,
|
|
267
|
-
jslogContext: 'throttling.calibrate',
|
|
268
|
-
};
|
|
269
|
-
this.calibrateButton.addEventListener('click', () => this.calibrateButtonClicked());
|
|
270
|
-
buttonContainerEl.append(this.calibrateButton);
|
|
271
|
-
|
|
272
|
-
this.cancelButton = new Buttons.Button.Button();
|
|
273
|
-
this.cancelButton.classList.add('cancel-button');
|
|
274
|
-
this.cancelButton.data = {
|
|
275
|
-
variant: Buttons.Button.Variant.OUTLINED,
|
|
276
|
-
jslogContext: 'throttling.calibrate-cancel',
|
|
277
|
-
};
|
|
278
|
-
this.cancelButton.textContent = i18nString(UIStrings.cancel);
|
|
279
|
-
this.cancelButton.addEventListener('click', () => this.cancelButtonClicked());
|
|
280
|
-
buttonContainerEl.append(this.cancelButton);
|
|
281
|
-
|
|
282
|
-
this.textEl = this.calibrateEl.createChild('div', 'text-container');
|
|
283
|
-
|
|
284
|
-
this.progress = this.calibrateEl.createChild('devtools-progress');
|
|
285
|
-
this.progress.setAttribute('no-stop-button', '');
|
|
286
|
-
|
|
287
|
-
this.updateState();
|
|
341
|
+
constructor(element?: HTMLElement, view: CPUThrottlingCardView = CPU_THROTTLING_CARD_DEFAULT_VIEW) {
|
|
342
|
+
super(element);
|
|
343
|
+
this.#view = view;
|
|
344
|
+
this.performUpdate();
|
|
288
345
|
}
|
|
289
346
|
|
|
290
|
-
wasShown(): void {
|
|
347
|
+
override wasShown(): void {
|
|
348
|
+
super.wasShown();
|
|
291
349
|
this.computePressurePromise = createComputePressurePromise();
|
|
292
350
|
this.state = 'cta';
|
|
293
|
-
this.
|
|
351
|
+
this.performUpdate();
|
|
294
352
|
}
|
|
295
353
|
|
|
296
|
-
willHide(): void {
|
|
354
|
+
override willHide(): void {
|
|
355
|
+
super.willHide();
|
|
297
356
|
this.computePressurePromise = undefined;
|
|
298
357
|
if (this.controller) {
|
|
299
358
|
this.controller.abort();
|
|
300
359
|
}
|
|
301
360
|
}
|
|
302
361
|
|
|
303
|
-
|
|
362
|
+
override performUpdate(): void {
|
|
363
|
+
if (!this.#setting && Common.Settings.Settings.hasInstance()) {
|
|
364
|
+
this.#setting =
|
|
365
|
+
Common.Settings.Settings.instance().createSetting<PanelsCommon.CPUThrottlingOption.CalibratedCPUThrottling>(
|
|
366
|
+
'calibrated-cpu-throttling', {}, Common.Settings.SettingStorageType.GLOBAL);
|
|
367
|
+
}
|
|
368
|
+
|
|
304
369
|
if (this.state !== 'calibrating') {
|
|
305
370
|
this.controller = undefined;
|
|
306
371
|
}
|
|
307
372
|
|
|
308
|
-
const result = this
|
|
309
|
-
const hasCalibrated = result.low || result.mid;
|
|
310
|
-
|
|
311
|
-
this.calibrateButton.style.display = 'none';
|
|
312
|
-
this.textEl.style.display = 'none';
|
|
313
|
-
this.cancelButton.style.display = 'none';
|
|
314
|
-
this.progress.style.display = 'none';
|
|
315
|
-
|
|
316
|
-
if (this.state === 'cta') {
|
|
317
|
-
this.calibrateButton.style.display = '';
|
|
318
|
-
this.calibrateButton.textContent =
|
|
319
|
-
hasCalibrated ? i18nString(UIStrings.recalibrate) : i18nString(UIStrings.calibrate);
|
|
320
|
-
|
|
321
|
-
if (!hasCalibrated) {
|
|
322
|
-
this.textEl.style.display = '';
|
|
323
|
-
this.textEl.textContent = '';
|
|
324
|
-
this.textEl.append(this.createTextWithIcon(i18nString(UIStrings.calibrationCTA), 'info'));
|
|
325
|
-
}
|
|
326
|
-
} else if (this.state === 'prompting') {
|
|
327
|
-
this.calibrateButton.style.display = '';
|
|
328
|
-
this.calibrateButton.textContent = i18nString(UIStrings.continue);
|
|
329
|
-
|
|
330
|
-
this.cancelButton.style.display = '';
|
|
331
|
-
|
|
332
|
-
this.textEl.style.display = '';
|
|
333
|
-
this.textEl.textContent = '';
|
|
334
|
-
for (const warning of this.warnings) {
|
|
335
|
-
this.textEl.append(this.createTextWithIcon(warning, 'warning'));
|
|
336
|
-
}
|
|
337
|
-
this.textEl.append(this.createTextWithIcon(i18nString(UIStrings.calibrationConfirmationPrompt), 'info'));
|
|
338
|
-
} else if (this.state === 'calibrating') {
|
|
339
|
-
this.cancelButton.style.display = '';
|
|
340
|
-
this.progress.style.display = '';
|
|
341
|
-
}
|
|
373
|
+
const result = this.#setting?.get() ?? {};
|
|
374
|
+
const hasCalibrated = Boolean(result.low || result.mid);
|
|
342
375
|
|
|
343
376
|
const resultToString = (result: number|PanelsCommon.CPUThrottlingOption.CalibrationError|undefined): string => {
|
|
344
377
|
if (result === undefined) {
|
|
@@ -358,26 +391,24 @@ export class CPUThrottlingCard {
|
|
|
358
391
|
return i18nString(UIStrings.dSlowdown, {PH1: result.toFixed(1)});
|
|
359
392
|
};
|
|
360
393
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
el.append(text);
|
|
380
|
-
return el;
|
|
394
|
+
this.#view(
|
|
395
|
+
{
|
|
396
|
+
state: this.state,
|
|
397
|
+
hasCalibrated,
|
|
398
|
+
lowResultText: resultToString(result.low),
|
|
399
|
+
lowNotCalibrated: result.low === undefined,
|
|
400
|
+
midResultText: resultToString(result.mid),
|
|
401
|
+
midNotCalibrated: result.mid === undefined,
|
|
402
|
+
warnings: this.warnings,
|
|
403
|
+
progressWorked: this.#progressWorked,
|
|
404
|
+
onCalibrateClick: () => {
|
|
405
|
+
void this.calibrateButtonClicked();
|
|
406
|
+
},
|
|
407
|
+
onCancelClick: () => this.cancelButtonClicked(),
|
|
408
|
+
},
|
|
409
|
+
undefined,
|
|
410
|
+
this.element,
|
|
411
|
+
);
|
|
381
412
|
}
|
|
382
413
|
|
|
383
414
|
private async getCalibrationWarnings(): Promise<string[]> {
|
|
@@ -405,10 +436,10 @@ export class CPUThrottlingCard {
|
|
|
405
436
|
if (this.state === 'cta') {
|
|
406
437
|
this.warnings = await this.getCalibrationWarnings();
|
|
407
438
|
this.state = 'prompting';
|
|
408
|
-
this.
|
|
439
|
+
this.requestUpdate();
|
|
409
440
|
} else if (this.state === 'prompting') {
|
|
410
441
|
this.state = 'calibrating';
|
|
411
|
-
this.
|
|
442
|
+
this.requestUpdate();
|
|
412
443
|
void this.runCalibration();
|
|
413
444
|
}
|
|
414
445
|
}
|
|
@@ -418,13 +449,13 @@ export class CPUThrottlingCard {
|
|
|
418
449
|
this.controller.abort();
|
|
419
450
|
} else {
|
|
420
451
|
this.state = 'cta';
|
|
421
|
-
this.
|
|
452
|
+
this.requestUpdate();
|
|
422
453
|
}
|
|
423
454
|
}
|
|
424
455
|
|
|
425
456
|
private async runCalibration(): Promise<void> {
|
|
426
|
-
this
|
|
427
|
-
this.
|
|
457
|
+
this.#progressWorked = 0;
|
|
458
|
+
this.requestUpdate();
|
|
428
459
|
|
|
429
460
|
this.controller = new CalibrationController();
|
|
430
461
|
|
|
@@ -435,7 +466,8 @@ export class CPUThrottlingCard {
|
|
|
435
466
|
}
|
|
436
467
|
|
|
437
468
|
for await (const result of this.controller.iterator()) {
|
|
438
|
-
this
|
|
469
|
+
this.#progressWorked = result.progress;
|
|
470
|
+
this.requestUpdate();
|
|
439
471
|
}
|
|
440
472
|
} catch (e) {
|
|
441
473
|
console.error(e);
|
|
@@ -444,15 +476,16 @@ export class CPUThrottlingCard {
|
|
|
444
476
|
}
|
|
445
477
|
|
|
446
478
|
const result = this.controller.result();
|
|
447
|
-
if (result && (result.low || result.mid)) {
|
|
448
|
-
this
|
|
479
|
+
if (result && (result.low || result.mid) && this.#setting) {
|
|
480
|
+
this.#setting.set(result);
|
|
449
481
|
// Let the user bask in the glory of a 100% progress bar, for a bit.
|
|
450
|
-
this
|
|
482
|
+
this.#progressWorked = 1;
|
|
483
|
+
this.requestUpdate();
|
|
451
484
|
await new Promise(resolve => setTimeout(resolve, 200));
|
|
452
485
|
}
|
|
453
486
|
|
|
454
487
|
this.state = 'cta';
|
|
455
|
-
this.
|
|
488
|
+
this.requestUpdate();
|
|
456
489
|
}
|
|
457
490
|
}
|
|
458
491
|
|
|
@@ -464,15 +497,312 @@ function extractCustomSettingIndex(key: SDK.NetworkManager.UserDefinedThrottling
|
|
|
464
497
|
return 0;
|
|
465
498
|
}
|
|
466
499
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
500
|
+
function retrieveOptionsTitle(conditions: SDK.NetworkManager.Conditions): string {
|
|
501
|
+
// The title is usually an i18nLazyString except for custom values that are stored in the local storage in the form of a string.
|
|
502
|
+
return typeof conditions.title === 'function' ? conditions.title() : conditions.title;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export interface EditorValues {
|
|
506
|
+
title: string;
|
|
507
|
+
download: string;
|
|
508
|
+
upload: string;
|
|
509
|
+
latency: string;
|
|
510
|
+
packetLoss: string;
|
|
511
|
+
packetQueueLength: string;
|
|
512
|
+
packetReordering: boolean;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export type EditorFieldName = keyof EditorValues;
|
|
516
|
+
|
|
517
|
+
export interface ViewInput {
|
|
518
|
+
presets: SDK.NetworkManager.Conditions[];
|
|
519
|
+
customConditions: SDK.NetworkManager.Conditions[];
|
|
520
|
+
editingIndex: number|null;
|
|
521
|
+
editingValues: EditorValues;
|
|
522
|
+
validationErrors: Partial<Record<EditorFieldName, Common.UIString.LocalizedString>>;
|
|
523
|
+
showValidationErrors: boolean;
|
|
524
|
+
onAddCustomProfile: () => void;
|
|
525
|
+
onBeginEdit: (index: number) => void;
|
|
526
|
+
onRemoveCustomProfile: (index: number) => void;
|
|
527
|
+
onEditorInput: <K extends EditorFieldName>(field: K, value: EditorValues[K]) => void;
|
|
528
|
+
onCommitEdit: () => void;
|
|
529
|
+
onCancelEdit: () => void;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
|
|
533
|
+
|
|
534
|
+
function renderHeaderRow(): LitTemplate {
|
|
535
|
+
const profileName = i18nString(UIStrings.profileName);
|
|
536
|
+
const columns = [
|
|
537
|
+
i18nString(UIStrings.download),
|
|
538
|
+
i18nString(UIStrings.upload),
|
|
539
|
+
i18nString(UIStrings.latency),
|
|
540
|
+
i18nString(UIStrings.packetLoss),
|
|
541
|
+
i18nString(UIStrings.packetQueueLength),
|
|
542
|
+
i18nString(UIStrings.packetReordering),
|
|
543
|
+
];
|
|
544
|
+
// clang-format off
|
|
545
|
+
return html`
|
|
546
|
+
<div class="conditions-list-item conditions-list-header">
|
|
547
|
+
<div class="conditions-list-text conditions-list-title" title=${profileName}>
|
|
548
|
+
<div class="conditions-list-title-text">${profileName}</div>
|
|
549
|
+
</div>
|
|
550
|
+
${columns.map(column => html`
|
|
551
|
+
<div class="conditions-list-separator"></div>
|
|
552
|
+
<div class="conditions-list-text" title=${column}>${column}</div>
|
|
553
|
+
`)}
|
|
554
|
+
</div>
|
|
555
|
+
`;
|
|
556
|
+
// clang-format on
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function renderConditionsItem(conditions: SDK.NetworkManager.Conditions): LitTemplate {
|
|
560
|
+
const title = retrieveOptionsTitle(conditions);
|
|
561
|
+
const downloadText = throughputText(conditions.download);
|
|
562
|
+
const uploadText = throughputText(conditions.upload);
|
|
563
|
+
const latencyText = i18nString(UIStrings.dms, {PH1: conditions.latency});
|
|
564
|
+
const packetLossText = percentText(conditions.packetLoss ?? 0);
|
|
565
|
+
const packetQueueLengthText = String(conditions.packetQueueLength ?? 0);
|
|
566
|
+
const packetReorderingText = conditions.packetReordering ? i18nString(UIStrings.on) : i18nString(UIStrings.off);
|
|
567
|
+
// clang-format off
|
|
568
|
+
return html`
|
|
569
|
+
<div class="conditions-list-item">
|
|
570
|
+
<div class="conditions-list-text conditions-list-title" title=${title}>
|
|
571
|
+
<div class="conditions-list-title-text">${title}</div>
|
|
572
|
+
</div>
|
|
573
|
+
<div class="conditions-list-separator"></div>
|
|
574
|
+
<div class="conditions-list-text">${downloadText}</div>
|
|
575
|
+
<div class="conditions-list-separator"></div>
|
|
576
|
+
<div class="conditions-list-text">${uploadText}</div>
|
|
577
|
+
<div class="conditions-list-separator"></div>
|
|
578
|
+
<div class="conditions-list-text">${latencyText}</div>
|
|
579
|
+
<div class="conditions-list-separator"></div>
|
|
580
|
+
<div class="conditions-list-text">${packetLossText}</div>
|
|
581
|
+
<div class="conditions-list-separator"></div>
|
|
582
|
+
<div class="conditions-list-text">${packetQueueLengthText}</div>
|
|
583
|
+
<div class="conditions-list-separator"></div>
|
|
584
|
+
<div class="conditions-list-text">${packetReorderingText}</div>
|
|
585
|
+
</div>
|
|
586
|
+
`;
|
|
587
|
+
// clang-format on
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
interface TextFieldDefinition {
|
|
591
|
+
name: Exclude<EditorFieldName, 'packetReordering'>;
|
|
592
|
+
labelText: Common.UIString.LocalizedString;
|
|
593
|
+
placeholder: string;
|
|
594
|
+
isOptional: boolean;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function renderEditor(input: ViewInput): LitTemplate {
|
|
598
|
+
const isNew = input.editingIndex === input.customConditions.length;
|
|
599
|
+
const optionalStr = i18nString(UIStrings.optional);
|
|
600
|
+
const textFields: TextFieldDefinition[] = [
|
|
601
|
+
{
|
|
602
|
+
name: 'title',
|
|
603
|
+
labelText: i18nString(UIStrings.profileName),
|
|
604
|
+
placeholder: '',
|
|
605
|
+
isOptional: false,
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: 'download',
|
|
609
|
+
labelText: i18nString(UIStrings.download),
|
|
610
|
+
placeholder: i18n.i18n.lockedString('kbit/s'),
|
|
611
|
+
isOptional: true,
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: 'upload',
|
|
615
|
+
labelText: i18nString(UIStrings.upload),
|
|
616
|
+
placeholder: i18n.i18n.lockedString('kbit/s'),
|
|
617
|
+
isOptional: true,
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
name: 'latency',
|
|
621
|
+
labelText: i18nString(UIStrings.latency),
|
|
622
|
+
placeholder: i18n.i18n.lockedString('ms'),
|
|
623
|
+
isOptional: true,
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
name: 'packetLoss',
|
|
627
|
+
labelText: i18nString(UIStrings.packetLoss),
|
|
628
|
+
placeholder: i18n.i18n.lockedString('percent'),
|
|
629
|
+
isOptional: true,
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
name: 'packetQueueLength',
|
|
633
|
+
labelText: i18nString(UIStrings.packetQueueLength),
|
|
634
|
+
placeholder: i18nString(UIStrings.packet),
|
|
635
|
+
isOptional: true,
|
|
636
|
+
},
|
|
637
|
+
];
|
|
638
|
+
const errorMessages = Object.values(input.validationErrors).filter(Boolean);
|
|
639
|
+
const hasErrors = errorMessages.length > 0;
|
|
640
|
+
|
|
641
|
+
// clang-format off
|
|
642
|
+
return html`
|
|
643
|
+
<div
|
|
644
|
+
class="editor-container"
|
|
645
|
+
jslog=${VisualLogging.pane('editor').track({resize: true})}
|
|
646
|
+
@keydown=${(e: KeyboardEvent) => {
|
|
647
|
+
if (Platform.KeyboardUtilities.isEscKey(e)) {
|
|
648
|
+
e.consume(true);
|
|
649
|
+
input.onCancelEdit();
|
|
650
|
+
}
|
|
651
|
+
}}>
|
|
652
|
+
<div
|
|
653
|
+
class="editor-content"
|
|
654
|
+
@keydown=${(e: KeyboardEvent) => {
|
|
655
|
+
if (e.key === 'Enter') {
|
|
656
|
+
e.consume(true);
|
|
657
|
+
input.onCommitEdit();
|
|
658
|
+
}
|
|
659
|
+
}}>
|
|
660
|
+
<div class="settings-container">
|
|
661
|
+
${textFields.map((field, index) => {
|
|
662
|
+
const isInvalid = input.showValidationErrors && Boolean(input.validationErrors[field.name]);
|
|
663
|
+
return html`
|
|
664
|
+
<div class="setting">
|
|
665
|
+
<div>${field.labelText}</div>
|
|
666
|
+
<div>
|
|
667
|
+
<input
|
|
668
|
+
class=${Directives.classMap({
|
|
669
|
+
'harmony-input': true,
|
|
670
|
+
input: true,
|
|
671
|
+
'error-input': isInvalid,
|
|
672
|
+
})}
|
|
673
|
+
type="text"
|
|
674
|
+
?autofocus=${index === 0}
|
|
675
|
+
placeholder=${field.placeholder}
|
|
676
|
+
aria-label=${field.labelText}
|
|
677
|
+
aria-description=${optionalStr}
|
|
678
|
+
aria-invalid=${isInvalid ? 'true' : 'false'}
|
|
679
|
+
.value=${Directives.live(input.editingValues[field.name])}
|
|
680
|
+
jslog=${VisualLogging.textField().track({change: true, keydown: 'Enter'}).context(field.name)}
|
|
681
|
+
@input=${(e: Event) => input.onEditorInput(field.name, (e.target as HTMLInputElement).value)}>
|
|
682
|
+
<div style=${field.isOptional ? '' : 'visibility: hidden'}>
|
|
683
|
+
${optionalStr}
|
|
684
|
+
</div>
|
|
685
|
+
</div>
|
|
686
|
+
</div>
|
|
687
|
+
`;
|
|
688
|
+
})}
|
|
689
|
+
<div class="setting">
|
|
690
|
+
<div>${i18nString(UIStrings.packetReordering)}</div>
|
|
691
|
+
<div>
|
|
692
|
+
<devtools-checkbox
|
|
693
|
+
class="input"
|
|
694
|
+
aria-label=${i18nString(UIStrings.packetReordering)}
|
|
695
|
+
aria-description=${optionalStr}
|
|
696
|
+
.checked=${input.editingValues.packetReordering}
|
|
697
|
+
.jslogContext=${'packetReordering'}
|
|
698
|
+
@change=${(e: Event) => input.onEditorInput('packetReordering', (e.target as UI.UIUtils.CheckboxLabel).checked)}>
|
|
699
|
+
</devtools-checkbox>
|
|
700
|
+
<div style="visibility: hidden">
|
|
701
|
+
${optionalStr}
|
|
702
|
+
</div>
|
|
703
|
+
</div>
|
|
704
|
+
</div>
|
|
705
|
+
</div>
|
|
706
|
+
</div>
|
|
707
|
+
<div class="editor-buttons">
|
|
708
|
+
<devtools-button
|
|
709
|
+
.variant=${Buttons.Button.Variant.OUTLINED}
|
|
710
|
+
.jslogContext=${'cancel'}
|
|
711
|
+
jslog=${VisualLogging.action('cancel').track({click: true})}
|
|
712
|
+
@click=${input.onCancelEdit}>
|
|
713
|
+
${i18nString(UIStrings.cancel)}
|
|
714
|
+
</devtools-button>
|
|
715
|
+
<devtools-button
|
|
716
|
+
.variant=${Buttons.Button.Variant.PRIMARY}
|
|
717
|
+
.jslogContext=${'commit'}
|
|
718
|
+
.disabled=${hasErrors}
|
|
719
|
+
@click=${input.onCommitEdit}>
|
|
720
|
+
${isNew ? i18nString(UIStrings.add) : i18nString(UIStrings.save)}
|
|
721
|
+
</devtools-button>
|
|
722
|
+
</div>
|
|
723
|
+
<div class="list-widget-input-validation-error" role="alert" aria-live="polite">
|
|
724
|
+
${input.showValidationErrors && hasErrors
|
|
725
|
+
? errorMessages.map((msg, i) => html`${i > 0 ? html`<br>` : nothing}${msg}`)
|
|
726
|
+
: nothing}
|
|
727
|
+
</div>
|
|
728
|
+
</div>
|
|
729
|
+
`;
|
|
730
|
+
// clang-format on
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
export const DEFAULT_VIEW: View = (input, _output, target) => {
|
|
734
|
+
const editingIndex = input.editingIndex;
|
|
735
|
+
const customBefore = editingIndex !== null ? input.customConditions.slice(0, editingIndex) : input.customConditions;
|
|
736
|
+
const customAfter = editingIndex !== null ? input.customConditions.slice(editingIndex + 1) : [];
|
|
737
|
+
|
|
738
|
+
// clang-format off
|
|
739
|
+
render(
|
|
740
|
+
html`
|
|
741
|
+
<div class="settings-card-container-wrapper">
|
|
742
|
+
<div class="settings-card-container throttling-conditions-settings">
|
|
743
|
+
${widget(CPUThrottlingCard)}
|
|
744
|
+
<devtools-card heading=${i18nString(UIStrings.defaultProfiles)}>
|
|
745
|
+
<div>
|
|
746
|
+
${renderHeaderRow()}
|
|
747
|
+
<devtools-list class="conditions-list">
|
|
748
|
+
${input.presets.map(preset => renderConditionsItem(preset))}
|
|
749
|
+
</devtools-list>
|
|
750
|
+
</div>
|
|
751
|
+
</devtools-card>
|
|
752
|
+
<devtools-card heading=${i18nString(UIStrings.customProfiles)}>
|
|
753
|
+
<div>
|
|
754
|
+
${renderHeaderRow()}
|
|
755
|
+
${customBefore.length > 0 ? html`
|
|
756
|
+
<devtools-list
|
|
757
|
+
class="conditions-list"
|
|
758
|
+
editable
|
|
759
|
+
deletable
|
|
760
|
+
@edit=${(e: Lists.List.ItemEditEvent) => input.onBeginEdit(e.detail.index)}
|
|
761
|
+
@delete=${(e: Lists.List.ItemRemoveEvent) => input.onRemoveCustomProfile(e.detail.index)}>
|
|
762
|
+
${customBefore.map(item => renderConditionsItem(item))}
|
|
763
|
+
</devtools-list>
|
|
764
|
+
` : nothing}
|
|
765
|
+
${editingIndex !== null ? renderEditor(input) : nothing}
|
|
766
|
+
${editingIndex !== null && customAfter.length > 0 ? html`
|
|
767
|
+
<devtools-list
|
|
768
|
+
class="conditions-list"
|
|
769
|
+
editable
|
|
770
|
+
deletable
|
|
771
|
+
@edit=${(e: Lists.List.ItemEditEvent) => input.onBeginEdit(editingIndex + 1 + e.detail.index)}
|
|
772
|
+
@delete=${(e: Lists.List.ItemRemoveEvent) => input.onRemoveCustomProfile(editingIndex + 1 + e.detail.index)}>
|
|
773
|
+
${customAfter.map(item => renderConditionsItem(item))}
|
|
774
|
+
</devtools-list>
|
|
775
|
+
` : nothing}
|
|
776
|
+
<devtools-button
|
|
777
|
+
class="add-conditions-button"
|
|
778
|
+
.variant=${Buttons.Button.Variant.OUTLINED}
|
|
779
|
+
.iconName=${'plus'}
|
|
780
|
+
.jslogContext=${'network.add-conditions'}
|
|
781
|
+
@click=${input.onAddCustomProfile}>
|
|
782
|
+
${i18nString(UIStrings.addCustomProfile)}
|
|
783
|
+
</devtools-button>
|
|
784
|
+
</div>
|
|
785
|
+
</devtools-card>
|
|
786
|
+
</div>
|
|
787
|
+
</div>
|
|
788
|
+
`,
|
|
789
|
+
target, {container: {attributes: {jslog: `${VisualLogging.pane('throttling-conditions')}`}}});
|
|
790
|
+
// clang-format on
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
const EMPTY_EDITOR_VALUES: EditorValues = {
|
|
794
|
+
title: '',
|
|
795
|
+
download: '',
|
|
796
|
+
upload: '',
|
|
797
|
+
latency: '',
|
|
798
|
+
packetLoss: '',
|
|
799
|
+
packetQueueLength: '',
|
|
800
|
+
packetReordering: false,
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
export class ThrottlingSettingsTab extends UI.Widget.VBox {
|
|
473
804
|
private readonly customUserConditions: Common.Settings.Setting<SDK.NetworkManager.Conditions[]>;
|
|
474
|
-
|
|
475
|
-
private cpuThrottlingCard: CPUThrottlingCard;
|
|
805
|
+
readonly #view: View;
|
|
476
806
|
/**
|
|
477
807
|
* We store how many custom conditions the user has defined when we load up
|
|
478
808
|
* DevTools. This is because when the user creates a new one, we need to
|
|
@@ -481,46 +811,20 @@ export class ThrottlingSettingsTab extends UI.Widget.VBox implements
|
|
|
481
811
|
* profile; we always use this counter which is only ever incremented.
|
|
482
812
|
*/
|
|
483
813
|
#customUserConditionsCount: number;
|
|
814
|
+
#editingIndex: number|null = null;
|
|
815
|
+
#editingConditions: SDK.NetworkManager.Conditions|null = null;
|
|
816
|
+
#editingValues: EditorValues = {...EMPTY_EDITOR_VALUES};
|
|
817
|
+
#showValidationErrors = false;
|
|
484
818
|
|
|
485
|
-
constructor(settings: Common.Settings.Settings) {
|
|
819
|
+
constructor(settings: Common.Settings.Settings, view: View = DEFAULT_VIEW) {
|
|
486
820
|
super({
|
|
487
|
-
jslog: `${VisualLogging.pane('throttling-conditions')}`,
|
|
488
821
|
useShadowDom: true,
|
|
489
822
|
});
|
|
823
|
+
this.#view = view;
|
|
490
824
|
this.registerRequiredCSS(throttlingSettingsTabStyles);
|
|
491
825
|
|
|
492
|
-
const settingsContent =
|
|
493
|
-
this.contentElement.createChild('div', 'settings-card-container-wrapper').createChild('div');
|
|
494
|
-
settingsContent.classList.add('settings-card-container', 'throttling-conditions-settings');
|
|
495
|
-
|
|
496
|
-
this.cpuThrottlingCard = new CPUThrottlingCard(settings);
|
|
497
|
-
settingsContent.append(this.cpuThrottlingCard.element);
|
|
498
|
-
|
|
499
|
-
const addButton = new Buttons.Button.Button();
|
|
500
|
-
addButton.classList.add('add-conditions-button');
|
|
501
|
-
addButton.data = {
|
|
502
|
-
variant: Buttons.Button.Variant.OUTLINED,
|
|
503
|
-
iconName: 'plus',
|
|
504
|
-
jslogContext: 'network.add-conditions',
|
|
505
|
-
};
|
|
506
|
-
addButton.textContent = i18nString(UIStrings.addCustomProfile);
|
|
507
|
-
addButton.addEventListener('click', () => this.addButtonClicked());
|
|
508
|
-
|
|
509
|
-
this.presetsList = new UI.ListWidget.ListWidget(this);
|
|
510
|
-
this.presetsList.setHeader(createHeaderRow());
|
|
511
|
-
createProfilesCard(i18nString(UIStrings.defaultProfiles), this.presetsList, settingsContent);
|
|
512
|
-
const presets = ThrottlingPresets.networkPresets;
|
|
513
|
-
for (let i = 0; i < presets.length; ++i) {
|
|
514
|
-
this.presetsList.appendItem(presets[i], false);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
this.customList = new UI.ListWidget.ListWidget(this);
|
|
518
|
-
this.customList.setHeader(createHeaderRow());
|
|
519
|
-
const customContainer = createProfilesCard(i18nString(UIStrings.customProfiles), this.customList, settingsContent);
|
|
520
|
-
customContainer.appendChild(addButton);
|
|
521
|
-
|
|
522
826
|
this.customUserConditions = SDK.NetworkManager.customUserNetworkConditionsSetting(settings);
|
|
523
|
-
this.customUserConditions.addChangeListener(this
|
|
827
|
+
this.customUserConditions.addChangeListener(this.#conditionsUpdated, this);
|
|
524
828
|
|
|
525
829
|
const customConditions = this.customUserConditions.get();
|
|
526
830
|
// We need to parse out the current max condition key index. If the last
|
|
@@ -539,31 +843,53 @@ export class ThrottlingSettingsTab extends UI.Widget.VBox implements
|
|
|
539
843
|
} else {
|
|
540
844
|
this.#customUserConditionsCount = 0;
|
|
541
845
|
}
|
|
542
|
-
}
|
|
543
846
|
|
|
544
|
-
|
|
545
|
-
super.wasShown();
|
|
546
|
-
this.cpuThrottlingCard.wasShown();
|
|
547
|
-
this.conditionsUpdated();
|
|
847
|
+
this.performUpdate();
|
|
548
848
|
}
|
|
549
849
|
|
|
550
|
-
override
|
|
551
|
-
|
|
552
|
-
this
|
|
850
|
+
override performUpdate(): void {
|
|
851
|
+
const customConditions = this.customUserConditions.get();
|
|
852
|
+
const validationErrors = this.#editingIndex !== null ? this.#validateEditorValues(this.#editingValues) : {};
|
|
853
|
+
|
|
854
|
+
this.#view(
|
|
855
|
+
{
|
|
856
|
+
presets: ThrottlingPresets.networkPresets,
|
|
857
|
+
customConditions,
|
|
858
|
+
editingIndex: this.#editingIndex,
|
|
859
|
+
editingValues: this.#editingValues,
|
|
860
|
+
validationErrors,
|
|
861
|
+
showValidationErrors: this.#showValidationErrors,
|
|
862
|
+
onAddCustomProfile: () => this.#addButtonClicked(),
|
|
863
|
+
onBeginEdit: this.#beginEdit.bind(this),
|
|
864
|
+
onRemoveCustomProfile: this.#removeCustomProfile.bind(this),
|
|
865
|
+
onEditorInput: this.#onEditorInput.bind(this),
|
|
866
|
+
onCommitEdit: this.#commitEdit.bind(this),
|
|
867
|
+
onCancelEdit: this.#cancelEdit.bind(this),
|
|
868
|
+
},
|
|
869
|
+
undefined,
|
|
870
|
+
this.contentElement,
|
|
871
|
+
);
|
|
553
872
|
}
|
|
554
873
|
|
|
555
|
-
|
|
556
|
-
|
|
874
|
+
override wasShown(): void {
|
|
875
|
+
super.wasShown();
|
|
876
|
+
this.#conditionsUpdated();
|
|
877
|
+
this.performUpdate();
|
|
878
|
+
}
|
|
557
879
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
880
|
+
#conditionsUpdated(): void {
|
|
881
|
+
this.#editingIndex = null;
|
|
882
|
+
this.#editingConditions = null;
|
|
883
|
+
this.#editingValues = {...EMPTY_EDITOR_VALUES};
|
|
884
|
+
this.#showValidationErrors = false;
|
|
885
|
+
this.requestUpdate();
|
|
562
886
|
}
|
|
563
887
|
|
|
564
|
-
|
|
888
|
+
#addButtonClicked(): void {
|
|
565
889
|
this.#customUserConditionsCount++;
|
|
566
|
-
this.
|
|
890
|
+
const customConditions = this.customUserConditions.get();
|
|
891
|
+
this.#editingIndex = customConditions.length;
|
|
892
|
+
this.#editingConditions = {
|
|
567
893
|
key: `USER_CUSTOM_SETTING_${this.#customUserConditionsCount}`,
|
|
568
894
|
title: () => '',
|
|
569
895
|
download: -1,
|
|
@@ -571,280 +897,143 @@ export class ThrottlingSettingsTab extends UI.Widget.VBox implements
|
|
|
571
897
|
latency: 0,
|
|
572
898
|
packetLoss: 0,
|
|
573
899
|
packetReordering: false,
|
|
574
|
-
}
|
|
900
|
+
};
|
|
901
|
+
this.#editingValues = {...EMPTY_EDITOR_VALUES};
|
|
902
|
+
this.#showValidationErrors = false;
|
|
903
|
+
this.requestUpdate();
|
|
575
904
|
}
|
|
576
905
|
|
|
577
|
-
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
element.createChild('div', 'conditions-list-separator');
|
|
597
|
-
element.createChild('div', 'conditions-list-text').textContent =
|
|
598
|
-
conditions.packetReordering ? i18nString(UIStrings.on) : i18nString(UIStrings.off);
|
|
599
|
-
|
|
600
|
-
return element;
|
|
906
|
+
#beginEdit(index: number): void {
|
|
907
|
+
const customConditions = this.customUserConditions.get();
|
|
908
|
+
const conditions = customConditions[index];
|
|
909
|
+
if (!conditions) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
this.#editingIndex = index;
|
|
913
|
+
this.#editingConditions = conditions;
|
|
914
|
+
this.#editingValues = {
|
|
915
|
+
title: retrieveOptionsTitle(conditions),
|
|
916
|
+
download: conditions.download <= 0 ? '' : String(conditions.download / (1000 / 8)),
|
|
917
|
+
upload: conditions.upload <= 0 ? '' : String(conditions.upload / (1000 / 8)),
|
|
918
|
+
latency: conditions.latency ? String(conditions.latency) : '',
|
|
919
|
+
packetLoss: conditions.packetLoss ? String(conditions.packetLoss) : '',
|
|
920
|
+
packetQueueLength: conditions.packetQueueLength ? String(conditions.packetQueueLength) : '',
|
|
921
|
+
packetReordering: conditions.packetReordering ?? false,
|
|
922
|
+
};
|
|
923
|
+
this.#showValidationErrors = false;
|
|
924
|
+
this.requestUpdate();
|
|
601
925
|
}
|
|
602
926
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
927
|
+
#onEditorInput<K extends EditorFieldName>(field: K, value: EditorValues[K]): void {
|
|
928
|
+
this.#editingValues = {
|
|
929
|
+
...this.#editingValues,
|
|
930
|
+
[field]: value,
|
|
931
|
+
};
|
|
932
|
+
this.#showValidationErrors = true;
|
|
933
|
+
this.requestUpdate();
|
|
607
934
|
}
|
|
608
935
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
936
|
+
#cancelEdit(): void {
|
|
937
|
+
this.#editingIndex = null;
|
|
938
|
+
this.#editingConditions = null;
|
|
939
|
+
this.#editingValues = {...EMPTY_EDITOR_VALUES};
|
|
940
|
+
this.#showValidationErrors = false;
|
|
941
|
+
this.requestUpdate();
|
|
613
942
|
}
|
|
614
943
|
|
|
615
|
-
commitEdit(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const
|
|
944
|
+
#commitEdit(): void {
|
|
945
|
+
if (this.#editingIndex === null || !this.#editingConditions) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
const validationErrors = this.#validateEditorValues(this.#editingValues);
|
|
949
|
+
if (Object.keys(validationErrors).length > 0) {
|
|
950
|
+
this.#showValidationErrors = true;
|
|
951
|
+
this.requestUpdate();
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
const conditions = this.#editingConditions;
|
|
956
|
+
conditions.title = this.#editingValues.title.trim();
|
|
957
|
+
const download = this.#editingValues.download.trim();
|
|
620
958
|
conditions.download = download ? parseInt(download, 10) * (1000 / 8) : -1;
|
|
621
|
-
const upload =
|
|
959
|
+
const upload = this.#editingValues.upload.trim();
|
|
622
960
|
conditions.upload = upload ? parseInt(upload, 10) * (1000 / 8) : -1;
|
|
623
|
-
const latency =
|
|
961
|
+
const latency = this.#editingValues.latency.trim();
|
|
624
962
|
conditions.latency = latency ? parseInt(latency, 10) : 0;
|
|
625
|
-
const packetLoss =
|
|
963
|
+
const packetLoss = this.#editingValues.packetLoss.trim();
|
|
626
964
|
conditions.packetLoss = packetLoss ? parseFloat(packetLoss) : 0;
|
|
627
|
-
const packetQueueLength =
|
|
965
|
+
const packetQueueLength = this.#editingValues.packetQueueLength.trim();
|
|
628
966
|
conditions.packetQueueLength = packetQueueLength ? parseFloat(packetQueueLength) : 0;
|
|
629
|
-
|
|
630
|
-
conditions.packetReordering = packetReordering;
|
|
967
|
+
conditions.packetReordering = this.#editingValues.packetReordering;
|
|
631
968
|
|
|
632
|
-
const list = this.customUserConditions.get();
|
|
633
|
-
if (
|
|
969
|
+
const list = [...this.customUserConditions.get()];
|
|
970
|
+
if (this.#editingIndex === list.length) {
|
|
634
971
|
list.push(conditions);
|
|
635
972
|
}
|
|
636
973
|
|
|
974
|
+
this.#editingIndex = null;
|
|
975
|
+
this.#editingConditions = null;
|
|
976
|
+
this.#editingValues = {...EMPTY_EDITOR_VALUES};
|
|
977
|
+
this.#showValidationErrors = false;
|
|
637
978
|
this.customUserConditions.set(list);
|
|
638
979
|
}
|
|
639
980
|
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
editor.control('upload').value = conditions.upload <= 0 ? '' : String(conditions.upload / (1000 / 8));
|
|
645
|
-
editor.control('latency').value = conditions.latency ? String(conditions.latency) : '';
|
|
646
|
-
editor.control('packetLoss').value = conditions.packetLoss ? String(conditions.packetLoss) : '';
|
|
647
|
-
editor.control('packetQueueLength').value =
|
|
648
|
-
conditions.packetQueueLength ? String(conditions.packetQueueLength) : '';
|
|
649
|
-
(editor.control('packetReordering') as HTMLInputElement).checked = conditions.packetReordering ?? false;
|
|
650
|
-
return editor;
|
|
981
|
+
#removeCustomProfile(index: number): void {
|
|
982
|
+
const list = [...this.customUserConditions.get()];
|
|
983
|
+
list.splice(index, 1);
|
|
984
|
+
this.customUserConditions.set(list);
|
|
651
985
|
}
|
|
652
986
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return this.editor;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// Define the settings configuration
|
|
659
|
-
const settings = [
|
|
660
|
-
{
|
|
661
|
-
name: 'title',
|
|
662
|
-
labelText: i18nString(UIStrings.profileName),
|
|
663
|
-
inputType: 'text',
|
|
664
|
-
placeholder: '',
|
|
665
|
-
validator: titleValidator,
|
|
666
|
-
isOptional: false,
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
name: 'download',
|
|
670
|
-
labelText: i18nString(UIStrings.download),
|
|
671
|
-
inputType: 'text',
|
|
672
|
-
placeholder: i18n.i18n.lockedString('kbit/s'),
|
|
673
|
-
validator: throughputValidator,
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
name: 'upload',
|
|
677
|
-
labelText: i18nString(UIStrings.upload),
|
|
678
|
-
inputType: 'text',
|
|
679
|
-
placeholder: i18n.i18n.lockedString('kbit/s'),
|
|
680
|
-
validator: throughputValidator,
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
name: 'latency',
|
|
684
|
-
labelText: i18nString(UIStrings.latency),
|
|
685
|
-
inputType: 'text',
|
|
686
|
-
placeholder: i18n.i18n.lockedString('ms'),
|
|
687
|
-
validator: latencyValidator,
|
|
688
|
-
},
|
|
689
|
-
{
|
|
690
|
-
name: 'packetLoss',
|
|
691
|
-
labelText: i18nString(UIStrings.packetLoss),
|
|
692
|
-
inputType: 'text',
|
|
693
|
-
placeholder: i18n.i18n.lockedString('percent'),
|
|
694
|
-
validator: packetLossValidator,
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
name: 'packetQueueLength',
|
|
698
|
-
labelText: i18nString(UIStrings.packetQueueLength),
|
|
699
|
-
inputType: 'text',
|
|
700
|
-
placeholder: i18nString(UIStrings.packet),
|
|
701
|
-
validator: packetQueueLengthValidator,
|
|
702
|
-
},
|
|
703
|
-
{
|
|
704
|
-
name: 'packetReordering',
|
|
705
|
-
labelText: i18nString(UIStrings.packetReordering),
|
|
706
|
-
inputType: 'checkbox',
|
|
707
|
-
placeholder: '',
|
|
708
|
-
validator: packetReorderingValidator,
|
|
709
|
-
isOptional: false,
|
|
710
|
-
},
|
|
711
|
-
];
|
|
712
|
-
|
|
713
|
-
const editor = new UI.ListWidget.Editor<SDK.NetworkManager.Conditions>();
|
|
714
|
-
this.editor = editor;
|
|
715
|
-
const content = editor.contentElement();
|
|
716
|
-
|
|
717
|
-
const settingsContainer = content.createChild('div', 'settings-container');
|
|
718
|
-
|
|
719
|
-
const createSettingField = (
|
|
720
|
-
name: string,
|
|
721
|
-
labelText: Common.UIString.LocalizedString,
|
|
722
|
-
inputType: string,
|
|
723
|
-
placeholder: Common.UIString.LocalizedString|string,
|
|
724
|
-
validator: (item: SDK.NetworkManager.Conditions, index: number, input: UI.ListWidget.EditorControl) =>
|
|
725
|
-
UI.ListWidget.ValidatorResult,
|
|
726
|
-
isOptional = true,
|
|
727
|
-
): void => {
|
|
728
|
-
const settingElement = settingsContainer.createChild('div', 'setting');
|
|
729
|
-
// Create title element
|
|
730
|
-
const titleContainer = settingElement.createChild('div');
|
|
731
|
-
titleContainer.textContent = labelText;
|
|
732
|
-
// Create input element
|
|
733
|
-
const inputElement = settingElement.createChild('div');
|
|
734
|
-
const input = editor.createInput(name, inputType, placeholder, validator);
|
|
735
|
-
input.classList.add('input');
|
|
736
|
-
UI.ARIAUtils.setLabel(input, labelText);
|
|
737
|
-
inputElement.appendChild(input);
|
|
738
|
-
|
|
739
|
-
const optionalTextElement = inputElement.createChild('div');
|
|
740
|
-
const optionalStr = i18nString(UIStrings.optional);
|
|
741
|
-
optionalTextElement.textContent = optionalStr;
|
|
742
|
-
UI.ARIAUtils.setDescription(input, optionalStr);
|
|
743
|
-
if (!isOptional) {
|
|
744
|
-
optionalTextElement.style.visibility = 'hidden';
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
|
|
748
|
-
// Iterate over settings and create components
|
|
749
|
-
settings.forEach(setting => {
|
|
750
|
-
createSettingField(
|
|
751
|
-
setting.name, setting.labelText, setting.inputType, setting.placeholder, setting.validator,
|
|
752
|
-
setting.isOptional);
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
return editor;
|
|
987
|
+
#validateEditorValues(values: EditorValues): Partial<Record<EditorFieldName, Common.UIString.LocalizedString>> {
|
|
988
|
+
const errors: Partial<Record<EditorFieldName, Common.UIString.LocalizedString>> = {};
|
|
756
989
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
const valid = value.length > 0 && value.length <= maxLength;
|
|
762
|
-
if (!valid) {
|
|
763
|
-
const errorMessage = i18nString(UIStrings.profileNameCharactersLengthMust, {PH1: maxLength});
|
|
764
|
-
return {valid, errorMessage};
|
|
765
|
-
}
|
|
766
|
-
return {
|
|
767
|
-
valid,
|
|
768
|
-
};
|
|
990
|
+
const maxLength = 49;
|
|
991
|
+
const title = values.title.trim();
|
|
992
|
+
if (title.length === 0 || title.length > maxLength) {
|
|
993
|
+
errors.title = i18nString(UIStrings.profileNameCharactersLengthMust, {PH1: maxLength});
|
|
769
994
|
}
|
|
770
995
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const throughput = input.getAttribute('aria-label');
|
|
779
|
-
const valid = !Number.isNaN(parsedValue) && parsedValue >= minThroughput && parsedValue <= maxThroughput;
|
|
780
|
-
if (!valid) {
|
|
781
|
-
const errorMessage = i18nString(
|
|
782
|
-
UIStrings.sMustBeANumberBetweenSkbsToSkbs,
|
|
783
|
-
{PH1: String(throughput), PH2: minThroughput, PH3: maxThroughput});
|
|
784
|
-
return {valid, errorMessage};
|
|
785
|
-
}
|
|
786
|
-
return {
|
|
787
|
-
valid,
|
|
788
|
-
};
|
|
996
|
+
const minThroughput = 0;
|
|
997
|
+
const maxThroughput = 10000000;
|
|
998
|
+
const download = values.download.trim();
|
|
999
|
+
const parsedDownload = Number(download);
|
|
1000
|
+
if (Number.isNaN(parsedDownload) || parsedDownload < minThroughput || parsedDownload > maxThroughput) {
|
|
1001
|
+
errors.download = i18nString(UIStrings.sMustBeANumberBetweenSkbsToSkbs,
|
|
1002
|
+
{PH1: i18nString(UIStrings.download), PH2: minThroughput, PH3: maxThroughput});
|
|
789
1003
|
}
|
|
790
1004
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
const parsedValue = Number(value);
|
|
797
|
-
const valid = Number.isInteger(parsedValue) && parsedValue >= minLatency && parsedValue <= maxLatency;
|
|
798
|
-
if (!valid) {
|
|
799
|
-
const errorMessage = i18nString(UIStrings.latencyMustBeAnIntegerBetweenSms, {PH1: minLatency, PH2: maxLatency});
|
|
800
|
-
return {valid, errorMessage};
|
|
801
|
-
}
|
|
802
|
-
return {
|
|
803
|
-
valid,
|
|
804
|
-
};
|
|
1005
|
+
const upload = values.upload.trim();
|
|
1006
|
+
const parsedUpload = Number(upload);
|
|
1007
|
+
if (Number.isNaN(parsedUpload) || parsedUpload < minThroughput || parsedUpload > maxThroughput) {
|
|
1008
|
+
errors.upload = i18nString(UIStrings.sMustBeANumberBetweenSkbsToSkbs,
|
|
1009
|
+
{PH1: i18nString(UIStrings.upload), PH2: minThroughput, PH3: maxThroughput});
|
|
805
1010
|
}
|
|
806
1011
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const parsedValue = Number(value);
|
|
814
|
-
const valid = parsedValue >= minPacketLoss && parsedValue <= maxPacketLoss;
|
|
815
|
-
if (!valid) {
|
|
816
|
-
const errorMessage =
|
|
817
|
-
i18nString(UIStrings.packetLossMustBeAnIntegerBetweenSpct, {PH1: minPacketLoss, PH2: maxPacketLoss});
|
|
818
|
-
return {valid, errorMessage};
|
|
819
|
-
}
|
|
820
|
-
return {
|
|
821
|
-
valid,
|
|
822
|
-
};
|
|
1012
|
+
const minLatency = 0;
|
|
1013
|
+
const maxLatency = 1000000;
|
|
1014
|
+
const latency = values.latency.trim();
|
|
1015
|
+
const parsedLatency = Number(latency);
|
|
1016
|
+
if (!Number.isInteger(parsedLatency) || parsedLatency < minLatency || parsedLatency > maxLatency) {
|
|
1017
|
+
errors.latency = i18nString(UIStrings.latencyMustBeAnIntegerBetweenSms, {PH1: minLatency, PH2: maxLatency});
|
|
823
1018
|
}
|
|
824
1019
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if (!valid) {
|
|
833
|
-
const errorMessage = i18nString(UIStrings.packetQueueLengthMustBeAnIntegerGreaterOrEqualToZero);
|
|
834
|
-
return {valid, errorMessage};
|
|
835
|
-
}
|
|
836
|
-
return {
|
|
837
|
-
valid,
|
|
838
|
-
};
|
|
1020
|
+
const minPacketLoss = 0;
|
|
1021
|
+
const maxPacketLoss = 100;
|
|
1022
|
+
const packetLoss = values.packetLoss.trim();
|
|
1023
|
+
const parsedPacketLoss = Number(packetLoss);
|
|
1024
|
+
if (Number.isNaN(parsedPacketLoss) || parsedPacketLoss < minPacketLoss || parsedPacketLoss > maxPacketLoss) {
|
|
1025
|
+
errors.packetLoss =
|
|
1026
|
+
i18nString(UIStrings.packetLossMustBeAnIntegerBetweenSpct, {PH1: minPacketLoss, PH2: maxPacketLoss});
|
|
839
1027
|
}
|
|
840
1028
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
};
|
|
1029
|
+
const minPacketQueueLength = 0;
|
|
1030
|
+
const packetQueueLength = values.packetQueueLength.trim();
|
|
1031
|
+
const parsedPacketQueueLength = Number(packetQueueLength);
|
|
1032
|
+
if (Number.isNaN(parsedPacketQueueLength) || parsedPacketQueueLength < minPacketQueueLength) {
|
|
1033
|
+
errors.packetQueueLength = i18nString(UIStrings.packetQueueLengthMustBeAnIntegerGreaterOrEqualToZero);
|
|
847
1034
|
}
|
|
1035
|
+
|
|
1036
|
+
return errors;
|
|
848
1037
|
}
|
|
849
1038
|
}
|
|
850
1039
|
|
|
@@ -871,41 +1060,3 @@ function percentText(percent: number): string {
|
|
|
871
1060
|
}
|
|
872
1061
|
return String(percent) + '%';
|
|
873
1062
|
}
|
|
874
|
-
|
|
875
|
-
function createProfilesCard(heading: string, list: UI.ListWidget.ListWidget<SDK.NetworkManager.Conditions>,
|
|
876
|
-
parent: Element): HTMLElement {
|
|
877
|
-
const card = parent.createChild('devtools-card');
|
|
878
|
-
card.heading = heading;
|
|
879
|
-
const container = card.createChild('div');
|
|
880
|
-
list.element.classList.add('conditions-list');
|
|
881
|
-
list.registerRequiredCSS(throttlingSettingsTabStyles);
|
|
882
|
-
list.show(container);
|
|
883
|
-
return container;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
function appendHeaderColumn(element: Element, text: string): void {
|
|
887
|
-
element.createChild('div', 'conditions-list-separator');
|
|
888
|
-
const column = element.createChild('div', 'conditions-list-text');
|
|
889
|
-
column.textContent = text;
|
|
890
|
-
UI.Tooltip.Tooltip.install(column, text);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
function createHeaderRow(): Element {
|
|
894
|
-
const element = document.createElement('div');
|
|
895
|
-
element.classList.add('conditions-list-item', 'conditions-list-header');
|
|
896
|
-
|
|
897
|
-
const title = element.createChild('div', 'conditions-list-text conditions-list-title');
|
|
898
|
-
const titleText = title.createChild('div', 'conditions-list-title-text');
|
|
899
|
-
const profileName = i18nString(UIStrings.profileName);
|
|
900
|
-
titleText.textContent = profileName;
|
|
901
|
-
UI.Tooltip.Tooltip.install(title, profileName);
|
|
902
|
-
|
|
903
|
-
appendHeaderColumn(element, i18nString(UIStrings.download));
|
|
904
|
-
appendHeaderColumn(element, i18nString(UIStrings.upload));
|
|
905
|
-
appendHeaderColumn(element, i18nString(UIStrings.latency));
|
|
906
|
-
appendHeaderColumn(element, i18nString(UIStrings.packetLoss));
|
|
907
|
-
appendHeaderColumn(element, i18nString(UIStrings.packetQueueLength));
|
|
908
|
-
appendHeaderColumn(element, i18nString(UIStrings.packetReordering));
|
|
909
|
-
|
|
910
|
-
return element;
|
|
911
|
-
}
|