Bug 1358054 - combine double updateRequest call while receive event in _onNetworkEventUpdate;
MozReview-Commit-ID: 7cyDQT6Rz6O
--- a/devtools/client/netmonitor/src/netmonitor-controller.js
+++ b/devtools/client/netmonitor/src/netmonitor-controller.js
@@ -300,18 +300,16 @@ function NetworkEventsHandler() {
this._onNetworkEvent = this._onNetworkEvent.bind(this);
this._onNetworkEventUpdate = this._onNetworkEventUpdate.bind(this);
this._onDocLoadingMarker = this._onDocLoadingMarker.bind(this);
this._onRequestHeaders = this._onRequestHeaders.bind(this);
this._onRequestCookies = this._onRequestCookies.bind(this);
this._onRequestPostData = this._onRequestPostData.bind(this);
this._onResponseHeaders = this._onResponseHeaders.bind(this);
this._onResponseCookies = this._onResponseCookies.bind(this);
- this._onSecurityInfo = this._onSecurityInfo.bind(this);
- this._onEventTimings = this._onEventTimings.bind(this);
}
NetworkEventsHandler.prototype = {
get client() {
return NetMonitorController._target.client;
},
get webConsoleClient() {
@@ -610,22 +608,22 @@ NetworkEventsHandler.prototype = {
window.emit(EVENTS.UPDATING_REQUEST_COOKIES, actor);
break;
case "requestPostData":
this.webConsoleClient.getRequestPostData(actor,
this._onRequestPostData);
window.emit(EVENTS.UPDATING_REQUEST_POST_DATA, actor);
break;
case "securityInfo":
- this.updateRequest(actor, {
- securityState: networkInfo.securityInfo,
- }).then(() => {
- this.webConsoleClient.getSecurityInfo(actor, this._onSecurityInfo);
- window.emit(EVENTS.UPDATING_SECURITY_INFO, actor);
- });
+ this.webConsoleClient.getSecurityInfo(actor,
+ this._onSecurityInfo.bind(this, {
+ securityState: networkInfo.securityInfo,
+ })
+ );
+ window.emit(EVENTS.UPDATING_SECURITY_INFO, actor);
break;
case "responseHeaders":
this.webConsoleClient.getResponseHeaders(actor,
this._onResponseHeaders);
window.emit(EVENTS.UPDATING_RESPONSE_HEADERS, actor);
break;
case "responseCookies":
this.webConsoleClient.getResponseCookies(actor,
@@ -649,22 +647,22 @@ NetworkEventsHandler.prototype = {
this._onResponseContent.bind(this, {
contentSize: networkInfo.response.bodySize,
transferredSize: networkInfo.response.transferredSize,
mimeType: networkInfo.response.content.mimeType
}));
window.emit(EVENTS.UPDATING_RESPONSE_CONTENT, actor);
break;
case "eventTimings":
- this.updateRequest(actor, {
- totalTime: networkInfo.totalTime
- }).then(() => {
- this.webConsoleClient.getEventTimings(actor, this._onEventTimings);
- window.emit(EVENTS.UPDATING_EVENT_TIMINGS, actor);
- });
+ this.webConsoleClient.getEventTimings(actor,
+ this._onEventTimings.bind(this, {
+ totalTime: networkInfo.totalTime
+ })
+ );
+ window.emit(EVENTS.UPDATING_EVENT_TIMINGS, actor);
break;
}
},
/**
* Handles additional information received for a "requestHeaders" packet.
*
* @param object response
@@ -704,23 +702,26 @@ NetworkEventsHandler.prototype = {
}).then(() => {
window.emit(EVENTS.RECEIVED_REQUEST_POST_DATA, response.from);
});
},
/**
* Handles additional information received for a "securityInfo" packet.
*
+ * @param object data
+ * The message received from the server event.
* @param object response
* The message received from the server.
*/
- _onSecurityInfo: function (response) {
- this.updateRequest(response.from, {
+ _onSecurityInfo: function (data, response) {
+ let payload = Object.assign({
securityInfo: response.securityInfo
- }).then(() => {
+ }, data);
+ this.updateRequest(response.from, payload).then(() => {
window.emit(EVENTS.RECEIVED_SECURITY_INFO, response.from);
});
},
/**
* Handles additional information received for a "responseHeaders" packet.
*
* @param object response
@@ -761,21 +762,22 @@ NetworkEventsHandler.prototype = {
this.updateRequest(response.from, payload).then(() => {
window.emit(EVENTS.RECEIVED_RESPONSE_CONTENT, response.from);
});
},
/**
* Handles additional information received for a "eventTimings" packet.
*
+ * @param object data
+ * The message received from the server event.
* @param object response
* The message received from the server.
*/
- _onEventTimings: function (response) {
- this.updateRequest(response.from, {
- eventTimings: response
- }).then(() => {
+ _onEventTimings: function (data, response) {
+ let payload = Object.assign({ eventTimings: response }, data);
+ this.updateRequest(response.from, payload).then(() => {
window.emit(EVENTS.RECEIVED_EVENT_TIMINGS, response.from);
});
}
};
exports.NetMonitorController = NetMonitorController;
--- a/devtools/client/netmonitor/test/browser_net_simple-request-data.js
+++ b/devtools/client/netmonitor/test/browser_net_simple-request-data.js
@@ -271,38 +271,21 @@ function test() {
});
monitor.panelWin.once(EVENTS.UPDATING_EVENT_TIMINGS, async () => {
await waitUntil(() => {
let requestItem = getSortedRequests(gStore.getState()).get(0);
return requestItem.eventTimings;
});
- let requestItem = getSortedRequests(gStore.getState()).get(0);
-
is(typeof requestItem.totalTime, "number",
"The attached totalTime is incorrect.");
ok(requestItem.totalTime >= 0,
"The attached totalTime should be positive.");
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(gStore.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS,
- {
- time: true
- }
- );
- });
-
- monitor.panelWin.once(EVENTS.RECEIVED_EVENT_TIMINGS, () => {
- let requestItem = getSortedRequests(gStore.getState()).get(0);
-
ok(requestItem.eventTimings,
"There should be a eventTimings data available.");
is(typeof requestItem.eventTimings.timings.blocked, "number",
"The eventTimings data has an incorrect |timings.blocked| property.");
is(typeof requestItem.eventTimings.timings.dns, "number",
"The eventTimings data has an incorrect |timings.dns| property.");
is(typeof requestItem.eventTimings.timings.connect, "number",
"The eventTimings data has an incorrect |timings.connect| property.");