chrome-devtools-frontend 1.0.1587572 → 1.0.1588580
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/DOMModel.ts +3 -0
- package/front_end/core/sdk/PreloadingModel.ts +15 -6
- package/front_end/core/sdk/ScopeTreeCache.ts +4 -0
- package/front_end/generated/Deprecation.ts +21 -0
- package/front_end/generated/InspectorBackendCommands.ts +5 -3
- package/front_end/generated/SupportedCSSProperties.js +46 -0
- package/front_end/generated/protocol-mapping.d.ts +4 -0
- package/front_end/generated/protocol-proxy-api.d.ts +5 -0
- package/front_end/generated/protocol.ts +49 -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/models/computed_style/ComputedStyleModel.ts +2 -1
- package/front_end/models/javascript_metadata/NativeFunctions.js +4 -16
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +15 -23
- 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 -5
- package/front_end/panels/application/preloading/PreloadingView.ts +18 -0
- package/front_end/panels/application/preloading/components/RuleSetDetailsView.css +12 -0
- package/front_end/panels/application/preloading/components/RuleSetDetailsView.ts +3 -3
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +11 -3
- package/front_end/panels/common/DOMLinkifier.ts +6 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +3 -3
- package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +1 -1
- package/front_end/panels/elements/ComputedStyleWidget.ts +27 -18
- package/front_end/panels/elements/ElementsPanel.ts +12 -4
- package/front_end/panels/elements/PropertiesWidget.ts +91 -52
- package/front_end/panels/elements/StylePropertyTreeElement.ts +11 -12
- package/front_end/panels/elements/StylesSidebarPane.ts +51 -8
- package/front_end/panels/elements/elementsPanel.css +6 -2
- package/front_end/panels/network/NetworkDataGridNode.ts +4 -0
- package/front_end/panels/network/NetworkItemView.ts +6 -45
- package/front_end/panels/network/RequestHeadersView.ts +237 -318
- package/front_end/panels/sources/CSSPlugin.ts +1 -1
- package/front_end/third_party/chromium/README.chromium +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/inline_editor/ColorSwatch.ts +32 -28
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +31 -6
- package/front_end/ui/visual_logging/KnownContextValues.ts +7 -0
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright 2022 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-lit-render-outside-of-view */
|
|
5
4
|
import '../../ui/kit/kit.js';
|
|
6
5
|
|
|
7
6
|
import * as Common from '../../core/common/common.js';
|
|
@@ -12,18 +11,15 @@ import * as SDK from '../../core/sdk/sdk.js';
|
|
|
12
11
|
import * as Persistence from '../../models/persistence/persistence.js';
|
|
13
12
|
import * as Workspace from '../../models/workspace/workspace.js';
|
|
14
13
|
import * as NetworkForward from '../../panels/network/forward/forward.js';
|
|
15
|
-
import * as Buttons from '../../ui/components/buttons/buttons.js';
|
|
16
14
|
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
15
|
import * as UI from '../../ui/legacy/legacy.js';
|
|
20
16
|
import * as Lit from '../../ui/lit/lit.js';
|
|
21
17
|
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
|
|
22
18
|
import * as Sources from '../sources/sources.js';
|
|
23
19
|
|
|
24
20
|
import * as NetworkComponents from './components/components.js';
|
|
21
|
+
import {ShowMoreDetailsWidget} from './ShowMoreDetailsWidget.js';
|
|
25
22
|
|
|
26
|
-
const RAW_HEADER_CUTOFF = 3000;
|
|
27
23
|
const {render, html} = Lit;
|
|
28
24
|
|
|
29
25
|
const UIStrings = {
|
|
@@ -91,10 +87,6 @@ const UIStrings = {
|
|
|
91
87
|
* @description Title text for a link to the Sources panel to the file containing the header override definitions
|
|
92
88
|
*/
|
|
93
89
|
revealHeaderOverrides: 'Reveal header override definitions',
|
|
94
|
-
/**
|
|
95
|
-
* @description Text to show more content
|
|
96
|
-
*/
|
|
97
|
-
showMore: 'Show more',
|
|
98
90
|
/**
|
|
99
91
|
* @description HTTP response code
|
|
100
92
|
*/
|
|
@@ -103,189 +95,281 @@ const UIStrings = {
|
|
|
103
95
|
const str_ = i18n.i18n.registerUIStrings('panels/network/RequestHeadersView.ts', UIStrings);
|
|
104
96
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
105
97
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
interface ViewInput {
|
|
99
|
+
showRequestHeadersText: boolean;
|
|
100
|
+
showResponseHeadersText: boolean;
|
|
101
|
+
request: SDK.NetworkRequest.NetworkRequest;
|
|
102
|
+
toggleShowRawResponseHeaders: () => void;
|
|
103
|
+
toggleShowRawRequestHeaders: () => void;
|
|
104
|
+
revealHeadersFile?: () => void;
|
|
105
|
+
toReveal?: {section: NetworkForward.UIRequestLocation.UIHeaderSection, header?: string};
|
|
106
|
+
}
|
|
107
|
+
type View = (input: ViewInput, output: object, target: HTMLElement) => void;
|
|
108
|
+
export const DEFAULT_VIEW: View = (input, output, target) => {
|
|
109
|
+
const requestHeadersText = input.request.requestHeadersText();
|
|
110
|
+
const statusClasses = ['status'];
|
|
111
|
+
if (input.request.statusCode < 300 || input.request.statusCode === 304) {
|
|
112
|
+
statusClasses.push('green-circle');
|
|
113
|
+
} else if (input.request.statusCode < 400) {
|
|
114
|
+
statusClasses.push('yellow-circle');
|
|
115
|
+
} else {
|
|
116
|
+
statusClasses.push('red-circle');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let comment = '';
|
|
120
|
+
if (input.request.cachedInMemory()) {
|
|
121
|
+
comment = i18nString(UIStrings.fromMemoryCache);
|
|
122
|
+
} else if (input.request.fromEarlyHints()) {
|
|
123
|
+
comment = i18nString(UIStrings.fromEarlyHints);
|
|
124
|
+
} else if (input.request.fetchedViaServiceWorker) {
|
|
125
|
+
comment = i18nString(UIStrings.fromServiceWorker);
|
|
126
|
+
} else if (input.request.redirectSourceSignedExchangeInfoHasNoErrors()) {
|
|
127
|
+
comment = i18nString(UIStrings.fromSignedexchange);
|
|
128
|
+
} else if (input.request.fromPrefetchCache()) {
|
|
129
|
+
comment = i18nString(UIStrings.fromPrefetchCache);
|
|
130
|
+
} else if (input.request.cached()) {
|
|
131
|
+
comment = i18nString(UIStrings.fromDiskCache);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (comment) {
|
|
135
|
+
statusClasses.push('status-with-comment');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const statusText = [input.request.statusCode, input.request.getInferredStatusText(), comment].join(' ');
|
|
139
|
+
// clang-format off
|
|
140
|
+
render(
|
|
141
|
+
html`
|
|
142
|
+
<style>${NetworkComponents.RequestHeaderSection.requestHeadersViewStyles}</style>
|
|
143
|
+
<style>${Input.checkboxStyles}</style>
|
|
144
|
+
${renderCategory({
|
|
145
|
+
name: 'general',
|
|
146
|
+
title: i18nString(UIStrings.general),
|
|
147
|
+
forceOpen: input.toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.GENERAL,
|
|
148
|
+
loggingContext: 'general',
|
|
149
|
+
contents: html`<div jslog=${VisualLogging.section('general')}>
|
|
150
|
+
${renderGeneralRow(input, i18nString(UIStrings.requestUrl), input.request.url(), 'request-url')}
|
|
151
|
+
${input.request.statusCode? renderGeneralRow(input, i18nString(UIStrings.requestMethod),
|
|
152
|
+
input.request.requestMethod, 'request-method') : Lit.nothing}
|
|
153
|
+
${input.request.statusCode? renderGeneralRow(input, i18nString(UIStrings.statusCode),
|
|
154
|
+
statusText, 'status-code', statusClasses) : Lit.nothing}
|
|
155
|
+
${input.request.remoteAddress()? renderGeneralRow(input, i18nString(UIStrings.remoteAddress),
|
|
156
|
+
input.request.remoteAddress(), 'remote-address') : Lit.nothing}
|
|
157
|
+
${input.request.referrerPolicy()? renderGeneralRow(input, i18nString(UIStrings.referrerPolicy),
|
|
158
|
+
String(input.request.referrerPolicy()), 'referrer-policy') : Lit.nothing}
|
|
159
|
+
</div>`
|
|
160
|
+
})}
|
|
161
|
+
${!input.request?.earlyHintsHeaders || input.request.earlyHintsHeaders.length === 0
|
|
162
|
+
? Lit.nothing
|
|
163
|
+
: renderCategory({
|
|
164
|
+
name: 'early-hints-headers',
|
|
165
|
+
onToggleRawHeaders: input.toggleShowRawResponseHeaders,
|
|
166
|
+
title: i18nString(UIStrings.earlyHintsHeaders),
|
|
167
|
+
headerCount: input.request.earlyHintsHeaders.length,
|
|
168
|
+
checked: undefined,
|
|
169
|
+
additionalContent: undefined,
|
|
170
|
+
forceOpen: input.toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.EARLY_HINTS,
|
|
171
|
+
loggingContext: 'early-hints-headers',
|
|
172
|
+
contents: input.showResponseHeadersText ?
|
|
173
|
+
renderRawHeaders(input.request.responseHeadersText) :
|
|
174
|
+
html`
|
|
175
|
+
<devtools-early-hints-header-section .data=${
|
|
176
|
+
{
|
|
177
|
+
request: input.request,
|
|
178
|
+
toReveal: input.toReveal,
|
|
179
|
+
} as NetworkComponents.ResponseHeaderSection
|
|
180
|
+
.ResponseHeaderSectionData}></devtools-early-hints-header-section>
|
|
181
|
+
`
|
|
182
|
+
})}
|
|
183
|
+
${renderCategory({
|
|
184
|
+
name: 'response-headers',
|
|
185
|
+
onToggleRawHeaders: input.toggleShowRawResponseHeaders,
|
|
186
|
+
title: i18nString(UIStrings.responseHeaders),
|
|
187
|
+
headerCount: input.request.sortedResponseHeaders.length,
|
|
188
|
+
checked: input.request.responseHeadersText ? input.showResponseHeadersText : undefined,
|
|
189
|
+
additionalContent: renderHeaderOverridesLink(input),
|
|
190
|
+
forceOpen: input.toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.RESPONSE,
|
|
191
|
+
loggingContext: 'response-headers',
|
|
192
|
+
contents: input.showResponseHeadersText ?
|
|
193
|
+
renderRawHeaders(input.request.responseHeadersText) :
|
|
194
|
+
html`
|
|
195
|
+
<devtools-response-header-section .data=${{
|
|
196
|
+
request: input.request,
|
|
197
|
+
toReveal: input.toReveal,
|
|
198
|
+
} as NetworkComponents.ResponseHeaderSection.ResponseHeaderSectionData} jslog=${
|
|
199
|
+
VisualLogging.section('response-headers')}></devtools-response-header-section>
|
|
200
|
+
`
|
|
201
|
+
})}
|
|
202
|
+
${renderCategory({
|
|
203
|
+
name: 'request-headers',
|
|
204
|
+
onToggleRawHeaders: input.toggleShowRawRequestHeaders,
|
|
205
|
+
title: i18nString(UIStrings.requestHeaders),
|
|
206
|
+
headerCount: input.request.requestHeaders().length,
|
|
207
|
+
checked: requestHeadersText ? input.showRequestHeadersText : undefined,
|
|
208
|
+
forceOpen: input.toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.REQUEST,
|
|
209
|
+
loggingContext: 'request-headers',
|
|
210
|
+
contents: (input.showRequestHeadersText && requestHeadersText) ?
|
|
211
|
+
renderRawHeaders(requestHeadersText) :
|
|
212
|
+
html`
|
|
213
|
+
<devtools-widget .widgetConfig=${
|
|
214
|
+
UI.Widget.widgetConfig(NetworkComponents.RequestHeaderSection.RequestHeaderSection, {
|
|
215
|
+
request: input.request,
|
|
216
|
+
toReveal: input.toReveal,
|
|
217
|
+
})} jslog=${VisualLogging.section('request-headers')}></devtools-widget>`
|
|
218
|
+
})}
|
|
219
|
+
`,
|
|
220
|
+
// clang-format on
|
|
221
|
+
target);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export class RequestHeadersView extends UI.Widget.Widget {
|
|
225
|
+
#request?: SDK.NetworkRequest.NetworkRequest;
|
|
109
226
|
#showResponseHeadersText = false;
|
|
110
227
|
#showRequestHeadersText = false;
|
|
111
|
-
#showResponseHeadersTextFull = false;
|
|
112
|
-
#showRequestHeadersTextFull = false;
|
|
113
228
|
#toReveal?: {section: NetworkForward.UIRequestLocation.UIHeaderSection, header?: string} = undefined;
|
|
114
229
|
readonly #workspace = Workspace.Workspace.WorkspaceImpl.instance();
|
|
230
|
+
#view: View;
|
|
231
|
+
get request(): SDK.NetworkRequest.NetworkRequest|undefined {
|
|
232
|
+
return this.#request;
|
|
233
|
+
}
|
|
115
234
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.#request =
|
|
119
|
-
this
|
|
235
|
+
set request(val) {
|
|
236
|
+
this.#removeEventListeners();
|
|
237
|
+
this.#request = val;
|
|
238
|
+
this.#addEventListeners();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
constructor(target?: HTMLElement, view = DEFAULT_VIEW) {
|
|
242
|
+
super({jslog: `${VisualLogging.pane('headers').track({resize: true})}`});
|
|
243
|
+
this.#view = view;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#addEventListeners(): void {
|
|
247
|
+
this.#request?.addEventListener(SDK.NetworkRequest.Events.REMOTE_ADDRESS_CHANGED, this.#refreshHeadersView, this);
|
|
248
|
+
this.#request?.addEventListener(SDK.NetworkRequest.Events.FINISHED_LOADING, this.#refreshHeadersView, this);
|
|
249
|
+
this.#request?.addEventListener(SDK.NetworkRequest.Events.REQUEST_HEADERS_CHANGED, this.#refreshHeadersView, this);
|
|
250
|
+
this.#request?.addEventListener(
|
|
251
|
+
SDK.NetworkRequest.Events.RESPONSE_HEADERS_CHANGED, this.#resetAndRefreshHeadersView, this);
|
|
252
|
+
this.#workspace.addEventListener(
|
|
253
|
+
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAddedOrRemoved, this);
|
|
254
|
+
this.#workspace.addEventListener(
|
|
255
|
+
Workspace.Workspace.Events.UISourceCodeRemoved, this.#uiSourceCodeAddedOrRemoved, this);
|
|
256
|
+
Common.Settings.Settings.instance()
|
|
257
|
+
.moduleSetting('persistence-network-overrides-enabled')
|
|
258
|
+
.addChangeListener(this.requestUpdate, this);
|
|
120
259
|
}
|
|
121
260
|
|
|
122
261
|
override wasShown(): void {
|
|
123
262
|
super.wasShown();
|
|
124
|
-
this.#
|
|
125
|
-
this.#request.addEventListener(SDK.NetworkRequest.Events.FINISHED_LOADING, this.#refreshHeadersView, this);
|
|
126
|
-
this.#request.addEventListener(SDK.NetworkRequest.Events.REQUEST_HEADERS_CHANGED, this.#refreshHeadersView, this);
|
|
127
|
-
this.#request.addEventListener(
|
|
128
|
-
SDK.NetworkRequest.Events.RESPONSE_HEADERS_CHANGED, this.#resetAndRefreshHeadersView, this);
|
|
263
|
+
this.#addEventListeners();
|
|
129
264
|
this.#toReveal = undefined;
|
|
130
265
|
this.#refreshHeadersView();
|
|
131
266
|
}
|
|
132
267
|
|
|
133
268
|
override willHide(): void {
|
|
134
269
|
super.willHide();
|
|
135
|
-
this.#
|
|
136
|
-
|
|
137
|
-
|
|
270
|
+
this.#removeEventListeners();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
#removeEventListeners(): void {
|
|
274
|
+
this.#request?.removeEventListener(
|
|
275
|
+
SDK.NetworkRequest.Events.REMOTE_ADDRESS_CHANGED, this.#refreshHeadersView, this);
|
|
276
|
+
this.#request?.removeEventListener(SDK.NetworkRequest.Events.FINISHED_LOADING, this.#refreshHeadersView, this);
|
|
277
|
+
this.#request?.removeEventListener(
|
|
138
278
|
SDK.NetworkRequest.Events.REQUEST_HEADERS_CHANGED, this.#refreshHeadersView, this);
|
|
139
|
-
this.#request
|
|
279
|
+
this.#request?.removeEventListener(
|
|
140
280
|
SDK.NetworkRequest.Events.RESPONSE_HEADERS_CHANGED, this.#resetAndRefreshHeadersView, this);
|
|
281
|
+
this.#workspace.removeEventListener(
|
|
282
|
+
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAddedOrRemoved, this);
|
|
283
|
+
this.#workspace.removeEventListener(
|
|
284
|
+
Workspace.Workspace.Events.UISourceCodeRemoved, this.#uiSourceCodeAddedOrRemoved, this);
|
|
285
|
+
Common.Settings.Settings.instance()
|
|
286
|
+
.moduleSetting('persistence-network-overrides-enabled')
|
|
287
|
+
.removeChangeListener(this.requestUpdate, this);
|
|
141
288
|
}
|
|
142
289
|
|
|
143
290
|
#resetAndRefreshHeadersView(): void {
|
|
144
|
-
this.#request
|
|
145
|
-
|
|
291
|
+
this.#request?.deleteAssociatedData(NetworkComponents.ResponseHeaderSection.RESPONSE_HEADER_SECTION_DATA_KEY);
|
|
292
|
+
this.requestUpdate();
|
|
146
293
|
}
|
|
147
294
|
|
|
148
295
|
#refreshHeadersView(): void {
|
|
149
|
-
|
|
296
|
+
this.requestUpdate();
|
|
150
297
|
}
|
|
151
298
|
|
|
152
299
|
revealHeader(section: NetworkForward.UIRequestLocation.UIHeaderSection, header?: string): void {
|
|
153
300
|
this.#toReveal = {section, header};
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
connectedCallback(): void {
|
|
158
|
-
this.#workspace.addEventListener(
|
|
159
|
-
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAddedOrRemoved, this);
|
|
160
|
-
this.#workspace.addEventListener(
|
|
161
|
-
Workspace.Workspace.Events.UISourceCodeRemoved, this.#uiSourceCodeAddedOrRemoved, this);
|
|
162
|
-
Common.Settings.Settings.instance()
|
|
163
|
-
.moduleSetting('persistence-network-overrides-enabled')
|
|
164
|
-
.addChangeListener(this.render, this);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
disconnectedCallback(): void {
|
|
168
|
-
this.#workspace.removeEventListener(
|
|
169
|
-
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAddedOrRemoved, this);
|
|
170
|
-
this.#workspace.removeEventListener(
|
|
171
|
-
Workspace.Workspace.Events.UISourceCodeRemoved, this.#uiSourceCodeAddedOrRemoved, this);
|
|
172
|
-
Common.Settings.Settings.instance()
|
|
173
|
-
.moduleSetting('persistence-network-overrides-enabled')
|
|
174
|
-
.removeChangeListener(this.render, this);
|
|
301
|
+
this.requestUpdate();
|
|
175
302
|
}
|
|
176
303
|
|
|
177
304
|
#uiSourceCodeAddedOrRemoved(event: Common.EventTarget.EventTargetEvent<Workspace.UISourceCode.UISourceCode>): void {
|
|
178
305
|
if (this.#getHeaderOverridesFileUrl() === event.data.url()) {
|
|
179
|
-
|
|
306
|
+
this.requestUpdate();
|
|
180
307
|
}
|
|
181
308
|
}
|
|
182
309
|
|
|
183
|
-
override
|
|
310
|
+
override performUpdate(): void {
|
|
184
311
|
if (!this.#request) {
|
|
185
312
|
return;
|
|
186
313
|
}
|
|
187
314
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
${this.#renderEarlyHintsHeaders()}
|
|
196
|
-
${this.#renderResponseHeaders()}
|
|
197
|
-
${this.#renderRequestHeaders()}
|
|
198
|
-
`, this.#shadow, {host: this});
|
|
199
|
-
|
|
200
|
-
// clang-format on
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
#renderEarlyHintsHeaders(): Lit.LitTemplate {
|
|
205
|
-
if (!this.#request || !this.#request.earlyHintsHeaders || this.#request.earlyHintsHeaders.length === 0) {
|
|
206
|
-
return Lit.nothing;
|
|
315
|
+
let revealHeadersFile;
|
|
316
|
+
const uiSourceCode = this.#workspace.uiSourceCodeForURL(this.#getHeaderOverridesFileUrl());
|
|
317
|
+
if (uiSourceCode) {
|
|
318
|
+
revealHeadersFile = (): void => {
|
|
319
|
+
Sources.SourcesPanel.SourcesPanel.instance().showUISourceCode(uiSourceCode);
|
|
320
|
+
void Sources.SourcesPanel.SourcesPanel.instance().revealInNavigator(uiSourceCode);
|
|
321
|
+
};
|
|
207
322
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
323
|
+
const input: ViewInput = {
|
|
324
|
+
toggleShowRawResponseHeaders: (): void => {
|
|
325
|
+
this.#showResponseHeadersText = !this.#showResponseHeadersText;
|
|
326
|
+
this.requestUpdate();
|
|
327
|
+
},
|
|
328
|
+
toggleShowRawRequestHeaders: (): void => {
|
|
329
|
+
this.#showRequestHeadersText = !this.#showRequestHeadersText;
|
|
330
|
+
this.requestUpdate();
|
|
331
|
+
},
|
|
332
|
+
revealHeadersFile,
|
|
333
|
+
request: this.#request,
|
|
334
|
+
toReveal: this.#toReveal,
|
|
335
|
+
showResponseHeadersText: this.#showResponseHeadersText,
|
|
336
|
+
showRequestHeadersText: this.#showRequestHeadersText,
|
|
212
337
|
};
|
|
213
338
|
|
|
214
|
-
|
|
215
|
-
return renderCategory({
|
|
216
|
-
onToggleRawHeaders: toggleShowRaw,
|
|
217
|
-
name: 'early-hints-headers',
|
|
218
|
-
title: i18nString(UIStrings.earlyHintsHeaders),
|
|
219
|
-
headerCount: this.#request.earlyHintsHeaders.length,
|
|
220
|
-
checked: undefined,
|
|
221
|
-
additionalContent: undefined,
|
|
222
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.EARLY_HINTS,
|
|
223
|
-
loggingContext: 'early-hints-headers',
|
|
224
|
-
contents: this.#showResponseHeadersText ? this.#renderRawHeaders(this.#request.responseHeadersText, true) : html`
|
|
225
|
-
<devtools-early-hints-header-section .data=${{
|
|
226
|
-
request: this.#request,
|
|
227
|
-
toReveal: this.#toReveal,
|
|
228
|
-
} as NetworkComponents.ResponseHeaderSection.ResponseHeaderSectionData}></devtools-early-hints-header-section>
|
|
229
|
-
`
|
|
230
|
-
});
|
|
339
|
+
this.#view(input, {}, this.contentElement);
|
|
231
340
|
}
|
|
232
341
|
|
|
233
|
-
#
|
|
342
|
+
#getHeaderOverridesFileUrl(): Platform.DevToolsPath.UrlString {
|
|
234
343
|
if (!this.#request) {
|
|
235
|
-
return
|
|
344
|
+
return Platform.DevToolsPath.EmptyUrlString;
|
|
236
345
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
return renderCategory({
|
|
244
|
-
onToggleRawHeaders: toggleShowRaw,
|
|
245
|
-
name: 'response-headers',
|
|
246
|
-
title: i18nString(UIStrings.responseHeaders),
|
|
247
|
-
headerCount: this.#request.sortedResponseHeaders.length,
|
|
248
|
-
checked: this.#request.responseHeadersText ? this.#showResponseHeadersText : undefined,
|
|
249
|
-
additionalContent: this.#renderHeaderOverridesLink(),
|
|
250
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.RESPONSE,
|
|
251
|
-
loggingContext: 'response-headers',
|
|
252
|
-
contents: this.#showResponseHeadersText ?
|
|
253
|
-
this.#renderRawHeaders(this.#request.responseHeadersText, true) :
|
|
254
|
-
html`
|
|
255
|
-
<devtools-response-header-section .data=${{
|
|
256
|
-
request: this.#request,
|
|
257
|
-
toReveal: this.#toReveal,
|
|
258
|
-
} as NetworkComponents.ResponseHeaderSection.ResponseHeaderSectionData} jslog=${
|
|
259
|
-
VisualLogging.section('response-headers')}></devtools-response-header-section>
|
|
260
|
-
`
|
|
261
|
-
});
|
|
346
|
+
const fileUrl = Persistence.NetworkPersistenceManager.NetworkPersistenceManager.instance().fileUrlFromNetworkUrl(
|
|
347
|
+
this.#request.url(), /* ignoreInactive */ true);
|
|
348
|
+
return fileUrl.substring(0, fileUrl.lastIndexOf('/')) + '/' +
|
|
349
|
+
Persistence.NetworkPersistenceManager.HEADERS_FILENAME as Platform.DevToolsPath.UrlString;
|
|
262
350
|
}
|
|
351
|
+
}
|
|
263
352
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
353
|
+
function renderHeaderOverridesLink(input: ViewInput): Lit.LitTemplate {
|
|
354
|
+
if (!input.revealHeadersFile) {
|
|
355
|
+
return Lit.nothing;
|
|
356
|
+
}
|
|
268
357
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
358
|
+
const revealHeadersFile = (event: Event): void => {
|
|
359
|
+
event.preventDefault();
|
|
360
|
+
input.revealHeadersFile?.();
|
|
361
|
+
};
|
|
362
|
+
const overridesSetting: Common.Settings.Setting<boolean> =
|
|
363
|
+
Common.Settings.Settings.instance().moduleSetting('persistence-network-overrides-enabled');
|
|
364
|
+
// Disabled until https://crbug.com/1079231 is fixed.
|
|
365
|
+
// clang-format off
|
|
273
366
|
const fileIcon = html`
|
|
274
367
|
<devtools-icon name="document" class=${'medium' + overridesSetting.get() ? 'inline-icon dot purple': 'inline-icon'}>
|
|
275
368
|
</devtools-icon>`;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const revealHeadersFile = (event: Event): void => {
|
|
279
|
-
event.preventDefault();
|
|
280
|
-
const uiSourceCode = this.#workspace.uiSourceCodeForURL(this.#getHeaderOverridesFileUrl());
|
|
281
|
-
if (uiSourceCode) {
|
|
282
|
-
Sources.SourcesPanel.SourcesPanel.instance().showUISourceCode(uiSourceCode);
|
|
283
|
-
void Sources.SourcesPanel.SourcesPanel.instance().revealInNavigator(uiSourceCode);
|
|
284
|
-
}
|
|
285
|
-
};
|
|
369
|
+
// clang-format on
|
|
286
370
|
|
|
287
|
-
|
|
288
|
-
|
|
371
|
+
// Disabled until https://crbug.com/1079231 is fixed.
|
|
372
|
+
// clang-format off
|
|
289
373
|
return html`
|
|
290
374
|
<devtools-link
|
|
291
375
|
href="https://goo.gle/devtools-override"
|
|
@@ -304,165 +388,20 @@ export class RequestHeadersView extends LegacyWrapper.LegacyWrapper.WrappableCom
|
|
|
304
388
|
${fileIcon}${Persistence.NetworkPersistenceManager.HEADERS_FILENAME}
|
|
305
389
|
</devtools-link>
|
|
306
390
|
`;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
#getHeaderOverridesFileUrl(): Platform.DevToolsPath.UrlString {
|
|
311
|
-
if (!this.#request) {
|
|
312
|
-
return Platform.DevToolsPath.EmptyUrlString;
|
|
313
|
-
}
|
|
314
|
-
const fileUrl = Persistence.NetworkPersistenceManager.NetworkPersistenceManager.instance().fileUrlFromNetworkUrl(
|
|
315
|
-
this.#request.url(), /* ignoreInactive */ true);
|
|
316
|
-
return fileUrl.substring(0, fileUrl.lastIndexOf('/')) + '/' +
|
|
317
|
-
Persistence.NetworkPersistenceManager.HEADERS_FILENAME as Platform.DevToolsPath.UrlString;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
#renderRequestHeaders(): Lit.LitTemplate {
|
|
321
|
-
if (!this.#request) {
|
|
322
|
-
return Lit.nothing;
|
|
323
|
-
}
|
|
324
|
-
const requestHeadersText = this.#request.requestHeadersText();
|
|
325
|
-
|
|
326
|
-
const toggleShowRaw = (): void => {
|
|
327
|
-
this.#showRequestHeadersText = !this.#showRequestHeadersText;
|
|
328
|
-
void this.render();
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
return renderCategory({
|
|
332
|
-
onToggleRawHeaders: toggleShowRaw,
|
|
333
|
-
name: 'request-headers',
|
|
334
|
-
title: i18nString(UIStrings.requestHeaders),
|
|
335
|
-
headerCount: this.#request.requestHeaders().length,
|
|
336
|
-
checked: requestHeadersText ? this.#showRequestHeadersText : undefined,
|
|
337
|
-
forceOpen: this.#toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.REQUEST,
|
|
338
|
-
loggingContext: 'request-headers',
|
|
339
|
-
contents: (this.#showRequestHeadersText && requestHeadersText) ?
|
|
340
|
-
this.#renderRawHeaders(requestHeadersText, false) :
|
|
341
|
-
html`
|
|
342
|
-
<devtools-widget .widgetConfig=${
|
|
343
|
-
UI.Widget.widgetConfig(NetworkComponents.RequestHeaderSection.RequestHeaderSection, {
|
|
344
|
-
request: this.#request,
|
|
345
|
-
toReveal: this.#toReveal,
|
|
346
|
-
})} jslog=${VisualLogging.section('request-headers')}></devtools-widget>`
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
#renderRawHeaders(rawHeadersText: string, forResponseHeaders: boolean): Lit.TemplateResult {
|
|
351
|
-
const trimmed = rawHeadersText.trim();
|
|
352
|
-
const showFull = forResponseHeaders ? this.#showResponseHeadersTextFull : this.#showRequestHeadersTextFull;
|
|
353
|
-
const isShortened = !showFull && trimmed.length > RAW_HEADER_CUTOFF;
|
|
354
|
-
|
|
355
|
-
const showMore = (): void => {
|
|
356
|
-
if (forResponseHeaders) {
|
|
357
|
-
this.#showResponseHeadersTextFull = true;
|
|
358
|
-
} else {
|
|
359
|
-
this.#showRequestHeadersTextFull = true;
|
|
360
|
-
}
|
|
361
|
-
void this.render();
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
const onContextMenuOpen = (event: Event): void => {
|
|
365
|
-
const showFull = forResponseHeaders ? this.#showResponseHeadersTextFull : this.#showRequestHeadersTextFull;
|
|
366
|
-
if (!showFull) {
|
|
367
|
-
const contextMenu = new UI.ContextMenu.ContextMenu(event);
|
|
368
|
-
const section = contextMenu.newSection();
|
|
369
|
-
section.appendItem(i18nString(UIStrings.showMore), showMore, {jslogContext: 'show-more'});
|
|
370
|
-
void contextMenu.show();
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
// Disabled until https://crbug.com/1079231 is fixed.
|
|
375
|
-
// clang-format off
|
|
376
|
-
return html`
|
|
377
|
-
<div
|
|
378
|
-
class="row raw-headers-row"
|
|
379
|
-
@contextmenu=${(event: Event) => {
|
|
380
|
-
if (isShortened) {
|
|
381
|
-
onContextMenuOpen(event);
|
|
382
|
-
}
|
|
383
|
-
}}
|
|
384
|
-
>
|
|
385
|
-
<div class="raw-headers">
|
|
386
|
-
${isShortened ? trimmed.substring(0, RAW_HEADER_CUTOFF) : trimmed}
|
|
387
|
-
</div>
|
|
388
|
-
${isShortened
|
|
389
|
-
? html`
|
|
390
|
-
<devtools-button
|
|
391
|
-
.size=${Buttons.Button.Size.SMALL}
|
|
392
|
-
.variant=${Buttons.Button.Variant.OUTLINED}
|
|
393
|
-
@click=${showMore}
|
|
394
|
-
jslog=${VisualLogging.action('raw-headers-show-more').track({
|
|
395
|
-
click: true,
|
|
396
|
-
})}
|
|
397
|
-
>${i18nString(UIStrings.showMore)}</devtools-button
|
|
398
|
-
>
|
|
399
|
-
`
|
|
400
|
-
: Lit.nothing}
|
|
401
|
-
</div>
|
|
402
|
-
`;
|
|
403
|
-
// clang-format on
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
#renderGeneralSection(): Lit.LitTemplate {
|
|
407
|
-
if (!this.#request) {
|
|
408
|
-
return Lit.nothing;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
const statusClasses = ['status'];
|
|
412
|
-
if (this.#request.statusCode < 300 || this.#request.statusCode === 304) {
|
|
413
|
-
statusClasses.push('green-circle');
|
|
414
|
-
} else if (this.#request.statusCode < 400) {
|
|
415
|
-
statusClasses.push('yellow-circle');
|
|
416
|
-
} else {
|
|
417
|
-
statusClasses.push('red-circle');
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
let comment = '';
|
|
421
|
-
if (this.#request.cachedInMemory()) {
|
|
422
|
-
comment = i18nString(UIStrings.fromMemoryCache);
|
|
423
|
-
} else if (this.#request.fromEarlyHints()) {
|
|
424
|
-
comment = i18nString(UIStrings.fromEarlyHints);
|
|
425
|
-
} else if (this.#request.fetchedViaServiceWorker) {
|
|
426
|
-
comment = i18nString(UIStrings.fromServiceWorker);
|
|
427
|
-
} else if (this.#request.redirectSourceSignedExchangeInfoHasNoErrors()) {
|
|
428
|
-
comment = i18nString(UIStrings.fromSignedexchange);
|
|
429
|
-
} else if (this.#request.fromPrefetchCache()) {
|
|
430
|
-
comment = i18nString(UIStrings.fromPrefetchCache);
|
|
431
|
-
} else if (this.#request.cached()) {
|
|
432
|
-
comment = i18nString(UIStrings.fromDiskCache);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
if (comment) {
|
|
436
|
-
statusClasses.push('status-with-comment');
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
const statusText = [this.#request.statusCode, this.#request.getInferredStatusText(), comment].join(' ');
|
|
391
|
+
// clang-format on
|
|
392
|
+
}
|
|
440
393
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
loggingContext: 'general',
|
|
446
|
-
// clang-format off
|
|
447
|
-
contents: html`<div jslog=${VisualLogging.section('general')}>
|
|
448
|
-
${this.#renderGeneralRow(i18nString(UIStrings.requestUrl), this.#request.url(), 'request-url')}
|
|
449
|
-
${this.#request.statusCode? this.#renderGeneralRow(i18nString(UIStrings.requestMethod),
|
|
450
|
-
this.#request.requestMethod, 'request-method') : Lit.nothing}
|
|
451
|
-
${this.#request.statusCode? this.#renderGeneralRow(i18nString(UIStrings.statusCode),
|
|
452
|
-
statusText, 'status-code', statusClasses) : Lit.nothing}
|
|
453
|
-
${this.#request.remoteAddress()? this.#renderGeneralRow(i18nString(UIStrings.remoteAddress),
|
|
454
|
-
this.#request.remoteAddress(), 'remote-address') : Lit.nothing}
|
|
455
|
-
${this.#request.referrerPolicy()? this.#renderGeneralRow(i18nString(UIStrings.referrerPolicy),
|
|
456
|
-
String(this.#request.referrerPolicy()), 'referrer-policy') : Lit.nothing}
|
|
457
|
-
</div>`});
|
|
458
|
-
// clang-format on
|
|
459
|
-
}
|
|
394
|
+
function renderRawHeaders(text: string): Lit.TemplateResult {
|
|
395
|
+
return html`<div class="row raw-headers-row"><devtools-widget class=raw-headers .widgetConfig=${
|
|
396
|
+
UI.Widget.widgetConfig(ShowMoreDetailsWidget, {text})}></devtools-widget></div>`;
|
|
397
|
+
}
|
|
460
398
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
399
|
+
function renderGeneralRow(
|
|
400
|
+
input: ViewInput, name: Common.UIString.LocalizedString, value: string, id: string,
|
|
401
|
+
classNames?: string[]): Lit.LitTemplate {
|
|
402
|
+
const isHighlighted = input.toReveal?.section === NetworkForward.UIRequestLocation.UIHeaderSection.GENERAL &&
|
|
403
|
+
name.toLowerCase() === input.toReveal?.header?.toLowerCase();
|
|
404
|
+
return html`
|
|
466
405
|
<div class="row ${isHighlighted ? 'header-highlight' : ''}">
|
|
467
406
|
<div class="header-name">${name}</div>
|
|
468
407
|
<div
|
|
@@ -472,21 +411,9 @@ export class RequestHeadersView extends LegacyWrapper.LegacyWrapper.WrappableCom
|
|
|
472
411
|
>${value}</div>
|
|
473
412
|
</div>
|
|
474
413
|
`;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
getHeaderElementById(id: string): Element|null {
|
|
478
|
-
const categories = this.#shadow.querySelectorAll('devtools-request-headers-category');
|
|
479
|
-
for (const category of categories) {
|
|
480
|
-
const element = category.querySelector(`#${id}`);
|
|
481
|
-
if (element) {
|
|
482
|
-
return element;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
414
|
}
|
|
488
415
|
|
|
489
|
-
function renderCategory(data: {
|
|
416
|
+
export function renderCategory(data: {
|
|
490
417
|
name: string,
|
|
491
418
|
title: Common.UIString.LocalizedString,
|
|
492
419
|
contents: Lit.LitTemplate,
|
|
@@ -555,11 +482,3 @@ function renderCategory(data: {
|
|
|
555
482
|
expandedSetting?.set((event.target as HTMLDetailsElement).open);
|
|
556
483
|
}
|
|
557
484
|
}
|
|
558
|
-
|
|
559
|
-
customElements.define('devtools-request-headers', RequestHeadersView);
|
|
560
|
-
|
|
561
|
-
declare global {
|
|
562
|
-
interface HTMLElementTagNameMap {
|
|
563
|
-
'devtools-request-headers': RequestHeadersView;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
@@ -163,7 +163,7 @@ class ColorSwatchWidget extends CodeMirror.WidgetType {
|
|
|
163
163
|
|
|
164
164
|
toDOM(view: CodeMirror.EditorView): HTMLElement {
|
|
165
165
|
const swatch = new InlineEditor.ColorSwatch.ColorSwatch(i18nString(UIStrings.openColorPicker));
|
|
166
|
-
swatch.
|
|
166
|
+
swatch.renderColor(this.#color);
|
|
167
167
|
const value = swatch.createChild('span');
|
|
168
168
|
value.textContent = this.#text;
|
|
169
169
|
value.setAttribute('hidden', 'true');
|