Skip to content

Commit 33225e4

Browse files
vkrot-cellDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
DirectSocket TCP panel #2
On click NetworkLogItem of type DirectSocket now a new set of tabs is opened: ConnectionInfo, Initiator, Timing The related commit in chromium - https://chromium-review.googlesource.com/c/chromium/src/+/6308994 The previous commit in devtools that add NetworkManager logic - https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6316791/20 Design Document: go/chrome-devtools:directsockets-design How the UI looks like: 1. Direct Socket connection in Network manager log: https://screenshot.googleplex.com/6oorNNBQW3TWvWx.png. 2. Connection info tab Opening state: https://screenshot.googleplex.com/6SeiiJb5vQyVHKh.png. 3. Initiator tab: https://screenshot.googleplex.com/AXaNjTaX2MqJVGx.png. 4. Timing tab: https://screenshot.googleplex.com/3tofCoEdAat4tuC.png. Change-Id: I70ab6e80a163d39c287ac5e35293346e37239db4 Bug: 358327120 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6406321 Reviewed-by: Danil Somsikov <[email protected]> Reviewed-by: Changhao Han <[email protected]> Commit-Queue: Vlad Krot <[email protected]>
1 parent 9481306 commit 33225e4

14 files changed

+611
-13
lines changed

config/gni/devtools_grd_files.gni

