Skip to content

Commit 1eb9f5f

Browse files
committed
Bug 1830230 - [devtools] Start sending multiple events as the response data is arrives r=webdriver-reviewers,perftest-reviewers,devtools-reviewers,afinder,jdescottes
Some highlights - Added a new RESPONSE_CONTENT_COMPLETE event - Now fires multiple RESPONSE_CONTENT events Differential Revision: https://phabricator.services.mozilla.com/D244948
1 parent d336828 commit 1eb9f5f

19 files changed

+230
-164
lines changed

devtools/client/netmonitor/src/components/StatusCode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const UPDATED_STATUS_PROPS = [
2424
"fromServiceWorker",
2525
"status",
2626
"statusText",
27+
"blockedReason",
2728
];
2829

2930
/**

devtools/client/netmonitor/src/components/request-list/RequestListColumnTransferredSize.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const UPDATED_TRANSFERRED_PROPS = [
2929
"fromCache",
3030
"isRacing",
3131
"fromServiceWorker",
32+
"blockedReason",
33+
"blockingExtension",
3234
];
3335

3436
class RequestListColumnTransferredSize extends Component {

devtools/client/netmonitor/src/components/request-list/RequestListItem.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ const UPDATED_REQ_ITEM_PROPS = [
173173
"waitingTime",
174174
"isEventStream",
175175
"priority",
176+
"blockedReason",
177+
"blockingExtension",
176178
];
177179

178180
const UPDATED_REQ_PROPS = [

devtools/client/netmonitor/src/utils/request-utils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,23 @@ function fetchNetworkUpdatePacket(requestData, request, updateTypes) {
112112
const promises = [];
113113
if (request) {
114114
updateTypes.forEach(updateType => {
115-
// Only stackTrace will be handled differently
115+
// stackTrace needs to be handled specially as the property to lookup
116+
// on the request object follows a slightly different convention.
117+
// i.e `stacktrace` not `stackTrace`
116118
if (updateType === "stackTrace") {
117119
if (request.cause.stacktraceAvailable && !request.stacktrace) {
118120
promises.push(requestData(request.id, updateType));
119121
}
120122
return;
121123
}
124+
// responseContent only checks the availiability flag as there can
125+
// be multiple response content events
126+
if (updateType === "responseContent") {
127+
if (request.responseContentAvailable) {
128+
promises.push(requestData(request.id, updateType));
129+
}
130+
return;
131+
}
122132

123133
if (request[`${updateType}Available`] && !request[updateType]) {
124134
promises.push(requestData(request.id, updateType));

devtools/client/netmonitor/test/browser_net_chunked-response.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ function setupTestServer() {
4444
}
4545

4646
add_task(async function () {
47-
// TODO: Enable test when Bug 1557795 gets fixed.
48-
// eslint-disable-next-line no-constant-condition
49-
if (true) {
50-
return;
51-
}
5247
const { httpServer, completeResponse } = setupTestServer();
5348
const port = httpServer.identity.primaryPort;
5449

@@ -72,7 +67,7 @@ add_task(async function () {
7267
});
7368
await SpecialPowers.spawn(
7469
tab.linkedBrowser,
75-
`http://localhost:${port}/chunked-data`,
70+
[`http://localhost:${port}/chunked-data`],
7671
async url => {
7772
await content.wrappedJSObject.fetch(url);
7873
}

devtools/client/netmonitor/test/browser_net_domain-not-found.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Tests that the request for a domain that is not found shows
88
* correctly.
99
*/
10+
1011
add_task(async function () {
1112
const URL = "https://not-existed.com/";
1213
const { monitor } = await initNetMonitor(URL, {
@@ -31,10 +32,7 @@ add_task(async function () {
3132
const value = firstItem.querySelector(
3233
".requests-list-transferred"
3334
).innerText;
34-
if (value == "") {
35-
return false;
36-
}
37-
return value;
35+
return value.includes("NS_ERROR") ? value : false;
3836
});
3937

4038
is(

devtools/client/netmonitor/test/browser_net_sse-basic.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,6 @@ add_task(async function testBasicServerSentEvents() {
213213
* 3) Assert that the close connection message is displayed when the connection is closed.
214214
*/
215215
add_task(async function testServerSentEventsDetails() {
216-
// TODO: Should enable this test when Bug 1557795 gets fixed.
217-
// eslint-disable-next-line no-constant-condition
218-
if (true) {
219-
return null;
220-
}
221216
const { httpServer, sendResponseMessages, completeResponse } =
222217
setupTestServer();
223218
const port = httpServer.identity.primaryPort;
@@ -279,7 +274,7 @@ add_task(async function testServerSentEventsDetails() {
279274
const waitForMoreMessages = waitForDOM(
280275
document,
281276
"#messages-view .message-list-table .message-list-item",
282-
3
277+
4
283278
);
284279
info("Send a couple of more messages");
285280
sendResponseMessages();

devtools/server/actors/network-monitor/network-event-actor.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,14 +638,33 @@ class NetworkEventActor extends Actor {
638638
});
639639
}
640640

641+
/**
642+
* Add network response content end.
643+
*
644+
* @param object
645+
*/
646+
addResponseContentComplete({ blockedReason, blockingExtension }) {
647+
// Ignore calls when this actor is already destroyed
648+
if (this.isDestroyed()) {
649+
return;
650+
}
651+
652+
this._onEventUpdate(
653+
lazy.NetworkUtils.NETWORK_EVENT_TYPES.RESPONSE_CONTENT_COMPLETE,
654+
{
655+
blockedReason,
656+
blockingExtension,
657+
}
658+
);
659+
}
660+
641661
/**
642662
* Add network response content.
643663
*
644664
* @param object content
645665
* The response content.
646-
* @param object
647666
*/
648-
addResponseContent(content, { blockedReason, blockingExtension }) {
667+
addResponseContent(content) {
649668
// Ignore calls when this actor is already destroyed
650669
if (this.isDestroyed()) {
651670
return;
@@ -664,8 +683,6 @@ class NetworkEventActor extends Actor {
664683
mimeType: content.mimeType,
665684
contentSize: content.size,
666685
transferredSize: content.transferredSize,
667-
blockedReason,
668-
blockingExtension,
669686
}
670687
);
671688
}

devtools/server/actors/resources/network-events-content.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,13 @@ class NetworkEventContentWatcher {
231231
{} /* offsets */
232232
);
233233
networkEventActor.addServerTimings({});
234-
networkEventActor.addResponseContent(
235-
{
236-
mimeType: channel.contentType,
237-
size: channel.contentLength,
238-
text: "",
239-
transferredSize: 0,
240-
},
241-
{}
242-
);
234+
networkEventActor.addResponseContent({
235+
mimeType: channel.contentType,
236+
size: channel.contentLength,
237+
text: "",
238+
transferredSize: 0,
239+
});
240+
networkEventActor.addResponseContentComplete({});
243241
} else if (type == RESOURCE_TYPES.DATA_CHANNEL) {
244242
lazy.NetworkUtils.handleDataChannel(channel, networkEventActor);
245243
}
@@ -301,7 +299,7 @@ class NetworkEventContentWatcher {
301299
// responseContent.
302300
const isResponseComplete =
303301
receivedUpdates.includes(NETWORK_EVENT_TYPES.RESPONSE_START) &&
304-
receivedUpdates.includes(NETWORK_EVENT_TYPES.RESPONSE_CONTENT) &&
302+
receivedUpdates.includes(NETWORK_EVENT_TYPES.RESPONSE_CONTENT_COMPLETE) &&
305303
receivedUpdates.includes(NETWORK_EVENT_TYPES.EVENT_TIMINGS);
306304

307305
if (isResponseComplete) {
@@ -314,6 +312,7 @@ class NetworkEventContentWatcher {
314312

315313
if (
316314
updateResource.updateType == NETWORK_EVENT_TYPES.RESPONSE_START ||
315+
updateResource.updateType == NETWORK_EVENT_TYPES.RESPONSE_CONTENT ||
317316
isResponseComplete
318317
) {
319318
this._emitUpdate(networkEvent);

devtools/server/actors/resources/network-events.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ class NetworkEventWatcher {
403403
resourceUpdates.contentSize = updateResource.contentSize;
404404
resourceUpdates.transferredSize = updateResource.transferredSize;
405405
resourceUpdates.mimeType = updateResource.mimeType;
406+
break;
407+
case NETWORK_EVENT_TYPES.RESPONSE_CONTENT_COMPLETE:
406408
resourceUpdates.blockingExtension = updateResource.blockingExtension;
407409
resourceUpdates.blockedReason = updateResource.blockedReason;
408410
break;
@@ -423,7 +425,7 @@ class NetworkEventWatcher {
423425

424426
const isResponseComplete =
425427
receivedUpdates.includes(NETWORK_EVENT_TYPES.EVENT_TIMINGS) &&
426-
receivedUpdates.includes(NETWORK_EVENT_TYPES.RESPONSE_CONTENT) &&
428+
receivedUpdates.includes(NETWORK_EVENT_TYPES.RESPONSE_CONTENT_COMPLETE) &&
427429
receivedUpdates.includes(NETWORK_EVENT_TYPES.SECURITY_INFO);
428430

429431
if (isResponseComplete) {
@@ -436,6 +438,7 @@ class NetworkEventWatcher {
436438

437439
if (
438440
updateResource.updateType == NETWORK_EVENT_TYPES.RESPONSE_START ||
441+
updateResource.updateType == NETWORK_EVENT_TYPES.RESPONSE_CONTENT ||
439442
isResponseComplete
440443
) {
441444
this._emitUpdate(networkEvent);

0 commit comments

Comments
 (0)