Bug 1285173 - Netmonitor perf stats: whenDataAvailable should wait for a nonempty request list r?Honza
MozReview-Commit-ID: F4yi7vUdXsM
--- 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);