Bug 1426688 - Wait for pending paints after page reload. r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 20 Dec 2017 10:12:00 -0800
changeset 715339 0fd8772159745d99b476225cad4c8362f17ea681
parent 715338 780e4e6f15c8d81907f9e193976f82b3761940ca
child 744776 a1e24fa9f765ff1ab759973c9e1b32ef023c1bb8
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 paints after page reload. r=jdescottes MozReview-Commit-ID: KcdqILBUySO
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
@@ -318,17 +318,17 @@ Damp.prototype = {
         observer.observe(tree, {
           childList: true
         });
       });
     }
 
     test.done();
 
-    await this.closeToolboxAndLog("console.objectexpanded");
+    await this.closeToolboxAndLog("console.objectexpanded", toolbox);
     await this.testTeardown();
   },
 
 async _consoleOpenWithCachedMessagesTest() {
   let TOTAL_MESSAGES = 100;
   let tab = await this.testSetup(SIMPLE_URL);
 
   // Load a frame script using a data URI so we can do logs
@@ -516,32 +516,35 @@ async _consoleOpenWithCachedMessagesTest
 
     // 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) {
+  async closeToolboxAndLog(name, toolbox) {
+    let { target } = toolbox;
     dump("Close toolbox on '" + name + "'\n");
-    let tab = getActiveTab(getMostRecentBrowserWindow());
-    let target = TargetFactory.forTab(tab);
     await target.client.waitForRequestsToSettle();
 
     let test = this.runTest(name + ".close.DAMP");
     await gDevTools.closeToolbox(target);
     test.done();
   },
 
-  async reloadPageAndLog(name, onReload) {
+  async reloadPageAndLog(name, toolbox, onReload) {
     dump("Reload page on '" + name + "'\n");
     let test = this.runTest(name + ".reload.DAMP");
     await this.reloadPage(onReload);
     test.done();
+
+    test = this.runTest(name + ".reload.settle.DAMP");
+    await this.waitForPendingPaints(toolbox);
+    test.done();
   },
 
   async _coldInspectorOpen() {
     await this.testSetup(SIMPLE_URL);
     await this.openToolboxAndLog("cold.inspector", "inspector");
     await this.closeToolbox();
     await this.testTeardown();
   },
@@ -557,49 +560,49 @@ async _consoleOpenWithCachedMessagesTest
     `);
     await this.testSetup(url);
     let toolbox = await this.openToolbox("webconsole");
 
     // Select the options panel to make the console be in background.
     // Options panel should not do anything on page reload.
     await toolbox.selectTool("options");
 
-    await this.reloadPageAndLog("panelsInBackground");
+    await this.reloadPageAndLog("panelsInBackground", toolbox);
 
     await this.closeToolbox();
     await this.testTeardown();
   },
 
   async reloadInspectorAndLog(label, toolbox) {
     let onReload = async function() {
       let inspector = toolbox.getPanel("inspector");
       // First wait for markup view to be loaded against the new root node
       await inspector.once("new-root");
       // Then wait for inspector to be updated
       await inspector.once("inspector-updated");
     };
-    await this.reloadPageAndLog(label + ".inspector", onReload);
+    await this.reloadPageAndLog(label + ".inspector", toolbox, onReload);
   },
 
   async customInspector() {
     let url = CUSTOM_URL.replace(/\$TOOL/, "inspector");
     await this.testSetup(url);
     let toolbox = await this.openToolboxAndLog("custom.inspector", "inspector");
     await this.reloadInspectorAndLog("custom", toolbox);
-    await this.closeToolboxAndLog("custom.inspector");
+    await this.closeToolboxAndLog("custom.inspector", toolbox);
     await this.testTeardown();
   },
 
   _getToolLoadingTests(url, label, { expectedMessages, expectedSources }) {
     let tests = {
       async inspector() {
         await this.testSetup(url);
         let toolbox = await this.openToolboxAndLog(label + ".inspector", "inspector");
         await this.reloadInspectorAndLog(label, toolbox);
-        await this.closeToolboxAndLog(label + ".inspector");
+        await this.closeToolboxAndLog(label + ".inspector", toolbox);
         await this.testTeardown();
       },
 
       async webconsole() {
         await this.testSetup(url);
         let toolbox = await this.openToolboxAndLog(label + ".webconsole", "webconsole");
         let onReload = async function() {
           let webconsole = toolbox.getPanel("webconsole");
@@ -609,18 +612,18 @@ async _consoleOpenWithCachedMessagesTest
               if (++messages == expectedMessages) {
                 webconsole.hud.ui.off("new-messages", receiveMessages);
                 done();
               }
             };
             webconsole.hud.ui.on("new-messages", receiveMessages);
           });
         };
-        await this.reloadPageAndLog(label + ".webconsole", onReload);
-        await this.closeToolboxAndLog(label + ".webconsole");
+        await this.reloadPageAndLog(label + ".webconsole", toolbox, onReload);
+        await this.closeToolboxAndLog(label + ".webconsole", toolbox);
         await this.testTeardown();
       },
 
       async debugger() {
         await this.testSetup(url);
         let onLoad = async function(toolbox, dbg) {
           await new Promise(done => {
             let { selectors, store } = dbg.panelWin.getGlobalsForTesting();
@@ -645,55 +648,55 @@ async _consoleOpenWithCachedMessagesTest
               if (++count >= expectedSources) {
                 client.removeListener("newSource", onSource);
                 done();
               }
             };
             client.addListener("newSource", onSource);
           });
         };
-        await this.reloadPageAndLog(label + ".jsdebugger", onReload);
-        await this.closeToolboxAndLog(label + ".jsdebugger");
+        await this.reloadPageAndLog(label + ".jsdebugger", toolbox, onReload);
+        await this.closeToolboxAndLog(label + ".jsdebugger", toolbox);
         await this.testTeardown();
       },
 
       async styleeditor() {
         await this.testSetup(url);
-        await this.openToolboxAndLog(label + ".styleeditor", "styleeditor");
-        await this.reloadPageAndLog(label + ".styleeditor");
-        await this.closeToolboxAndLog(label + ".styleeditor");
+        const toolbox = await this.openToolboxAndLog(label + ".styleeditor", "styleeditor");
+        await this.reloadPageAndLog(label + ".styleeditor", toolbox);
+        await this.closeToolboxAndLog(label + ".styleeditor", toolbox);
         await this.testTeardown();
       },
 
       async performance() {
         await this.testSetup(url);
-        await this.openToolboxAndLog(label + ".performance", "performance");
-        await this.reloadPageAndLog(label + ".performance");
-        await this.closeToolboxAndLog(label + ".performance");
+        const toolbox = await this.openToolboxAndLog(label + ".performance", "performance");
+        await this.reloadPageAndLog(label + ".performance", toolbox);
+        await this.closeToolboxAndLog(label + ".performance", toolbox);
         await this.testTeardown();
       },
 
       async netmonitor() {
         await this.testSetup(url);
         const toolbox = await this.openToolboxAndLog(label + ".netmonitor", "netmonitor");
         const requestsDone = this.waitForNetworkRequests(label + ".netmonitor", toolbox);
-        await this.reloadPageAndLog(label + ".netmonitor");
+        await this.reloadPageAndLog(label + ".netmonitor", toolbox);
         await requestsDone;
-        await this.closeToolboxAndLog(label + ".netmonitor");
+        await this.closeToolboxAndLog(label + ".netmonitor", toolbox);
         await this.testTeardown();
       },
 
       async saveAndReadHeapSnapshot() {
         await this.testSetup(url);
-        await this.openToolboxAndLog(label + ".memory", "memory");
-        await this.reloadPageAndLog(label + ".memory");
+        const toolbox = await this.openToolboxAndLog(label + ".memory", "memory");
+        await this.reloadPageAndLog(label + ".memory", toolbox);
         await this.saveHeapSnapshot(label);
         await this.readHeapSnapshot(label);
         await this.takeCensus(label);
-        await this.closeToolboxAndLog(label + ".memory");
+        await this.closeToolboxAndLog(label + ".memory", toolbox);
         await this.testTeardown();
       },
     };
     // Prefix all tests with the page type (simple or complicated)
     for (let name in tests) {
       tests[label + "." + name] = tests[name];
       delete tests[name];
     }