Bug 1425273 - Waiting for event timings in damp test r?ochameau draft
authorRicky Chien <ricky060709@gmail.com>
Thu, 04 Jan 2018 15:36:08 +0800
changeset 715575 d0ba3f6032365b00442d7387f2525367e3f65c98
parent 715574 bcb9884d86bd39436cfa254746f65c8c294fb271
child 744828 1005dd23f396fb0b3a19d4bee4f12a392971251f
push id94197
push userbmo:rchien@mozilla.com
push dateThu, 04 Jan 2018 07:36:39 +0000
reviewersochameau
bugs1425273
milestone59.0a1
Bug 1425273 - Waiting for event timings in damp test r?ochameau MozReview-Commit-ID: A2YgZafM0Jv
testing/talos/talos/tests/devtools/addon/content/damp.js
--- 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);
     };