Bug 1426688 - Wait for pending paint updates after opening the toolbox. r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 20 Dec 2017 02:28:02 -0800
changeset 715338 780e4e6f15c8d81907f9e193976f82b3761940ca
parent 715146 4d1423f75c677447cafb8cd3f9a5fbdff8bfbca8
child 715339 0fd8772159745d99b476225cad4c8362f17ea681
push id94143
push userbmo:poirot.alex@gmail.com
push dateWed, 03 Jan 2018 18:56:19 +0000
reviewersjdescottes
bugs1426688
milestone59.0a1
Bug 1426688 - Wait for pending paint updates after opening the toolbox. r=jdescottes MozReview-Commit-ID: 34Z9dPwUnwI
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
@@ -475,22 +475,50 @@ async _consoleOpenWithCachedMessagesTest
       }
     });
 
     test.done();
 
     return Promise.resolve();
   },
 
+  /**
+   * Wait for any pending paint.
+   * The tool may have touched the DOM elements at the very end of the current test.
+   * We should ensure waiting for the reflow related to these changes.
+   */
+  async waitForPendingPaints(toolbox) {
+    let panel = toolbox.getCurrentPanel();
+    // All panels have its own way of exposing their window object...
+    let window = panel.panelWin || panel._frameWindow || panel.panelWindow;
+
+    let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                      .getInterface(Ci.nsIDOMWindowUtils);
+    window.performance.mark("pending paints.start");
+    while (utils.isMozAfterPaintPending) {
+      await new Promise(done => {
+        window.addEventListener("MozAfterPaint", function listener() {
+          window.performance.mark("pending paint");
+          done();
+        }, { once: true });
+      });
+    }
+    window.performance.measure("pending paints", "pending paints.start");
+  },
+
   async openToolboxAndLog(name, tool, onLoad) {
     dump("Open toolbox on '" + name + "'\n");
     let test = this.runTest(name + ".open.DAMP");
     let toolbox = await this.openToolbox(tool, onLoad);
     test.done();
 
+    test = this.runTest(name + ".open.settle.DAMP");
+    await this.waitForPendingPaints(toolbox);
+    test.done();
+
     // Force freeing memory after toolbox open as it creates a lot of objects
     // and for complex documents, it introduces a GC that runs during 'reload' test.
     await garbageCollect();
 
     return toolbox;
   },
 
   async closeToolboxAndLog(name) {