Bug 1425273 - Waiting for event timings in damp test r?ochameau
MozReview-Commit-ID: A2YgZafM0Jv
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -781,42 +781,55 @@ async _consoleOpenWithCachedMessagesTest
*/
waitForAllRequestsFinished() {
let tab = getActiveTab(getMostRecentBrowserWindow());
let target = TargetFactory.forTab(tab);
let toolbox = gDevTools.getToolbox(target);
let window = toolbox.getCurrentPanel().panelWin;
return new Promise(resolve => {
- // Key is the request id, value is a boolean - is request finished or not?
- let requests = new Map();
+ let requests = new Set();
+ let timings = new Set();
- function onRequest(_, id) {
- requests.set(id, false);
+ function onRequestAdded(_, id) {
+ requests.add(id);
}
function onPayloadReady(_, id) {
- requests.set(id, true);
+ requests.delete(id);
+ maybeResolve();
+ }
+
+ function onTimingsUpdating(_, id) {
+ timings.add(id);
+ }
+
+ function onTimingsUpdated(_, id) {
+ timings.delete(id);
maybeResolve();
}
function maybeResolve() {
- // Have all the requests in the map finished yet?
- if (![...requests.values()].every(finished => finished)) {
+ // Have all the requests finished yet?
+ if (requests.size > 0 || timings.size > 0) {
return;
}
// All requests are done - unsubscribe from events and resolve!
- window.off(EVENTS.NETWORK_EVENT, onRequest);
+ window.off(EVENTS.REQUEST_ADDED, onRequestAdded);
window.off(EVENTS.PAYLOAD_READY, onPayloadReady);
+ window.off(EVENTS.UPDATING_EVENT_TIMINGS, onTimingsUpdating);
+ window.off(EVENTS.RECEIVED_EVENT_TIMINGS, onTimingsUpdated);
resolve();
}
- window.on(EVENTS.NETWORK_EVENT, onRequest);
+ window.on(EVENTS.REQUEST_ADDED, onRequestAdded);
window.on(EVENTS.PAYLOAD_READY, onPayloadReady);
+ window.on(EVENTS.UPDATING_EVENT_TIMINGS, onTimingsUpdating);
+ window.on(EVENTS.RECEIVED_EVENT_TIMINGS, onTimingsUpdated);
});
},
startTest(doneCallback, config) {
this._onTestComplete = function(results) {
TalosParentProfiler.pause("DAMP - end");
doneCallback(results);
};