From f4cd2c00679844417e55127b2eef479d58cfddd6 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 20 Dec 2017 02:28:02 -0800 Subject: [PATCH] Bug 1426688 - Wait for pending paint updates after opening the toolbox. r=jdescottes MozReview-Commit-ID: 34Z9dPwUnwI --HG-- extra : rebase_source : fb220a3cfbb48c1aeb5ad1d0d8ae4749c5afc3ce --- .../tests/devtools/addon/content/damp.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/testing/talos/talos/tests/devtools/addon/content/damp.js b/testing/talos/talos/tests/devtools/addon/content/damp.js index a4c6bafd7f73..b12ee771b250 100644 --- a/testing/talos/talos/tests/devtools/addon/content/damp.js +++ b/testing/talos/talos/tests/devtools/addon/content/damp.js @@ -480,12 +480,40 @@ async _consoleOpenWithCachedMessagesTest() { 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();