chrome-devtools-frontend 1.0.1586699 → 1.0.1587905
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/front_end/core/sdk/ScopeTreeCache.ts +4 -0
- package/front_end/entrypoint_template.html +5 -1
- package/front_end/generated/Deprecation.ts +21 -0
- package/front_end/generated/InspectorBackendCommands.ts +1 -1
- package/front_end/generated/protocol.ts +2 -0
- package/front_end/models/ai_assistance/AiConversation.ts +5 -1
- package/front_end/models/ai_assistance/agents/AiAgent.ts +16 -4
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +7 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +0 -2
- package/front_end/panels/ai_assistance/components/ChatInput.ts +36 -31
- package/front_end/panels/ai_assistance/components/chatInput.css +6 -9
- package/front_end/panels/application/ServiceWorkerCacheViews.ts +3 -6
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +11 -3
- package/front_end/panels/common/DOMLinkifier.ts +6 -1
- package/front_end/panels/elements/ComputedStyleWidget.ts +25 -2
- package/front_end/panels/elements/ElementsPanel.ts +114 -15
- package/front_end/panels/elements/PropertiesWidget.ts +40 -2
- package/front_end/panels/elements/StylesSidebarPane.ts +26 -3
- package/front_end/panels/network/NetworkDataGridNode.ts +4 -0
- package/front_end/panels/network/NetworkItemView.ts +6 -44
- package/front_end/panels/network/RequestHeadersView.ts +499 -0
- package/front_end/panels/network/components/RequestHeaderSection.ts +3 -0
- package/front_end/panels/network/components/components.ts +0 -2
- package/front_end/panels/network/network.ts +3 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/package.json +1 -1
- package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/ui/legacy/Toolbar.ts +37 -5
- package/front_end/ui/legacy/UIUtils.ts +35 -5
- package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +113 -133
- package/package.json +1 -1
- package/front_end/panels/network/components/RequestHeadersView.ts +0 -569
|
@@ -1,569 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
/* eslint-disable @devtools/no-lit-render-outside-of-view */
|
|
5
|
-
import '../../../ui/kit/kit.js';
|
|
6
|
-
|
|
7
|
-
import * as Common from '../../../core/common/common.js';
|
|
8
|
-
import * as Host from '../../../core/host/host.js';
|
|
9
|
-
import * as i18n from '../../../core/i18n/i18n.js';
|
|
10
|
-
import * as Platform from '../../../core/platform/platform.js';
|
|
11
|
-
import * as SDK from '../../../core/sdk/sdk.js';
|
|
12
|
-
import * as Persistence from '../../../models/persistence/persistence.js';
|
|
13
|
-
import * as Workspace from '../../../models/workspace/workspace.js';
|
|
14
|
-
import * as NetworkForward from '../../../panels/network/forward/forward.js';
|
|
15
|
-
import * as Buttons from '../../../ui/components/buttons/buttons.js';
|
|
16
|
-
import * as Input from '../../../ui/components/input/input.js';
|
|
17
|
-
import * as LegacyWrapper from '../../../ui/components/legacy_wrapper/legacy_wrapper.js';
|
|
18
|
-
import * as RenderCoordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
|
|
19
|
-
import * as UI from '../../../ui/legacy/legacy.js';
|
|
20
|
-
import * as Lit from '../../../ui/lit/lit.js';
|
|
21
|
-
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
|
|
22
|
-
import * as Sources from '../../sources/sources.js';
|
|
23
|
-
|
|
24
|
-
import {RequestHeaderSection} from './RequestHeaderSection.js';
|
|
25
|
-
import requestHeadersViewStyles from './RequestHeadersView.css.js';
|
|
26
|
-
import {
|
|
27
|
-
RESPONSE_HEADER_SECTION_DATA_KEY,
|
|
28
|
-
type ResponseHeaderSectionData,
|
|
29
|
-
} from './ResponseHeaderSection.js';
|
|
30
|
-
|
|
31
|
-
const RAW_HEADER_CUTOFF = 3000;
|
|
32
|
-
const {render, html} = Lit;
|
|
33
|
-
|
|
34
|
-
const UIStrings = {
|
|
35
|
-
/**
|
|
36
|
-
* @description Text in Request Headers View of the Network panel
|
|
37
|
-
*/
|
|
38
|
-
fromDiskCache: '(from disk cache)',
|
|
39
|
-
/**
|
|
40
|
-
* @description Text in Request Headers View of the Network panel
|
|
41
|
-
*/
|
|
42
|
-
fromMemoryCache: '(from memory cache)',
|
|
43
|
-
/**
|
|
44
|
-
* @description Text in Request Headers View of the Network panel
|
|
45
|
-
*/
|
|
46
|
-
fromEarlyHints: '(from early hints)',
|
|
47
|
-
/**
|
|
48
|
-
* @description Text in Request Headers View of the Network panel
|
|
49
|
-
*/
|
|
50
|
-
fromPrefetchCache: '(from prefetch cache)',
|
|
51
|
-
/**
|
|
52
|
-
* @description Text in Request Headers View of the Network panel
|
|
53
|
-
*/
|
|
54
|
-
fromServiceWorker: '(from `service worker`)',
|
|
55
|
-
/**
|
|
56
|
-
* @description Text in Request Headers View of the Network panel
|
|
57
|
-
*/
|
|
58
|
-
fromSignedexchange: '(from signed-exchange)',
|
|
59
|
-
/**
|
|
60
|
-
* @description Section header for a list of the main aspects of a http request
|
|
61
|
-
*/
|
|
62
|
-
general: 'General',
|
|
63
|
-
/**
|
|
64
|
-
* @description Label for a checkbox to switch between raw and parsed headers
|
|
65
|
-
*/
|
|
66
|
-
raw: 'Raw',
|
|
67
|
-
/**
|
|
68
|
-
* @description Text in Request Headers View of the Network panel
|
|
69
|
-
*/
|
|
70
|
-
referrerPolicy: 'Referrer Policy',
|
|
71
|
-
/**
|
|
72
|
-
* @description Text in Network Log View Columns of the Network panel
|
|
73
|
-
*/
|
|
74
|
-
remoteAddress: 'Remote Address',
|
|
75
|
-
/**
|
|
76
|
-
* @description Text in Request Headers View of the Network panel
|
|
77
|
-
*/
|
|
78
|
-
requestHeaders: 'Request Headers',
|
|
79
|
-
/**
|
|
80
|
-
* @description The HTTP method of a request
|
|
81
|
-
*/
|
|
82
|
-
requestMethod: 'Request Method',
|
|
83
|
-
/**
|
|
84
|
-
* @description The URL of a request
|
|
85
|
-
*/
|
|
86
|
-
requestUrl: 'Request URL',
|
|
87
|
-
/**
|
|
88
|
-
* @description A context menu item in the Network Log View Columns of the Network panel
|
|
89
|
-
*/
|
|
90
|
-
responseHeaders: 'Response headers',
|
|
91
|
-
/**
|
|
92
|
-
* @description A context menu item in the Network Log View Columns of the Network panel
|
|
93
|
-
*/
|
|
94
|
-
earlyHintsHeaders: 'Early hints headers',
|
|
95
|
-
/**
|
|
96
|
-
* @description Title text for a link to the Sources panel to the file containing the header override definitions
|
|
97
|
-
*/
|
|
98
|
-
revealHeaderOverrides: 'Reveal header override definitions',
|
|
99
|
-
/**
|
|
100
|
-
* @description Text to show more content
|
|
101
|
-
*/
|
|
102
|
-
showMore: 'Show more',
|
|
103
|
-
/**
|
|
104
|
-
* @description HTTP response code
|
|
105
|
-
*/
|
|
106
|
-
statusCode: 'Status Code',
|
|
107
|
-
} as const;
|
|
108
|
-
const str_ = i18n.i18n.registerUIStrings('panels/network/components/RequestHeadersView.ts', UIStrings);
|
|
109
|
-
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
110
|
-
|
|
111
|
-
export class RequestHeadersView extends LegacyWrapper.LegacyWrapper.WrappableComponent {
|
|
112
|
-
#request: Readonly<SDK.NetworkRequest.NetworkRequest>;
|
|
113
|
-
readonly #shadow = this.attachShadow({mode: 'open'});
|
|
114
|
-
#showResponseHeadersText = false;
|
|
115
|
-
#showRequestHeadersText = false;
|
|
116
|
-
#showResponseHeadersTextFull = false;
|
|
117
|
-
#showRequestHeadersTextFull = false;
|
|
118
|
-
#toReveal?: {section: NetworkForward.UIRequestLocation.UIHeaderSection, header?: string} = undefined;
|
|
119
|
-
readonly #workspace = Workspace.Workspace.WorkspaceImpl.instance();
|
|
120
|
-
|
|
121
|
-
constructor(request: SDK.NetworkRequest.NetworkRequest) {
|
|
122
|
-
super();
|
|
123
|
-
this.#request = request;
|
|
124
|
-
this.setAttribute('jslog', `${VisualLogging.pane('headers').track({resize: true})}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
override wasShown(): void {
|
|
128
|
-
super.wasShown();
|
|
129
|
-
this.#request.addEventListener(SDK.NetworkRequest.Events.REMOTE_ADDRESS_CHANGED, this.#refreshHeadersView, this);
|
|
130
|
-
this.#request.addEventListener(SDK.NetworkRequest.Events.FINISHED_LOADING, this.#refreshHeadersView, this);
|
|
131
|
-
this.#request.addEventListener(SDK.NetworkRequest.Events.REQUEST_HEADERS_CHANGED, this.#refreshHeadersView, this);
|
|
132
|
-
this.#request.addEventListener(
|
|
133
|
-
SDK.NetworkRequest.Events.RESPONSE_HEADERS_CHANGED, this.#resetAndRefreshHeadersView, this);
|
|
134
|
-
this.#toReveal = undefined;
|
|
135
|
-
this.#refreshHeadersView();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
override willHide(): void {
|
|
139
|
-
super.willHide();
|
|
140
|
-
this.#request.removeEventListener(SDK.NetworkRequest.Events.REMOTE_ADDRESS_CHANGED, this.#refreshHeadersView, this);
|
|
141
|
-
this.#request.removeEventListener(SDK.NetworkRequest.Events.FINISHED_LOADING, this.#refreshHeadersView, this);
|
|
142
|
-
this.#request.removeEventListener(
|
|
143
|
-
SDK.NetworkRequest.Events.REQUEST_HEADERS_CHANGED, this.#refreshHeadersView, this);
|
|
144
|
-
this.#request.removeEventListener(
|
|
145
|
-
SDK.NetworkRequest.Events.RESPONSE_HEADERS_CHANGED, this.#resetAndRefreshHeadersView, this);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
#resetAndRefreshHeadersView(): void {
|
|
149
|
-
this.#request.deleteAssociatedData(RESPONSE_HEADER_SECTION_DATA_KEY);
|
|
150
|
-
void this.render();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
#refreshHeadersView(): void {
|
|
154
|
-
void this.render();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
revealHeader(section: NetworkForward.UIRequestLocation.UIHeaderSection, header?: string): void {
|
|
158
|
-
this.#toReveal = {section, header};
|
|
159
|
-
void this.render();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
connectedCallback(): void {
|
|
163
|
-
this.#workspace.addEventListener(
|
|
164
|
-
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAddedOrRemoved, this);
|
|
165
|
-
this.#workspace.addEventListener(
|
|
166
|
-
Workspace.Workspace.Events.UISourceCodeRemoved, this.#uiSourceCodeAddedOrRemoved, this);
|
|
167
|
-
Common.Settings.Settings.instance()
|
|
168
|
-
.moduleSetting('persistence-network-overrides-enabled')
|
|
169
|
-
.addChangeListener(this.render, this);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
disconnectedCallback(): void {
|
|
173
|
-
this.#workspace.removeEventListener(
|
|
174
|
-
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAddedOrRemoved, this);
|
|
175
|
-
this.#workspace.removeEventListener(
|
|
176
|
-
Workspace.Workspace.Events.UISourceCodeRemoved, this.#uiSourceCodeAddedOrRemoved, this);
|
|
177
|
-
Common.Settings.Settings.instance()
|
|
178
|
-
.moduleSetting('persistence-network-overrides-enabled')
|
|
179
|
-
.removeChangeListener(this.render, this);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
#uiSourceCodeAddedOrRemoved(event: Common.EventTarget.EventTargetEvent<Workspace.UISourceCode.UISourceCode>): void {
|
|
183
|
-
if (this.#getHeaderOverridesFileUrl() === event.data.url()) {
|
|
184
|
-
void this.render();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
override async render(): Promise<void> {
|
|
189
|
-
if (!this.#request) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return await RenderCoordinator.write(() => {
|
|
194
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
195
|
-
// clang-format off
|
|
196
|
-
render(html`
|
|
197
|
-
<style>${requestHeadersViewStyles}</style>
|
|
198
|
-
<style>${Input.checkboxStyles}</style>
|
|
199
|
-
${this.#renderGeneralSection()}
|
|
200
|
-
${this.#renderEarlyHintsHeaders()}
|
|
201
|
-
${this.#renderResponseHeaders()}
|
|
202
|
-
${this.#renderRequestHeaders()}
|
|
203
|
-
`, this.#shadow, {host: this});
|
|
204
|
-
|
|
205
|
-
// clang-format on
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
#renderEarlyHintsHeaders(): Lit.LitTemplate {
|
|
210
|
-
if (!this.#request || !this.#request.earlyHintsHeaders || this.#request.earlyHintsHeaders.length === 0) {
|
|
211
|
-
return Lit.nothing;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const toggleShowRaw = (): void => {
|
|
215
|
-
this.#showResponseHeadersText = !this.#showResponseHeadersText;
|
|
216
|
-
void this.render();
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
220
|
-
return renderCategory({
|
|
221
|
-
onToggleRawHeaders: toggleShowRaw,
|
|
222
|
-
name: 'early-hints-headers',
|
|
223
|
-
title: i18nString(UIStrings.earlyHintsHeaders),
|
|
224
|
-
headerCount: this.#request.earlyHintsHeaders.length,
|
|
225
|
-
checked: undefined,
|
|
226
|
-
additionalContent: undefined,
|
|
227
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.EARLY_HINTS,
|
|
228
|
-
loggingContext: 'early-hints-headers',
|
|
229
|
-
contents: this.#showResponseHeadersText ? this.#renderRawHeaders(this.#request.responseHeadersText, true) : html`
|
|
230
|
-
<devtools-early-hints-header-section .data=${{
|
|
231
|
-
request: this.#request,
|
|
232
|
-
toReveal: this.#toReveal,
|
|
233
|
-
} as ResponseHeaderSectionData}></devtools-early-hints-header-section>
|
|
234
|
-
`
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
#renderResponseHeaders(): Lit.LitTemplate {
|
|
239
|
-
if (!this.#request) {
|
|
240
|
-
return Lit.nothing;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const toggleShowRaw = (): void => {
|
|
244
|
-
this.#showResponseHeadersText = !this.#showResponseHeadersText;
|
|
245
|
-
void this.render();
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
return renderCategory({
|
|
249
|
-
onToggleRawHeaders: toggleShowRaw,
|
|
250
|
-
name: 'response-headers',
|
|
251
|
-
title: i18nString(UIStrings.responseHeaders),
|
|
252
|
-
headerCount: this.#request.sortedResponseHeaders.length,
|
|
253
|
-
checked: this.#request.responseHeadersText ? this.#showResponseHeadersText : undefined,
|
|
254
|
-
additionalContent: this.#renderHeaderOverridesLink(),
|
|
255
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.RESPONSE,
|
|
256
|
-
loggingContext: 'response-headers',
|
|
257
|
-
contents: this.#showResponseHeadersText ?
|
|
258
|
-
this.#renderRawHeaders(this.#request.responseHeadersText, true) :
|
|
259
|
-
html`
|
|
260
|
-
<devtools-response-header-section .data=${{
|
|
261
|
-
request: this.#request,
|
|
262
|
-
toReveal: this.#toReveal,
|
|
263
|
-
} as ResponseHeaderSectionData} jslog=${
|
|
264
|
-
VisualLogging.section('response-headers')}></devtools-response-header-section>
|
|
265
|
-
`
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
#renderHeaderOverridesLink(): Lit.LitTemplate {
|
|
270
|
-
if (!this.#workspace.uiSourceCodeForURL(this.#getHeaderOverridesFileUrl())) {
|
|
271
|
-
return Lit.nothing;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const overridesSetting: Common.Settings.Setting<boolean> =
|
|
275
|
-
Common.Settings.Settings.instance().moduleSetting('persistence-network-overrides-enabled');
|
|
276
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
277
|
-
// clang-format off
|
|
278
|
-
const fileIcon = html`
|
|
279
|
-
<devtools-icon name="document" class=${'medium' + overridesSetting.get() ? 'inline-icon dot purple': 'inline-icon'}>
|
|
280
|
-
</devtools-icon>`;
|
|
281
|
-
// clang-format on
|
|
282
|
-
|
|
283
|
-
const revealHeadersFile = (event: Event): void => {
|
|
284
|
-
event.preventDefault();
|
|
285
|
-
const uiSourceCode = this.#workspace.uiSourceCodeForURL(this.#getHeaderOverridesFileUrl());
|
|
286
|
-
if (uiSourceCode) {
|
|
287
|
-
Sources.SourcesPanel.SourcesPanel.instance().showUISourceCode(uiSourceCode);
|
|
288
|
-
void Sources.SourcesPanel.SourcesPanel.instance().revealInNavigator(uiSourceCode);
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
293
|
-
// clang-format off
|
|
294
|
-
return html`
|
|
295
|
-
<devtools-link
|
|
296
|
-
href="https://goo.gle/devtools-override"
|
|
297
|
-
class="link devtools-link"
|
|
298
|
-
jslogcontext="devtools-override"
|
|
299
|
-
>
|
|
300
|
-
<devtools-icon name="help" class="inline-icon medium">
|
|
301
|
-
</devtools-icon>
|
|
302
|
-
</devtools-link>
|
|
303
|
-
<devtools-link
|
|
304
|
-
@click=${revealHeadersFile}
|
|
305
|
-
class="link devtools-link"
|
|
306
|
-
title=${UIStrings.revealHeaderOverrides}
|
|
307
|
-
jslogcontext="reveal-header-overrides"
|
|
308
|
-
>
|
|
309
|
-
${fileIcon}${Persistence.NetworkPersistenceManager.HEADERS_FILENAME}
|
|
310
|
-
</devtools-link>
|
|
311
|
-
`;
|
|
312
|
-
// clang-format on
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
#getHeaderOverridesFileUrl(): Platform.DevToolsPath.UrlString {
|
|
316
|
-
if (!this.#request) {
|
|
317
|
-
return Platform.DevToolsPath.EmptyUrlString;
|
|
318
|
-
}
|
|
319
|
-
const fileUrl = Persistence.NetworkPersistenceManager.NetworkPersistenceManager.instance().fileUrlFromNetworkUrl(
|
|
320
|
-
this.#request.url(), /* ignoreInactive */ true);
|
|
321
|
-
return fileUrl.substring(0, fileUrl.lastIndexOf('/')) + '/' +
|
|
322
|
-
Persistence.NetworkPersistenceManager.HEADERS_FILENAME as Platform.DevToolsPath.UrlString;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
#renderRequestHeaders(): Lit.LitTemplate {
|
|
326
|
-
if (!this.#request) {
|
|
327
|
-
return Lit.nothing;
|
|
328
|
-
}
|
|
329
|
-
const requestHeadersText = this.#request.requestHeadersText();
|
|
330
|
-
|
|
331
|
-
const toggleShowRaw = (): void => {
|
|
332
|
-
this.#showRequestHeadersText = !this.#showRequestHeadersText;
|
|
333
|
-
void this.render();
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
return renderCategory({
|
|
337
|
-
onToggleRawHeaders: toggleShowRaw,
|
|
338
|
-
name: 'request-headers',
|
|
339
|
-
title: i18nString(UIStrings.requestHeaders),
|
|
340
|
-
headerCount: this.#request.requestHeaders().length,
|
|
341
|
-
checked: requestHeadersText ? this.#showRequestHeadersText : undefined,
|
|
342
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.REQUEST,
|
|
343
|
-
loggingContext: 'request-headers',
|
|
344
|
-
contents: (this.#showRequestHeadersText && requestHeadersText) ?
|
|
345
|
-
this.#renderRawHeaders(requestHeadersText, false) :
|
|
346
|
-
html`
|
|
347
|
-
<devtools-widget .widgetConfig=${UI.Widget.widgetConfig(RequestHeaderSection, {
|
|
348
|
-
request: this.#request,
|
|
349
|
-
toReveal: this.#toReveal,
|
|
350
|
-
})} jslog=${VisualLogging.section('request-headers')}></devtools-widget>`
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
#renderRawHeaders(rawHeadersText: string, forResponseHeaders: boolean): Lit.TemplateResult {
|
|
355
|
-
const trimmed = rawHeadersText.trim();
|
|
356
|
-
const showFull = forResponseHeaders ? this.#showResponseHeadersTextFull : this.#showRequestHeadersTextFull;
|
|
357
|
-
const isShortened = !showFull && trimmed.length > RAW_HEADER_CUTOFF;
|
|
358
|
-
|
|
359
|
-
const showMore = (): void => {
|
|
360
|
-
if (forResponseHeaders) {
|
|
361
|
-
this.#showResponseHeadersTextFull = true;
|
|
362
|
-
} else {
|
|
363
|
-
this.#showRequestHeadersTextFull = true;
|
|
364
|
-
}
|
|
365
|
-
void this.render();
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const onContextMenuOpen = (event: Event): void => {
|
|
369
|
-
const showFull = forResponseHeaders ? this.#showResponseHeadersTextFull : this.#showRequestHeadersTextFull;
|
|
370
|
-
if (!showFull) {
|
|
371
|
-
const contextMenu = new UI.ContextMenu.ContextMenu(event);
|
|
372
|
-
const section = contextMenu.newSection();
|
|
373
|
-
section.appendItem(i18nString(UIStrings.showMore), showMore, {jslogContext: 'show-more'});
|
|
374
|
-
void contextMenu.show();
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
379
|
-
// clang-format off
|
|
380
|
-
return html`
|
|
381
|
-
<div
|
|
382
|
-
class="row raw-headers-row"
|
|
383
|
-
@contextmenu=${(event: Event) => {
|
|
384
|
-
if (isShortened) {
|
|
385
|
-
onContextMenuOpen(event);
|
|
386
|
-
}
|
|
387
|
-
}}
|
|
388
|
-
>
|
|
389
|
-
<div class="raw-headers">
|
|
390
|
-
${isShortened ? trimmed.substring(0, RAW_HEADER_CUTOFF) : trimmed}
|
|
391
|
-
</div>
|
|
392
|
-
${isShortened
|
|
393
|
-
? html`
|
|
394
|
-
<devtools-button
|
|
395
|
-
.size=${Buttons.Button.Size.SMALL}
|
|
396
|
-
.variant=${Buttons.Button.Variant.OUTLINED}
|
|
397
|
-
@click=${showMore}
|
|
398
|
-
jslog=${VisualLogging.action('raw-headers-show-more').track({
|
|
399
|
-
click: true,
|
|
400
|
-
})}
|
|
401
|
-
>${i18nString(UIStrings.showMore)}</devtools-button
|
|
402
|
-
>
|
|
403
|
-
`
|
|
404
|
-
: Lit.nothing}
|
|
405
|
-
</div>
|
|
406
|
-
`;
|
|
407
|
-
// clang-format on
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
#renderGeneralSection(): Lit.LitTemplate {
|
|
411
|
-
if (!this.#request) {
|
|
412
|
-
return Lit.nothing;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
const statusClasses = ['status'];
|
|
416
|
-
if (this.#request.statusCode < 300 || this.#request.statusCode === 304) {
|
|
417
|
-
statusClasses.push('green-circle');
|
|
418
|
-
} else if (this.#request.statusCode < 400) {
|
|
419
|
-
statusClasses.push('yellow-circle');
|
|
420
|
-
} else {
|
|
421
|
-
statusClasses.push('red-circle');
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
let comment = '';
|
|
425
|
-
if (this.#request.cachedInMemory()) {
|
|
426
|
-
comment = i18nString(UIStrings.fromMemoryCache);
|
|
427
|
-
} else if (this.#request.fromEarlyHints()) {
|
|
428
|
-
comment = i18nString(UIStrings.fromEarlyHints);
|
|
429
|
-
} else if (this.#request.fetchedViaServiceWorker) {
|
|
430
|
-
comment = i18nString(UIStrings.fromServiceWorker);
|
|
431
|
-
} else if (this.#request.redirectSourceSignedExchangeInfoHasNoErrors()) {
|
|
432
|
-
comment = i18nString(UIStrings.fromSignedexchange);
|
|
433
|
-
} else if (this.#request.fromPrefetchCache()) {
|
|
434
|
-
comment = i18nString(UIStrings.fromPrefetchCache);
|
|
435
|
-
} else if (this.#request.cached()) {
|
|
436
|
-
comment = i18nString(UIStrings.fromDiskCache);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
if (comment) {
|
|
440
|
-
statusClasses.push('status-with-comment');
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
const statusText = [this.#request.statusCode, this.#request.getInferredStatusText(), comment].join(' ');
|
|
444
|
-
|
|
445
|
-
return renderCategory({
|
|
446
|
-
name: 'general',
|
|
447
|
-
title: i18nString(UIStrings.general),
|
|
448
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.GENERAL,
|
|
449
|
-
loggingContext: 'general',
|
|
450
|
-
// clang-format off
|
|
451
|
-
contents: html`<div jslog=${VisualLogging.section('general')}>
|
|
452
|
-
${this.#renderGeneralRow(i18nString(UIStrings.requestUrl), this.#request.url(), 'request-url')}
|
|
453
|
-
${this.#request.statusCode? this.#renderGeneralRow(i18nString(UIStrings.requestMethod),
|
|
454
|
-
this.#request.requestMethod, 'request-method') : Lit.nothing}
|
|
455
|
-
${this.#request.statusCode? this.#renderGeneralRow(i18nString(UIStrings.statusCode),
|
|
456
|
-
statusText, 'status-code', statusClasses) : Lit.nothing}
|
|
457
|
-
${this.#request.remoteAddress()? this.#renderGeneralRow(i18nString(UIStrings.remoteAddress),
|
|
458
|
-
this.#request.remoteAddress(), 'remote-address') : Lit.nothing}
|
|
459
|
-
${this.#request.referrerPolicy()? this.#renderGeneralRow(i18nString(UIStrings.referrerPolicy),
|
|
460
|
-
String(this.#request.referrerPolicy()), 'referrer-policy') : Lit.nothing}
|
|
461
|
-
</div>`});
|
|
462
|
-
// clang-format on
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
#renderGeneralRow(name: Common.UIString.LocalizedString, value: string, id: string, classNames?: string[]):
|
|
466
|
-
Lit.LitTemplate {
|
|
467
|
-
const isHighlighted = this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.GENERAL &&
|
|
468
|
-
name.toLowerCase() === this.#toReveal?.header?.toLowerCase();
|
|
469
|
-
return html`
|
|
470
|
-
<div class="row ${isHighlighted ? 'header-highlight' : ''}">
|
|
471
|
-
<div class="header-name">${name}</div>
|
|
472
|
-
<div
|
|
473
|
-
id=${id}
|
|
474
|
-
class="header-value ${classNames?.join(' ')}"
|
|
475
|
-
@copy=${() => Host.userMetrics.actionTaken(Host.UserMetrics.Action.NetworkPanelCopyValue)}
|
|
476
|
-
>${value}</div>
|
|
477
|
-
</div>
|
|
478
|
-
`;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
getHeaderElementById(id: string): Element|null {
|
|
482
|
-
const categories = this.#shadow.querySelectorAll('devtools-request-headers-category');
|
|
483
|
-
for (const category of categories) {
|
|
484
|
-
const element = category.querySelector(`#${id}`);
|
|
485
|
-
if (element) {
|
|
486
|
-
return element;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
return null;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function renderCategory(data: {
|
|
494
|
-
name: string,
|
|
495
|
-
title: Common.UIString.LocalizedString,
|
|
496
|
-
contents: Lit.LitTemplate,
|
|
497
|
-
loggingContext: string,
|
|
498
|
-
headerCount?: number,
|
|
499
|
-
checked?: boolean,
|
|
500
|
-
additionalContent?: Lit.LitTemplate,
|
|
501
|
-
forceOpen?: boolean,
|
|
502
|
-
onToggleRawHeaders?: () => void,
|
|
503
|
-
}): Lit.LitTemplate {
|
|
504
|
-
const expandedSetting =
|
|
505
|
-
Common.Settings.Settings.instance().createSetting('request-info-' + data.name + '-category-expanded', true);
|
|
506
|
-
|
|
507
|
-
const isOpen = (expandedSetting ? expandedSetting.get() : true) || data.forceOpen;
|
|
508
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
509
|
-
// clang-format off
|
|
510
|
-
return html`
|
|
511
|
-
<details ?open=${isOpen} @toggle=${onToggle} aria-label=${data.title}>
|
|
512
|
-
<summary
|
|
513
|
-
class="header"
|
|
514
|
-
@keydown=${onSummaryKeyDown}
|
|
515
|
-
jslog=${VisualLogging.sectionHeader().track({click: true}).context(data.loggingContext)}
|
|
516
|
-
>
|
|
517
|
-
<div class="header-grid-container">
|
|
518
|
-
<div>
|
|
519
|
-
${data.title}${data.headerCount !== undefined ?
|
|
520
|
-
html`<span class="header-count"> (${data.headerCount})</span>` :
|
|
521
|
-
Lit.nothing
|
|
522
|
-
}
|
|
523
|
-
</div>
|
|
524
|
-
<div class="hide-when-closed">
|
|
525
|
-
${data.checked !== undefined ? html`
|
|
526
|
-
<devtools-checkbox .checked=${data.checked} @change=${data.onToggleRawHeaders}
|
|
527
|
-
jslog=${VisualLogging.toggle('raw-headers').track({change: true})}>
|
|
528
|
-
${i18nString(UIStrings.raw)}
|
|
529
|
-
</devtools-checkbox>` : Lit.nothing}
|
|
530
|
-
</div>
|
|
531
|
-
<div class="hide-when-closed">${data.additionalContent}</div>
|
|
532
|
-
</div>
|
|
533
|
-
</summary>
|
|
534
|
-
${data.contents}
|
|
535
|
-
</details>
|
|
536
|
-
`;
|
|
537
|
-
// clang-format on
|
|
538
|
-
|
|
539
|
-
function onSummaryKeyDown(event: KeyboardEvent): void {
|
|
540
|
-
if (!event.target) {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
const summaryElement = event.target as HTMLElement;
|
|
544
|
-
const detailsElement = summaryElement.parentElement as HTMLDetailsElement;
|
|
545
|
-
if (!detailsElement) {
|
|
546
|
-
throw new Error('<details> element is not found for a <summary> element');
|
|
547
|
-
}
|
|
548
|
-
switch (event.key) {
|
|
549
|
-
case 'ArrowLeft':
|
|
550
|
-
detailsElement.open = false;
|
|
551
|
-
break;
|
|
552
|
-
case 'ArrowRight':
|
|
553
|
-
detailsElement.open = true;
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function onToggle(event: Event): void {
|
|
559
|
-
expandedSetting?.set((event.target as HTMLDetailsElement).open);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
customElements.define('devtools-request-headers', RequestHeadersView);
|
|
564
|
-
|
|
565
|
-
declare global {
|
|
566
|
-
interface HTMLElementTagNameMap {
|
|
567
|
-
'devtools-request-headers': RequestHeadersView;
|
|
568
|
-
}
|
|
569
|
-
}
|