Bug 1285173 - Netmonitor perf stats: whenDataAvailable should wait for a nonempty request list r?Honza draft
authorJarda Snajdr <jsnajdr@gmail.com>
Fri, 11 Nov 2016 16:06:29 +0100
changeset 439094 2fed6f37636efc590e78972ab7b6c77a30372d35
parent 438818 5e76768327660437bf3486554ad318e4b70276e1
child 439141 bd42afdc8726ae4f959eed43b6e58c0c6974f5c9
push id35905
push userbmo:jsnajdr@gmail.com
push dateTue, 15 Nov 2016 12:26:31 +0000
reviewersHonza
bugs1285173
milestone53.0a1
Bug 1285173 - Netmonitor perf stats: whenDataAvailable should wait for a nonempty request list r?Honza MozReview-Commit-ID: F4yi7vUdXsM
devtools/client/netmonitor/netmonitor-view.js
--- a/devtools/client/netmonitor/netmonitor-view.js
+++ b/devtools/client/netmonitor/netmonitor-view.js
@@ -228,17 +228,17 @@ var NetMonitorView = {
       yield controller.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED);
 
       try {
         // • The response headers and status code are required for determining
         // whether a response is "fresh" (cacheable).
         // • The response content size and request total time are necessary for
         // populating the statistics view.
         // • The response mime type is used for categorization.
-        yield whenDataAvailable(requestsView.attachments, [
+        yield whenDataAvailable(requestsView, [
           "responseHeaders", "status", "contentSize", "mimeType", "totalTime"
         ]);
       } catch (ex) {
         // Timed out while waiting for data. Continue with what we have.
         console.error(ex);
       }
 
       statisticsView.createPrimedCacheChart(requestsView.items);
@@ -1185,28 +1185,29 @@ NetworkDetailsView.prototype = {
  */
 var $ = (selector, target = document) => target.querySelector(selector);
 var $all = (selector, target = document) => target.querySelectorAll(selector);
 
 /**
  * Makes sure certain properties are available on all objects in a data store.
  *
  * @param array dataStore
- *        A list of objects for which to check the availability of properties.
+ *        The request view object from which to fetch the item list.
  * @param array mandatoryFields
  *        A list of strings representing properties of objects in dataStore.
  * @return object
  *         A promise resolved when all objects in dataStore contain the
  *         properties defined in mandatoryFields.
  */
-function whenDataAvailable(dataStore, mandatoryFields) {
+function whenDataAvailable(requestsView, mandatoryFields) {
   let deferred = promise.defer();
 
   let interval = setInterval(() => {
-    if (dataStore.every(item => {
+    const { attachments } = requestsView;
+    if (attachments.length > 0 && attachments.every(item => {
       return mandatoryFields.every(field => field in item);
     })) {
       clearInterval(interval);
       clearTimeout(timer);
       deferred.resolve();
     }
   }, WDA_DEFAULT_VERIFY_INTERVAL);