+1
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,7 @@ grd_files_debug_sources = [
16221622
"front_end/panels/network/SignedExchangeInfoView.js",
16231623
"front_end/panels/network/binaryResourceView.css.js",
16241624
"front_end/panels/network/blockedURLsPane.css.js",
1625+
"front_end/panels/network/components/DirectSocketConnectionView.js",
16251626
"front_end/panels/network/components/EditableSpan.css.js",
16261627
"front_end/panels/network/components/EditableSpan.js",
16271628
"front_end/panels/network/components/HeaderSectionRow.css.js",

front_end/panels/network/NetworkDataGridNode.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,8 @@ export class NetworkRequestNode extends NetworkNode {
12391239
const statusText = this.requestInternal.getInferredStatusText();
12401240
this.appendSubtitle(cell, statusText);
12411241
UI.Tooltip.Tooltip.install(cell, this.requestInternal.statusCode + ' ' + statusText);
1242+
} else if (this.requestInternal.statusText) {
1243+
this.setTextAndTitle(cell, this.requestInternal.statusText);
12421244
} else if (this.requestInternal.finished) {
12431245
this.setTextAndTitle(cell, i18nString(UIStrings.finished));
12441246
} else if (this.requestInternal.preserved) {

front_end/panels/network/NetworkItemView.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import * as Common from '../../core/common/common.js';
56
import * as Platform from '../../core/platform/platform.js';
67
import * as SDK from '../../core/sdk/sdk.js';
78
import type * as Protocol from '../../generated/protocol.js';
@@ -53,6 +54,7 @@ describeWithMockConnection('NetworkItemView', () => {
5354
it('reveals header in RequestHeadersView', async () => {
5455
const networkItemView = renderNetworkItemView();
5556
const headersViewComponent = networkItemView.getHeadersViewComponent();
57+
assert.exists(headersViewComponent);
5658
const headersViewComponentSpy = sinon.spy(headersViewComponent, 'revealHeader');
5759

5860
assert.isTrue(headersViewComponentSpy.notCalled);
@@ -139,4 +141,29 @@ describeWithEnvironment('NetworkItemView', () => {
139141

140142
networkItemView.detach();
141143
});
144+
145+
it('shows the ConnectionInfo tab for DirectSocket requests', () => {
146+
request.setResourceType(Common.ResourceType.resourceTypes.DirectSocket);
147+
request.directSocketInfo = {
148+
type: SDK.NetworkRequest.DirectSocketType.TCP,
149+
status: SDK.NetworkRequest.DirectSocketStatus.OPENING,
150+
createOptions: {
151+
remoteAddr: '127.0.0.1',
152+
remotePort: 2545,
153+
noDelay: false,
154+
keepAliveDelay: 1000,
155+
sendBufferSize: 1002,
156+
receiveBufferSize: 1003,
157+
dnsQueryType: undefined,
158+
}
159+
};
160+
161+
const networkItemView = renderNetworkItemView(request);
162+
163+
assert.isTrue(networkItemView.hasTab(NetworkForward.UIRequestLocation.UIRequestTabs.DIRECT_SOCKET_CONNECTION));
164+
assert.isTrue(networkItemView.hasTab(NetworkForward.UIRequestLocation.UIRequestTabs.INITIATOR));
165+
assert.isTrue(networkItemView.hasTab(NetworkForward.UIRequestLocation.UIRequestTabs.TIMING));
166+
167+
networkItemView.detach();
168+
});
142169
});

front_end/panels/network/NetworkItemView.ts

+26-12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const UIStrings = {
5757
*@description Text for network request headers
5858
*/
5959
headers: 'Headers',
60+
/**
61+
*@description Text for network connection info. In case the request is not made over http.
62+
*/
63+
connectionInfo: 'Connection Info',
6064
/**
6165
*@description Text in Network Item View of the Network panel
6266
*/
@@ -147,11 +151,12 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
147151
export class NetworkItemView extends UI.TabbedPane.TabbedPane {
148152
private requestInternal: SDK.NetworkRequest.NetworkRequest;
149153
private readonly resourceViewTabSetting: Common.Settings.Setting<NetworkForward.UIRequestLocation.UIRequestTabs>;
150-
private readonly headersViewComponent: NetworkComponents.RequestHeadersView.RequestHeadersView;
154+
private readonly headersViewComponent: NetworkComponents.RequestHeadersView.RequestHeadersView|undefined;
151155
private payloadView: RequestPayloadView|null;
152156
private readonly responseView: RequestResponseView|undefined;
153157
private cookiesView: RequestCookiesView|null;
154158
private initialTab?: NetworkForward.UIRequestLocation.UIRequestTabs;
159+
private readonly firstTab: NetworkForward.UIRequestLocation.UIRequestTabs;
155160

156161
constructor(
157162
request: SDK.NetworkRequest.NetworkRequest, calculator: NetworkTimeCalculator,
@@ -163,15 +168,22 @@ export class NetworkItemView extends UI.TabbedPane.TabbedPane {
163168
keydown: 'ArrowUp|ArrowLeft|ArrowDown|ArrowRight|Enter|Space',
164169
})}`);
165170

166-
const headersTab = NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT;
167-
this.resourceViewTabSetting = Common.Settings.Settings.instance().createSetting(
168-
'resource-view-tab', NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT);
171+
if (request.resourceType() === Common.ResourceType.resourceTypes.DirectSocket) {
172+
this.firstTab = NetworkForward.UIRequestLocation.UIRequestTabs.DIRECT_SOCKET_CONNECTION;
173+
this.appendTab(
174+
NetworkForward.UIRequestLocation.UIRequestTabs.DIRECT_SOCKET_CONNECTION, i18nString(UIStrings.connectionInfo),
175+
new NetworkComponents.DirectSocketConnectionView.DirectSocketConnectionView(request),
176+
i18nString(UIStrings.headers));
177+
} else {
178+
this.firstTab = NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT;
179+
this.headersViewComponent = new NetworkComponents.RequestHeadersView.RequestHeadersView(request);
180+
this.appendTab(
181+
NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT, i18nString(UIStrings.headers),
182+
LegacyWrapper.LegacyWrapper.legacyWrapper(UI.Widget.VBox, this.headersViewComponent),
183+
i18nString(UIStrings.headers));
184+
}
169185

170-
this.headersViewComponent = new NetworkComponents.RequestHeadersView.RequestHeadersView(request);
171-
this.appendTab(
172-
headersTab, i18nString(UIStrings.headers),
173-
LegacyWrapper.LegacyWrapper.legacyWrapper(UI.Widget.VBox, this.headersViewComponent),
174-
i18nString(UIStrings.headers));
186+
this.resourceViewTabSetting = Common.Settings.Settings.instance().createSetting('resource-view-tab', this.firstTab);
175187

176188
if (this.requestInternal.hasOverriddenHeaders()) {
177189
const statusDot = document.createElement('div');
@@ -190,6 +202,8 @@ export class NetworkItemView extends UI.TabbedPane.TabbedPane {
190202
this.appendTab(
191203
NetworkForward.UIRequestLocation.UIRequestTabs.WS_FRAMES, i18nString(UIStrings.messages), frameView,
192204
i18nString(UIStrings.websocketMessages));
205+
} else if (request.resourceType() === Common.ResourceType.resourceTypes.DirectSocket) {
206+
// TODO(@vkrot): add direct socket messages tab
193207
} else if (request.mimeType === Platform.MimeType.MimeType.EVENTSTREAM) {
194208
this.appendTab(
195209
NetworkForward.UIRequestLocation.UIRequestTabs.EVENT_SOURCE, i18nString(UIStrings.eventstream),
@@ -328,7 +342,7 @@ export class NetworkItemView extends UI.TabbedPane.TabbedPane {
328342
// it makes sense to retry on the next tick
329343
window.setTimeout(() => {
330344
if (!this.selectTab(tabId)) {
331-
this.selectTab(NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT);
345+
this.selectTab(this.firstTab);
332346
}
333347
}, 0);
334348
}
@@ -352,10 +366,10 @@ export class NetworkItemView extends UI.TabbedPane.TabbedPane {
352366

353367
revealHeader(section: NetworkForward.UIRequestLocation.UIHeaderSection, header: string|undefined): void {
354368
this.selectTabInternal(NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT);
355-
this.headersViewComponent.revealHeader(section, header);
369+
this.headersViewComponent?.revealHeader(section, header);
356370
}
357371

358-
getHeadersViewComponent(): NetworkComponents.RequestHeadersView.RequestHeadersView {
372+
getHeadersViewComponent(): NetworkComponents.RequestHeadersView.RequestHeadersView|undefined {
359373
return this.headersViewComponent;
360374
}
361375
}

front_end/panels/network/components/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ generate_css("css_files") {
2222

2323
devtools_module("components") {
2424
sources = [
25+
"DirectSocketConnectionView.ts",
2526
"EditableSpan.ts",
2627
"HeaderSectionRow.ts",
2728
"RequestHeaderSection.ts",
@@ -76,6 +77,7 @@ devtools_entrypoint("bundle") {
7677
ts_library("unittests") {
7778
testonly = true
7879
sources = [
80+
"DirectSocketConnectionView.test.ts",
7981
"HeaderSectionRow.test.ts",
8082
"RequestHeaderSection.test.ts",
8183
"RequestHeadersView.test.ts",

0 commit comments

Comments
 (0)