Bug 1285173 - Netmonitor perf stats: whenDataAvailable should wait for a nonempty request list. r=Honza, a=gchang
authorJarda Snajdr <jsnajdr@gmail.com>
Fri, 11 Nov 2016 16:06:29 +0100
changeset 352519 f96c9373cf0f846ffef9ce0d766991a4a28d8079
parent 352518 0b9eb8d402348f01d04a412f912a5d4c1950349f
child 352520 ea5bb8b2aaa0dad0b47e6f7beb898e46b8b8cb6c
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, gchang
bugs1285173
milestone52.0a2
Bug 1285173 - Netmonitor perf stats: whenDataAvailable should wait for a nonempty request list. r=Honza, a=gchang 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);