зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1578215 - DAMP Perf regression in netmonitor har export test (+12%); r=nchevobbe,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D44437 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
77681b7832
Коммит
e5d8c5ba59
|
@ -20,6 +20,8 @@ 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 +230,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,6 +523,8 @@ 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.
|
||||
// Note that this event might be consumed by extension so, emit it in production
|
||||
// release as well.
|
||||
this.emit(EVENTS.PAYLOAD_READY, actor);
|
||||
}
|
||||
|
||||
|
@ -603,7 +605,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 +653,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 +666,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 +679,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 +692,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 +705,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 +718,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 +730,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 +747,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,6 +760,11 @@ class FirefoxDataProvider {
|
|||
const payload = await this.updateRequest(response.from, {
|
||||
eventTimings: response,
|
||||
});
|
||||
|
||||
// This event is utilized only in tests but, DAMP is using it too
|
||||
// and running DAMP test doesn't set the `devtools.testing` flag.
|
||||
// So, emit this event even in the production mode.
|
||||
// See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1578215
|
||||
this.emit(EVENTS.RECEIVED_EVENT_TIMINGS, response.from);
|
||||
return payload.eventTimings;
|
||||
}
|
||||
|
@ -771,7 +778,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -783,6 +790,16 @@ class FirefoxDataProvider {
|
|||
this.owner.emit(type, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire test events for the owner object. These events are
|
||||
* emitted only when tests are running.
|
||||
*/
|
||||
emitForTests(type, data) {
|
||||
if (this.owner) {
|
||||
this.owner.emitForTests(type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FirefoxDataProvider;
|
||||
|
|
Загрузка…
Ссылка в новой задаче