Bug 1421335 - Right response info link disappears after request is expanded; r=nchevobbe
authorJan Odvarko <odvarko@gmail.com>
Thu, 07 Dec 2017 16:28:33 +0100
changeset 449605 eaf338dcf3ea3a1c4c3644cc4a1a2c2c988cbd9f
parent 449604 99914fd768522fe45160f171966a5efc65c59cc2
child 449606 787fbdc766c4b069b4779f79c09f22999889100e
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1421335
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1421335 - Right response info link disappears after request is expanded; r=nchevobbe MozReview-Commit-ID: 5WEqPQaWGGt
devtools/client/netmonitor/src/connector/firefox-data-provider.js
devtools/client/webconsole/new-console-output/reducers/messages.js
devtools/client/webconsole/new-console-output/store.js
--- a/devtools/client/netmonitor/src/connector/firefox-data-provider.js
+++ b/devtools/client/netmonitor/src/connector/firefox-data-provider.js
@@ -336,17 +336,23 @@ class FirefoxDataProvider {
       case "responseContent":
         this.pushRequestToQueue(actor, {
           contentSize: networkInfo.response.bodySize,
           transferredSize: networkInfo.response.transferredSize,
           mimeType: networkInfo.response.content.mimeType,
         });
         break;
       case "eventTimings":
-        this.pushRequestToQueue(actor, { totalTime: networkInfo.totalTime });
+        // Total time doesn't have to be always set e.g. net provider enhancer
+        // in Console panel is using this method to fetch data when network log
+        // is expanded. So, make sure to not push undefined into the payload queue
+        // (it could overwrite an existing value).
+        if (typeof networkInfo.totalTime != "undefined") {
+          this.pushRequestToQueue(actor, { totalTime: networkInfo.totalTime });
+        }
         await this._requestData(actor, updateType);
         break;
     }
 
     // This available field helps knowing when/if updateType property is arrived
     // and can be requested via `requestData`
     this.pushRequestToQueue(actor, { [`${updateType}Available`]: true });
 
--- a/devtools/client/webconsole/new-console-output/reducers/messages.js
+++ b/devtools/client/webconsole/new-console-output/reducers/messages.js
@@ -60,16 +60,17 @@ function addMessage(state, filtersState,
   const {
     messagesById,
     messagesUiById,
     groupsById,
     currentGroup,
     repeatById,
     visibleMessages,
     filteredMessagesCount,
+    networkMessagesUpdateById,
   } = state;
 
   if (newMessage.type === constants.MESSAGE_TYPE.NULL_MESSAGE) {
     // When the message has a NULL type, we don't add it.
     return state;
   }
 
   if (newMessage.type === constants.MESSAGE_TYPE.END_GROUP) {
@@ -131,16 +132,24 @@ function addMessage(state, filtersState,
   } else if (DEFAULT_FILTERS.includes(cause)) {
     newState.filteredMessagesCount = {
       ...filteredMessagesCount,
       global: filteredMessagesCount.global + 1,
       [cause]: filteredMessagesCount[cause] + 1
     };
   }
 
+  // Append received network-data also into networkMessagesUpdateById
+  // that is responsible for collecting (lazy loaded) HTTP payload data.
+  if (newMessage.source == "network") {
+    newState.networkMessagesUpdateById = Object.assign({}, networkMessagesUpdateById, {
+      [newMessage.actor]: newMessage
+    });
+  }
+
   return newState;
 }
 
 function messages(state = MessageState(), action, filtersState, prefsState) {
   const {
     messagesById,
     messagesUiById,
     messagesTableDataById,
--- a/devtools/client/webconsole/new-console-output/store.js
+++ b/devtools/client/webconsole/new-console-output/store.js
@@ -193,35 +193,19 @@ function enableNetProvider(hud) {
       let newState = reducer(state, action);
 
       // If network message has been opened, fetch all HTTP details
       // from the backend. It can happen (especially in test) that
       // the message is opened before all network event updates are
       // received. The rest of updates will be handled below, see:
       // NETWORK_MESSAGE_UPDATE action handler.
       if (type == MESSAGE_OPEN) {
-        let message = getMessage(state, action.id);
+        let updates = getAllNetworkMessagesUpdateById(newState);
+        let message = updates[action.id];
         if (!message.openedOnce && message.source == "network") {
-          let updates = getAllNetworkMessagesUpdateById(newState);
-
-          // If there is no network request update received for this
-          // request-log, it's likely that it comes from cache.
-          // I.e. it's been executed before the console panel started
-          // listening from network events. Let fix that by updating
-          // the reducer now.
-          // Executing the reducer means that the `networkMessagesUpdateById`
-          // is updated (a actor key created). The key is needed for proper
-          // handling NETWORK_UPDATE_REQUEST event (in the same reducer).
-          if (!updates[action.id]) {
-            newState = reducer(newState, {
-              type: NETWORK_MESSAGE_UPDATE,
-              message: message,
-            });
-          }
-
           dataProvider.onNetworkEvent(null, message);
           message.updates.forEach(updateType => {
             dataProvider.onNetworkEventUpdate(null, {
               packet: { updateType: updateType },
               networkInfo: message,
             });
           });
         }