Bug 1578215 - DAMP Perf regression in netmonitor har export test (+12%); r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D44437

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Odvarko 2019-09-05 17:43:23 +00:00
Родитель 3d0ca8182e
Коммит dfef1c3407
3 изменённых файлов: 41 добавлений и 24 удалений

Просмотреть файл

@ -20,6 +20,12 @@ const {
getSortedRequests,
} = require("./selectors/index");
loader.lazyRequireGetter(
this,
"flags",
"devtools/shared/flags"
);
/**
* API object for NetMonitor panel (like a facade). This object can be
* consumed by other panels, WebExtension API, etc.
@ -228,6 +234,16 @@ NetMonitorAPI.prototype = {
// with the given requestId.
this.store.dispatch(Actions.sendCustomRequest(this.connector, requestId));
},
/**
* Fire events for the owner object. These events are only
* used in tests so, don't fire them in production release.
*/
emitForTests(type, data) {
if (flags.testing) {
this.emit(type, data);
}
},
};
exports.NetMonitorAPI = NetMonitorAPI;

Просмотреть файл

@ -275,7 +275,7 @@ class FirefoxConnector {
this.actions.addTimingMarker(event);
}
this.emit(EVENTS.TIMELINE_EVENT, event);
this.emitForTests(EVENTS.TIMELINE_EVENT, event);
}
/**
@ -466,15 +466,16 @@ class FirefoxConnector {
});
}
this.emit(EVENTS.THROTTLING_CHANGED, { profile });
this.emitForTests(EVENTS.THROTTLING_CHANGED, { profile });
}
/**
* Fire events for the owner object.
* Fire events for the owner object. These events are only
* used in tests so, don't fire them in production release.
*/
emit(type, data) {
emitForTests(type, data) {
if (this.owner) {
this.owner.emit(type, data);
this.owner.emitForTests(type, data);
}
}
}

Просмотреть файл

@ -115,7 +115,7 @@ class FirefoxDataProvider {
);
}
this.emit(EVENTS.REQUEST_ADDED, id);
this.emitForTests(EVENTS.REQUEST_ADDED, id);
}
/**
@ -342,7 +342,7 @@ class FirefoxDataProvider {
*/
getLongString(stringGrip) {
return this.webConsoleClient.getString(stringGrip).then(payload => {
this.emit(EVENTS.LONGSTRING_RESOLVED, { payload });
this.emitForTests(EVENTS.LONGSTRING_RESOLVED, { payload });
return payload;
});
}
@ -381,7 +381,7 @@ class FirefoxDataProvider {
channelId,
});
this.emit(EVENTS.NETWORK_EVENT, actor);
this.emitForTests(EVENTS.NETWORK_EVENT, actor);
}
/**
@ -411,7 +411,7 @@ class FirefoxDataProvider {
statusText: networkInfo.response.statusText,
headersSize: networkInfo.response.headersSize,
});
this.emit(EVENTS.STARTED_RECEIVING_RESPONSE, actor);
this.emitForTests(EVENTS.STARTED_RECEIVING_RESPONSE, actor);
break;
case "responseContent":
this.pushRequestToQueue(actor, {
@ -437,7 +437,7 @@ class FirefoxDataProvider {
this.onPayloadDataReceived(actor);
this.emit(EVENTS.NETWORK_EVENT_UPDATED, actor);
this.emitForTests(EVENTS.NETWORK_EVENT_UPDATED, actor);
}
/**
@ -523,7 +523,7 @@ class FirefoxDataProvider {
// This event is fired only once per request, once all the properties are fetched
// from `onNetworkEventUpdate`. There should be no more RDP requests after this.
this.emit(EVENTS.PAYLOAD_READY, actor);
this.emitForTests(EVENTS.PAYLOAD_READY, actor);
}
/**
@ -603,7 +603,7 @@ class FirefoxDataProvider {
.toUpperCase()}`;
// Emit event that tell we just start fetching some data
this.emit(EVENTS[updatingEventName], actor);
this.emitForTests(EVENTS[updatingEventName], actor);
let response = await new Promise((resolve, reject) => {
// Do a RDP request to fetch data from the actor.
@ -651,7 +651,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
requestHeaders: response,
});
this.emit(EVENTS.RECEIVED_REQUEST_HEADERS, response.from);
this.emitForTests(EVENTS.RECEIVED_REQUEST_HEADERS, response.from);
return payload.requestHeaders;
}
@ -664,7 +664,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
responseHeaders: response,
});
this.emit(EVENTS.RECEIVED_RESPONSE_HEADERS, response.from);
this.emitForTests(EVENTS.RECEIVED_RESPONSE_HEADERS, response.from);
return payload.responseHeaders;
}
@ -677,7 +677,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
requestCookies: response,
});
this.emit(EVENTS.RECEIVED_REQUEST_COOKIES, response.from);
this.emitForTests(EVENTS.RECEIVED_REQUEST_COOKIES, response.from);
return payload.requestCookies;
}
@ -690,7 +690,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
requestPostData: response,
});
this.emit(EVENTS.RECEIVED_REQUEST_POST_DATA, response.from);
this.emitForTests(EVENTS.RECEIVED_REQUEST_POST_DATA, response.from);
return payload.requestPostData;
}
@ -703,7 +703,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
securityInfo: response.securityInfo,
});
this.emit(EVENTS.RECEIVED_SECURITY_INFO, response.from);
this.emitForTests(EVENTS.RECEIVED_SECURITY_INFO, response.from);
return payload.securityInfo;
}
@ -716,7 +716,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
responseCookies: response,
});
this.emit(EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
this.emitForTests(EVENTS.RECEIVED_RESPONSE_COOKIES, response.from);
return payload.responseCookies;
}
@ -728,7 +728,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
responseCache: response,
});
this.emit(EVENTS.RECEIVED_RESPONSE_CACHE, response.from);
this.emitForTests(EVENTS.RECEIVED_RESPONSE_CACHE, response.from);
return payload.responseCache;
}
@ -745,7 +745,7 @@ class FirefoxDataProvider {
mimeType: response.content.mimeType,
responseContent: response,
});
this.emit(EVENTS.RECEIVED_RESPONSE_CONTENT, response.from);
this.emitForTests(EVENTS.RECEIVED_RESPONSE_CONTENT, response.from);
return payload.responseContent;
}
@ -758,7 +758,7 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
eventTimings: response,
});
this.emit(EVENTS.RECEIVED_EVENT_TIMINGS, response.from);
this.emitForTests(EVENTS.RECEIVED_EVENT_TIMINGS, response.from);
return payload.eventTimings;
}
@ -771,16 +771,16 @@ class FirefoxDataProvider {
const payload = await this.updateRequest(response.from, {
stacktrace: response.stacktrace,
});
this.emit(EVENTS.RECEIVED_EVENT_STACKTRACE, response.from);
this.emitForTests(EVENTS.RECEIVED_EVENT_STACKTRACE, response.from);
return payload.stacktrace;
}
/**
* Fire events for the owner object.
*/
emit(type, data) {
emitForTests(type, data) {
if (this.owner) {
this.owner.emit(type, data);
this.owner.emitForTests(type, data);
}
}
}