chrome-devtools-frontend 1.0.1736236 → 1.0.1738725
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/ui-and-widgets/ui-css-scoping-and-flex-layout.md +1 -1
- package/.agents/skills/version-control/SKILL.md +63 -11
- package/docs/devtools-protocol.md +3 -1
- package/eslint.config.mjs +0 -6
- package/front_end/core/host/AidaClient.ts +14 -36
- package/front_end/core/host/AidaGcaTranslation.ts +8 -5
- package/front_end/core/root/Runtime.ts +0 -5
- package/front_end/design_system_tokens.css +1 -0
- package/front_end/entrypoints/main/GlobalAiButton.ts +2 -9
- package/front_end/entrypoints/main/MainImpl.ts +0 -4
- package/front_end/generated/SupportedCSSProperties.ts +8 -23
- package/front_end/models/ai-utils/AiUtils.ts +1 -5
- package/front_end/models/ai_assistance/agents/AiAgent.ts +2 -18
- package/front_end/models/ai_assistance/contexts/FileContext.ts +1 -2
- package/front_end/models/ai_assistance/tools/ListSources.ts +3 -1
- package/front_end/models/ai_code_generation/AiCodeGeneration.ts +0 -6
- package/front_end/models/javascript_metadata/NativeFunctions.ts +9 -5
- package/front_end/models/trace/EventsSerializer.ts +0 -8
- package/front_end/models/workspace/UISourceCode.ts +30 -8
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -7
- package/front_end/panels/ai_assistance/ai_assistance-meta.ts +15 -34
- package/front_end/panels/ai_assistance/components/ChatView.ts +2 -16
- package/front_end/panels/ai_assistance/components/chatView.css +0 -32
- package/front_end/panels/ai_assistance/components/walkthroughView.css +1 -1
- package/front_end/panels/animation/AnimationTimeline.ts +1 -1
- package/front_end/panels/animation/animationTimeline.css +5 -3
- package/front_end/panels/application/PrivateVerificationTokensView.ts +114 -26
- package/front_end/panels/application/ResourcesPanel.ts +1 -0
- package/front_end/panels/application/backgroundServiceView.css +2 -2
- package/front_end/panels/application/components/permissionsPolicySection.css +0 -4
- package/front_end/panels/application/frameDetailsReportView.css +0 -7
- package/front_end/panels/application/indexedDBViews.css +3 -3
- package/front_end/panels/application/privateVerificationTokensView.css +6 -0
- package/front_end/panels/application/serviceWorkerUpdateCycleView.css +1 -1
- package/front_end/panels/application/serviceWorkersView.css +2 -2
- package/front_end/panels/comments/CommentsPane.ts +1 -1
- package/front_end/panels/comments/commentsPane.css +1 -1
- package/front_end/panels/common/common.ts +0 -1
- package/front_end/panels/console/ConsoleView.ts +11 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +5 -1
- package/front_end/panels/console/consolePinPane.css +1 -1
- package/front_end/panels/console/consoleView.css +5 -4
- package/front_end/panels/elements/DOMTreeWidget.ts +47 -5
- package/front_end/panels/elements/layoutPane.css +0 -1
- package/front_end/panels/emulation/InspectedPagePlaceholder.ts +1 -0
- package/front_end/panels/emulation/deviceModeView.css +0 -1
- package/front_end/panels/issues/issuesTree.css +2 -2
- package/front_end/panels/layer_viewer/LayerDetailsView.ts +34 -17
- package/front_end/panels/layer_viewer/LayerTreeOutline.ts +39 -17
- package/front_end/panels/layer_viewer/Layers3DView.ts +34 -13
- package/front_end/panels/layer_viewer/layerDetailsView.css +1 -1
- package/front_end/panels/layer_viewer/layers3DView.css +0 -4
- package/front_end/panels/media/playerListView.css +0 -18
- package/front_end/panels/media/playerPropertiesView.css +1 -1
- package/front_end/panels/network/NetworkWaterfallColumn.ts +22 -10
- package/front_end/panels/network/RequestPreviewView.ts +182 -63
- package/front_end/panels/network/SignedExchangeInfoView.ts +242 -158
- package/front_end/panels/network/networkConfigView.css +1 -1
- package/front_end/panels/network/networkLogView.css +2 -1
- package/front_end/panels/network/networkPanel.css +0 -5
- package/front_end/panels/network/networkTimingTable.css +1 -1
- package/front_end/panels/network/signedExchangeInfoView.css +12 -8
- package/front_end/panels/performance_monitor/performanceMonitor.css +2 -2
- package/front_end/panels/profiler/IsolateSelector.ts +31 -10
- package/front_end/panels/profiler/profilesPanel.css +0 -8
- package/front_end/panels/protocol_monitor/JSONEditor.css +1 -1
- package/front_end/panels/screencast/screencastView.css +2 -2
- package/front_end/panels/security/SecurityPanel.ts +474 -418
- package/front_end/panels/security/SecurityPanelSidebar.ts +68 -48
- package/front_end/panels/security/lockIcon.css +52 -50
- package/front_end/panels/security/mainView.css +149 -145
- package/front_end/panels/security/originView.css +117 -115
- package/front_end/panels/sensors/LocationsSettingsTab.ts +2 -50
- package/front_end/panels/sensors/locationsSettingsTab.css +1 -21
- package/front_end/panels/settings/AISettingsTab.ts +1 -2
- package/front_end/panels/settings/SettingsScreen.ts +1 -1
- package/front_end/panels/sources/CallStackSidebarPane.ts +31 -6
- package/front_end/panels/sources/NavigatorView.ts +105 -31
- package/front_end/panels/sources/breakpointsView.css +2 -1
- package/front_end/panels/sources/scopeChainSidebarPane.css +1 -1
- package/front_end/panels/timeline/ThirdPartyTreeView.ts +1 -0
- package/front_end/panels/timeline/TimelineLayersView.ts +108 -46
- package/front_end/panels/timeline/TimelinePanel.ts +4 -2
- package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +1 -1
- package/front_end/panels/timeline/components/networkRequestDetails.css +1 -1
- package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +0 -7
- package/front_end/panels/web_audio/webAudio.css +1 -2
- package/front_end/panels/webauthn/WebauthnPane.ts +1 -1
- package/front_end/panels/whats_new/ReleaseNoteText.ts +6 -6
- package/front_end/panels/whats_new/resources/WNDT.md +6 -6
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/comments/CommentAnchorResolver.ts +45 -4
- package/front_end/ui/comments/CommentOverlayManager.ts +45 -12
- package/front_end/ui/components/buttons/FloatingButton.ts +2 -6
- package/front_end/ui/components/buttons/button.css +2 -2
- package/front_end/ui/components/buttons/floatingButton.css +0 -44
- package/front_end/ui/components/icon_button/iconButton.css +1 -1
- package/front_end/ui/components/markdown_view/markdownView.css +1 -1
- package/front_end/ui/legacy/ContextMenu.ts +7 -5
- package/front_end/ui/legacy/InspectorDrawerView.ts +1 -0
- package/front_end/ui/legacy/InspectorView.ts +5 -1
- package/front_end/ui/legacy/PopoverHelper.ts +1 -0
- package/front_end/ui/legacy/RootView.ts +9 -3
- package/front_end/ui/legacy/SplitWidget.ts +1 -0
- package/front_end/ui/legacy/Treeoutline.ts +9 -0
- package/front_end/ui/legacy/UIUtils.ts +1 -1
- package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +130 -137
- package/front_end/ui/legacy/components/inline_editor/CSSShadowEditor.ts +1 -1
- package/front_end/ui/legacy/components/inline_editor/SwatchPopoverHelper.ts +1 -0
- package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +1 -1
- package/front_end/ui/legacy/components/inline_editor/cssAngleEditor.css +3 -1
- package/front_end/ui/legacy/components/inline_editor/cssShadowEditor.css +7 -6
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +2 -0
- package/front_end/ui/legacy/components/perf_ui/pieChart.css +2 -2
- package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +1 -10
- package/front_end/ui/legacy/filter.css +1 -1
- package/front_end/ui/legacy/infobar.css +1 -1
- package/front_end/ui/legacy/inspectorCommon.css +2 -2
- package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +3 -3
- package/front_end/ui/legacy/listWidget.css +2 -7
- package/front_end/ui/legacy/softDropDownButton.css +1 -1
- package/front_end/ui/legacy/tabbedPane.css +2 -1
- package/front_end/ui/legacy/treeoutline.css +3 -2
- package/front_end/ui/visual_logging/KnownContextValues.ts +133 -0
- package/front_end/ui/visual_logging/LoggingEvents.ts +1 -1
- package/package.json +1 -1
- package/front_end/Images/geminiInDevTools.png +0 -0
- package/front_end/Images/geminiInDevTools_2x.png +0 -0
- package/front_end/generated/InspectorBackendCommands.ts +0 -1690
- package/front_end/generated/protocol-mapping.d.ts +0 -5986
- package/front_end/generated/protocol-proxy-api.d.ts +0 -5452
- package/front_end/generated/protocol.ts +0 -23364
- package/front_end/panels/common/GeminiRebrandPromoDialog.ts +0 -193
- package/front_end/panels/common/geminiRebrandPromoDialog.css +0 -47
|
@@ -17,11 +17,17 @@ import {RequestTimeRangeNameToColor} from './NetworkOverview.js';
|
|
|
17
17
|
import networkWaterfallColumnStyles from './networkWaterfallColumn.css.js';
|
|
18
18
|
import {RequestTimingView} from './RequestTimingView.js';
|
|
19
19
|
|
|
20
|
-
const {ref} = Directives;
|
|
20
|
+
const {ref, styleMap} = Directives;
|
|
21
21
|
|
|
22
22
|
const BAR_SPACING = 1;
|
|
23
23
|
|
|
24
24
|
export interface ViewInput {
|
|
25
|
+
/** Canvas width in CSS pixels. */
|
|
26
|
+
width: number;
|
|
27
|
+
/** Canvas height in CSS pixels. */
|
|
28
|
+
height: number;
|
|
29
|
+
/** Ratio between the canvas backing store size and its CSS size. */
|
|
30
|
+
pixelRatio: number;
|
|
25
31
|
onMouseMove: (offsetY: number, shiftKey: boolean) => void;
|
|
26
32
|
onMouseLeave: () => void;
|
|
27
33
|
onClick: (offsetY: number) => boolean;
|
|
@@ -34,11 +40,17 @@ export interface ViewOutput {
|
|
|
34
40
|
export type View = (input: ViewInput, output: ViewOutput, target: HTMLElement) => void;
|
|
35
41
|
|
|
36
42
|
export const DEFAULT_VIEW: View = (input, output, target) => {
|
|
43
|
+
const width = Math.max(0, input.width);
|
|
44
|
+
const height = Math.max(0, input.height);
|
|
45
|
+
const pixelRatio = Math.max(0, input.pixelRatio);
|
|
37
46
|
// clang-format off
|
|
38
47
|
render(html`
|
|
39
48
|
<style>${networkWaterfallColumnStyles}</style>
|
|
40
49
|
<canvas
|
|
41
50
|
tabindex="-1"
|
|
51
|
+
width=${Math.round(width * pixelRatio)}
|
|
52
|
+
height=${Math.round(height * pixelRatio)}
|
|
53
|
+
style=${styleMap({width: `${width}px`, height: `${height}px`})}
|
|
42
54
|
@mousemove=${(event: MouseEvent) => input.onMouseMove(event.offsetY, event.shiftKey)}
|
|
43
55
|
@mouseleave=${input.onMouseLeave}
|
|
44
56
|
@click=${(event: MouseEvent) => {
|
|
@@ -137,6 +149,9 @@ export class NetworkWaterfallColumn extends UI.Widget.VBox {
|
|
|
137
149
|
|
|
138
150
|
override performUpdate(): void {
|
|
139
151
|
this.#view({
|
|
152
|
+
width: this.offsetWidth,
|
|
153
|
+
height: this.offsetHeight,
|
|
154
|
+
pixelRatio: window.devicePixelRatio,
|
|
140
155
|
onMouseMove: (offsetY, shiftKey) => this.setHoveredNode(this.getNodeFromPoint(offsetY), shiftKey),
|
|
141
156
|
onMouseLeave: () => this.setHoveredNode(null, false),
|
|
142
157
|
onClick: offsetY => this.setSelectedNode(this.getNodeFromPoint(offsetY)),
|
|
@@ -403,20 +418,14 @@ export class NetworkWaterfallColumn extends UI.Widget.VBox {
|
|
|
403
418
|
|
|
404
419
|
this.startTime = this.calculator.minimumBoundary();
|
|
405
420
|
this.endTime = this.calculator.maximumBoundary();
|
|
406
|
-
|
|
421
|
+
// Render synchronously, because the canvas must have its new size before
|
|
422
|
+
// we draw on it.
|
|
423
|
+
this.performUpdate();
|
|
407
424
|
this.resetPaths();
|
|
408
425
|
this.textLayers = [];
|
|
409
426
|
this.draw();
|
|
410
427
|
}
|
|
411
428
|
|
|
412
|
-
private resetCanvas(): void {
|
|
413
|
-
const ratio = window.devicePixelRatio;
|
|
414
|
-
this.canvas.width = this.offsetWidth * ratio;
|
|
415
|
-
this.canvas.height = this.offsetHeight * ratio;
|
|
416
|
-
this.canvas.style.width = this.offsetWidth + 'px';
|
|
417
|
-
this.canvas.style.height = this.offsetHeight + 'px';
|
|
418
|
-
}
|
|
419
|
-
|
|
420
429
|
override onResize(): void {
|
|
421
430
|
super.onResize();
|
|
422
431
|
this.calculateCanvasSize();
|
|
@@ -449,6 +458,9 @@ export class NetworkWaterfallColumn extends UI.Widget.VBox {
|
|
|
449
458
|
if (!context) {
|
|
450
459
|
return;
|
|
451
460
|
}
|
|
461
|
+
// The view only resizes the canvas (which implicitly clears it) when its
|
|
462
|
+
// dimensions change, so explicitly clear the bitmap and the drawing state.
|
|
463
|
+
context.reset();
|
|
452
464
|
context.save();
|
|
453
465
|
context.scale(window.devicePixelRatio, window.devicePixelRatio);
|
|
454
466
|
context.translate(0, this.headerHeight);
|
|
@@ -1,21 +1,24 @@
|
|
|
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
|
-
/* eslint-disable @devtools/no-imperative-dom-api */
|
|
5
4
|
|
|
6
5
|
import '../../ui/legacy/legacy.js';
|
|
7
6
|
|
|
7
|
+
import * as Common from '../../core/common/common.js';
|
|
8
8
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
9
9
|
import type * as SDK from '../../core/sdk/sdk.js';
|
|
10
10
|
import * as TextUtils from '../../core/text_utils/text_utils.js';
|
|
11
11
|
import * as SourceFrame from '../../ui/legacy/components/source_frame/source_frame.js';
|
|
12
12
|
import * as UI from '../../ui/legacy/legacy.js';
|
|
13
|
-
import {render} from '../../ui/lit/lit.js';
|
|
13
|
+
import {Directives, html, type LitTemplate, render} from '../../ui/lit/lit.js';
|
|
14
14
|
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
|
|
15
15
|
|
|
16
16
|
import {RequestHTMLView} from './RequestHTMLView.js';
|
|
17
17
|
import {SignedExchangeInfoView} from './SignedExchangeInfoView.js';
|
|
18
18
|
|
|
19
|
+
const {widget} = UI.Widget;
|
|
20
|
+
const {repeat} = Directives;
|
|
21
|
+
|
|
19
22
|
const UIStrings = {
|
|
20
23
|
/**
|
|
21
24
|
* @description Text in Request Preview View of the Network panel
|
|
@@ -25,17 +28,102 @@ const UIStrings = {
|
|
|
25
28
|
* @description Text in Request Preview View of the Network panel
|
|
26
29
|
*/
|
|
27
30
|
previewNotAvailable: 'Preview not available',
|
|
31
|
+
/**
|
|
32
|
+
* @description Text shown in the empty widget when there is no content to
|
|
33
|
+
* preview in the Request Preview View of the Network panel.
|
|
34
|
+
*/
|
|
35
|
+
nothingToPreview: 'Nothing to preview',
|
|
28
36
|
} as const;
|
|
29
37
|
const str_ = i18n.i18n.registerUIStrings('panels/network/RequestPreviewView.ts', UIStrings);
|
|
30
38
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
39
|
+
|
|
40
|
+
export interface ViewInput {
|
|
41
|
+
request: SDK.NetworkRequest.NetworkRequest;
|
|
42
|
+
resourceType: Common.ResourceType.ResourceType;
|
|
43
|
+
mimeType: string;
|
|
44
|
+
highlighterType: string;
|
|
45
|
+
hasSignedExchange: boolean;
|
|
46
|
+
error: string|null;
|
|
47
|
+
htmlDataURL: string|null;
|
|
48
|
+
parsedJSON: SourceFrame.JSONView.ParsedJSON|null;
|
|
49
|
+
parsedXML: Document|null;
|
|
50
|
+
isTextContent: boolean;
|
|
51
|
+
hasTextContent: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
|
|
55
|
+
|
|
56
|
+
export const DEFAULT_VIEW: View = (input, _output, target) => {
|
|
57
|
+
// clang-format off
|
|
58
|
+
let previewTemplate: LitTemplate;
|
|
59
|
+
if (input.hasSignedExchange) {
|
|
60
|
+
previewTemplate = html`${widget(SignedExchangeInfoView, {request: input.request})}`;
|
|
61
|
+
} else if (input.error !== null) {
|
|
62
|
+
previewTemplate = html`${widget(UI.EmptyWidget.EmptyWidget, {
|
|
63
|
+
header: i18nString(UIStrings.failedToLoadResponseData),
|
|
64
|
+
text: input.error,
|
|
65
|
+
})}`;
|
|
66
|
+
} else if (input.parsedJSON) {
|
|
67
|
+
previewTemplate = html`${widget(SourceFrame.JSONView.SearchableJsonView, {parsedJSON: input.parsedJSON})}`;
|
|
68
|
+
} else if (input.htmlDataURL) {
|
|
69
|
+
previewTemplate = html`${widget(RequestHTMLView, {dataURL: input.htmlDataURL})}`;
|
|
70
|
+
} else if (input.resourceType === Common.ResourceType.resourceTypes.Image) {
|
|
71
|
+
previewTemplate = html`${widget(
|
|
72
|
+
(element: HTMLElement) => new SourceFrame.ImageView.ImageView(input.mimeType, input.request, element),
|
|
73
|
+
{showToolbar: true},
|
|
74
|
+
)}`;
|
|
75
|
+
} else if (input.resourceType === Common.ResourceType.resourceTypes.Font) {
|
|
76
|
+
previewTemplate = html`${widget(
|
|
77
|
+
(element: HTMLElement) => new SourceFrame.FontView.FontView(input.mimeType, input.request, element),
|
|
78
|
+
{showToolbar: true},
|
|
79
|
+
)}`;
|
|
80
|
+
} else if (!input.isTextContent) {
|
|
81
|
+
previewTemplate = html`${widget(UI.EmptyWidget.EmptyWidget, {
|
|
82
|
+
header: i18nString(UIStrings.previewNotAvailable),
|
|
83
|
+
text: '',
|
|
84
|
+
})}`;
|
|
85
|
+
} else if (!input.hasTextContent) {
|
|
86
|
+
previewTemplate = html`${widget(UI.EmptyWidget.EmptyWidget, {
|
|
87
|
+
header: i18nString(UIStrings.nothingToPreview),
|
|
88
|
+
text: '',
|
|
89
|
+
})}`;
|
|
90
|
+
} else if (input.parsedXML) {
|
|
91
|
+
const parsedXML = input.parsedXML;
|
|
92
|
+
previewTemplate = html`${widget(element => SourceFrame.XMLView.XMLView.createSearchableView(parsedXML, element))}`;
|
|
93
|
+
} else {
|
|
94
|
+
previewTemplate = html`${widget(
|
|
95
|
+
element => new SourceFrame.ResourceSourceFrame.SearchableContainer(
|
|
96
|
+
input.request, input.highlighterType, element),
|
|
97
|
+
)}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
render(
|
|
101
|
+
html`${repeat([input.request], request => request, () => previewTemplate)}`,
|
|
102
|
+
target,
|
|
103
|
+
{
|
|
104
|
+
container: {
|
|
105
|
+
attributes: {
|
|
106
|
+
jslog: `${VisualLogging.pane('preview').track({resize: true})}`,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
// clang-format on
|
|
112
|
+
};
|
|
113
|
+
|
|
31
114
|
export class RequestPreviewView extends UI.Widget.VBox {
|
|
32
115
|
#request!: SDK.NetworkRequest.NetworkRequest;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
116
|
+
readonly #view: View;
|
|
117
|
+
#error: string|null = null;
|
|
118
|
+
#htmlDataURL: string|null = null;
|
|
119
|
+
#parsedJSON: SourceFrame.JSONView.ParsedJSON|null = null;
|
|
120
|
+
#parsedXML: Document|null = null;
|
|
121
|
+
#isTextContent = false;
|
|
122
|
+
#hasTextContent = false;
|
|
123
|
+
|
|
124
|
+
constructor(request?: SDK.NetworkRequest.NetworkRequest|HTMLElement, view: View = DEFAULT_VIEW) {
|
|
125
|
+
super(request instanceof HTMLElement ? request : undefined);
|
|
126
|
+
this.#view = view;
|
|
39
127
|
if (request && !(request instanceof HTMLElement)) {
|
|
40
128
|
this.#request = request;
|
|
41
129
|
}
|
|
@@ -50,80 +138,111 @@ export class RequestPreviewView extends UI.Widget.VBox {
|
|
|
50
138
|
return;
|
|
51
139
|
}
|
|
52
140
|
this.#request = request;
|
|
53
|
-
this
|
|
54
|
-
this.
|
|
55
|
-
this.element.removeChildren();
|
|
56
|
-
if (this.isShowing()) {
|
|
57
|
-
void this.doShowPreview();
|
|
58
|
-
}
|
|
141
|
+
this.#resetState();
|
|
142
|
+
this.requestUpdate();
|
|
59
143
|
}
|
|
60
144
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return view;
|
|
66
|
-
}
|
|
67
|
-
view.show(this.element);
|
|
68
|
-
await view.updateComplete;
|
|
69
|
-
if (!(view instanceof UI.View.SimpleView)) {
|
|
70
|
-
return view;
|
|
71
|
-
}
|
|
72
|
-
const toolbar = this.element.createChild('devtools-toolbar', 'network-item-preview-toolbar');
|
|
73
|
-
void view.toolbarItems().then(items => {
|
|
74
|
-
// eslint-disable-next-line @devtools/no-lit-render-outside-of-view
|
|
75
|
-
render(items, toolbar);
|
|
76
|
-
});
|
|
77
|
-
return view;
|
|
145
|
+
// Used by layout test
|
|
146
|
+
// http/tests/devtools/network/network-choose-preview-view.js
|
|
147
|
+
get contentViewPromise(): Promise<UI.Widget.AnyWidget|null> {
|
|
148
|
+
return this.updateComplete.then(() => this.children().at(-1) ?? null);
|
|
78
149
|
}
|
|
79
150
|
|
|
80
151
|
override wasShown(): void {
|
|
81
152
|
super.wasShown();
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private doShowPreview(): Promise<UI.Widget.AnyWidget> {
|
|
86
|
-
if (!this.contentViewPromise) {
|
|
87
|
-
this.contentViewPromise = this.showPreview();
|
|
88
|
-
}
|
|
89
|
-
return this.contentViewPromise;
|
|
153
|
+
this.requestUpdate();
|
|
90
154
|
}
|
|
91
155
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return new UI.EmptyWidget.EmptyWidget(i18nString(UIStrings.failedToLoadResponseData), contentData.error);
|
|
156
|
+
override async performUpdate(): Promise<void> {
|
|
157
|
+
if (!this.#request) {
|
|
158
|
+
return;
|
|
96
159
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
160
|
+
const request = this.#request;
|
|
161
|
+
await this.#loadPreviewData(request);
|
|
162
|
+
if (this.#request !== request) {
|
|
163
|
+
return;
|
|
101
164
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (jsonView) {
|
|
106
|
-
return jsonView;
|
|
165
|
+
let resourceType = Common.ResourceType.ResourceType.fromMimeType(request.mimeType);
|
|
166
|
+
if (resourceType === Common.ResourceType.resourceTypes.Other) {
|
|
167
|
+
resourceType = request.contentType();
|
|
107
168
|
}
|
|
169
|
+
const highlighterType = request.mimeType.replace(/;.*/, '') || request.contentType().canonicalMimeType();
|
|
170
|
+
this.#view(
|
|
171
|
+
{
|
|
172
|
+
request,
|
|
173
|
+
resourceType,
|
|
174
|
+
mimeType: request.mimeType,
|
|
175
|
+
highlighterType,
|
|
176
|
+
hasSignedExchange: Boolean(request.signedExchangeInfo()),
|
|
177
|
+
error: this.#error,
|
|
178
|
+
htmlDataURL: this.#htmlDataURL,
|
|
179
|
+
parsedJSON: this.#parsedJSON,
|
|
180
|
+
parsedXML: this.#parsedXML,
|
|
181
|
+
isTextContent: this.#isTextContent,
|
|
182
|
+
hasTextContent: this.#hasTextContent,
|
|
183
|
+
},
|
|
184
|
+
undefined,
|
|
185
|
+
this.contentElement,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
108
188
|
|
|
109
|
-
|
|
189
|
+
#resetState(): void {
|
|
190
|
+
this.#error = null;
|
|
191
|
+
this.#htmlDataURL = null;
|
|
192
|
+
this.#parsedJSON = null;
|
|
193
|
+
this.#parsedXML = null;
|
|
194
|
+
this.#isTextContent = false;
|
|
195
|
+
this.#hasTextContent = false;
|
|
110
196
|
}
|
|
111
197
|
|
|
112
|
-
async
|
|
113
|
-
|
|
114
|
-
|
|
198
|
+
async #loadPreviewData(request: SDK.NetworkRequest.NetworkRequest): Promise<void> {
|
|
199
|
+
this.#resetState();
|
|
200
|
+
|
|
201
|
+
if (request.signedExchangeInfo()) {
|
|
202
|
+
return;
|
|
115
203
|
}
|
|
116
204
|
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
return
|
|
205
|
+
const contentData = await request.requestContentData();
|
|
206
|
+
if (this.#request !== request) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (TextUtils.ContentData.ContentData.isError(contentData)) {
|
|
210
|
+
this.#error = contentData.error;
|
|
211
|
+
return;
|
|
120
212
|
}
|
|
121
213
|
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
|
|
214
|
+
const allowlist = new Set<string>(['text/html', 'text/plain', 'application/xhtml+xml']);
|
|
215
|
+
if (allowlist.has(request.mimeType)) {
|
|
216
|
+
// http://crbug.com/767393 - DevTools should recognize JSON regardless of
|
|
217
|
+
// the content type
|
|
218
|
+
const parsedJSON = await SourceFrame.JSONView.JSONView.parseJSON(contentData.text);
|
|
219
|
+
if (this.#request !== request) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (parsedJSON && typeof parsedJSON.data === 'object') {
|
|
223
|
+
this.#parsedJSON = parsedJSON;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const dataURL = contentData.asDataUrl();
|
|
227
|
+
if (dataURL) {
|
|
228
|
+
this.#htmlDataURL = dataURL;
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
125
231
|
}
|
|
126
232
|
|
|
127
|
-
|
|
233
|
+
this.#isTextContent = contentData.isTextContent;
|
|
234
|
+
this.#hasTextContent = Boolean(contentData.isTextContent && contentData.text);
|
|
235
|
+
if (this.#hasTextContent) {
|
|
236
|
+
this.#parsedXML = SourceFrame.XMLView.XMLView.parseXML(contentData.text, contentData.mimeType);
|
|
237
|
+
if (!this.#parsedXML) {
|
|
238
|
+
const parsedJSON = await SourceFrame.JSONView.JSONView.parseJSON(contentData.text);
|
|
239
|
+
if (this.#request !== request) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (parsedJSON && typeof parsedJSON.data === 'object') {
|
|
243
|
+
this.#parsedJSON = parsedJSON;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
128
247
|
}
|
|
129
248
|
}
|