Bug 1419533 - Add talos test for devtools inspector layout tab;r=ochameau draft
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 21 Nov 2017 19:56:14 +0100
changeset 704226 b3b00d371deb150d325d38451fff0b5bed811e99
parent 704125 27718ff74dde99123c2329a0a2f3d4a43ff1b906
child 742034 e51cf4ea05c2003fe4ec6cd8ab953a0d96fa6dbf
push id91113
push userjdescottes@mozilla.com
push dateTue, 28 Nov 2017 11:19:39 +0000
reviewersochameau
bugs1419533
milestone59.0a1
Bug 1419533 - Add talos test for devtools inspector layout tab;r=ochameau MozReview-Commit-ID: 7Ayx8XG2GJp
testing/talos/talos/tests/devtools/addon/content/damp.html
testing/talos/talos/tests/devtools/addon/content/damp.js
--- a/testing/talos/talos/tests/devtools/addon/content/damp.html
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.html
@@ -30,16 +30,17 @@ var defaultConfig = {
 
     "custom.inspector": true,
 
     "console.bulklog": true,
     "console.streamlog": true,
     "console.objectexpand": true,
     "console.openwithcache": true,
     "inspector.mutations": true,
+    "inspector.layout": true,
 
     "panelsInBackground.reload": true,
   }
 };
 
 var testsInfo = {
   "cold.inspector": "Measure first open toolbox on inspector panel",
 
@@ -59,16 +60,17 @@ var testsInfo = {
   "complicated.netmonitor": "Measure open/close toolbox on network monitor panel against complicated document",
   "complicated.saveAndReadHeapSnapshot": "Measure open/close toolbox on memory panel and save/read heap snapshot against complicated document",
 
   "console.bulklog": "Measure time for a bunch of sync console.log statements to appear",
   "console.streamlog": "Measure rAF on page during a stream of console.log statements",
   "console.objectexpand": "Measure time to expand a large object and close the console",
   "console.openwithcache": "Measure time to render last logged messages in console for a page with 100 logged messages",
   "inspector.mutations": "Measure the time to perform childList mutations when inspector is enabled",
+  "inspector.layout": "Measure the time to open/close toolbox on inspector with layout tab against big document with grid containers",
 
   "panelsInBackground.reload": "Measure page reload time when all panels are in background",
 };
 
 function updateConfig() {
   config = {subtests: []};
   for (var test in defaultConfig.subtests) {
     if ($("subtest-" + test).checked) { // eslint-disable-line no-undef
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -333,17 +333,17 @@ async _consoleOpenWithCachedMessagesTest
 
   await this.openToolboxAndLog("console.openwithcache", "webconsole");
 
   await this.closeToolbox(null);
   await this.testTeardown();
 },
 
   /**
-   * Measure the time necesssary to perform successive childList mutations in the content
+   * Measure the time necessary to perform successive childList mutations in the content
    * page and update the markup-view accordingly.
    */
   async _inspectorMutationsTest() {
     let tab = await this.testSetup(SIMPLE_URL);
     let messageManager = tab.linkedBrowser.messageManager;
     let {toolbox} = await this.openToolbox("inspector");
     let inspector = toolbox.getPanel("inspector");
 
@@ -389,16 +389,64 @@ async _consoleOpenWithCachedMessagesTest
       name: "inspector.mutations",
       value: performance.now() - start
     });
 
     await this.closeToolbox(null);
     await this.testTeardown();
   },
 
+  /**
+   * Measure the time to open toolbox on the inspector with the layout tab selected.
+   */
+  async _inspectorLayoutTest() {
+    let tab = await this.testSetup(SIMPLE_URL);
+    let messageManager = tab.linkedBrowser.messageManager;
+
+    // Backup current sidebar tab preference
+    let sidebarTab = Services.prefs.getCharPref("devtools.inspector.activeSidebar");
+
+    // Set layoutview as the current inspector sidebar tab.
+    Services.prefs.setCharPref("devtools.inspector.activeSidebar", "layoutview");
+
+    // Setup test page. It is a simple page containing 5000 regular nodes and 10 grid
+    // containers.
+    await new Promise(resolve => {
+      messageManager.addMessageListener("setup-test-done", resolve);
+
+      const NODES = 5000;
+      const GRID_NODES = 10;
+      messageManager.loadFrameScript("data:,(" + encodeURIComponent(
+        `function () {
+          let div = content.document.createElement("div");
+          div.innerHTML =
+            new Array(${NODES}).join("<div></div>") +
+            new Array(${GRID_NODES}).join("<div style='display:grid'></div>");
+          content.document.body.appendChild(div);
+          sendSyncMessage("setup-test-done");
+        }`
+      ) + ")()", false);
+    });
+
+    // Open the toolbox and record the time.
+    let start = performance.now();
+    await this.openToolbox("inspector");
+    this._results.push({
+      name: "inspector.layout.open",
+      value: performance.now() - start
+    });
+
+    await this.closeToolbox(null);
+
+    // Restore sidebar tab preference.
+    Services.prefs.setCharPref("devtools.inspector.activeSidebar", sidebarTab);
+
+    await this.testTeardown();
+  },
+
   takeCensus(label) {
     let start = performance.now();
 
     this._snapshot.takeCensus({
       breakdown: {
         by: "coarseType",
         objects: {
           by: "objectClass",
@@ -791,16 +839,17 @@ async _consoleOpenWithCachedMessagesTest
     tests["custom.inspector"] = this.customInspector;
 
     // Run individual tests covering a very precise tool feature
     tests["console.bulklog"] = this._consoleBulkLoggingTest;
     tests["console.streamlog"] = this._consoleStreamLoggingTest;
     tests["console.objectexpand"] = this._consoleObjectExpansionTest;
     tests["console.openwithcache"] = this._consoleOpenWithCachedMessagesTest;
     tests["inspector.mutations"] = this._inspectorMutationsTest;
+    tests["inspector.layout"] = this._inspectorLayoutTest;
 
     // Filter tests via `./mach --subtests filter` command line argument
     let filter = Services.prefs.getCharPref("talos.subtests", "");
     if (filter) {
       for (let name in tests) {
         if (!name.includes(filter)) {
           delete tests[name];
         }