Bug 1399897 - Fix console_table mochitest; r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 08 Jan 2018 12:26:32 +0100
changeset 453259 83acad9bf47b7c32947d37f03e60622722c1fd88
parent 453258 914fce4a03e31172958705299a83128633911d48
child 453260 ed6f1ea151c1eb56e2d45da039e7694bce70f32a
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1399897
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399897 - Fix console_table mochitest; r=Honza. Now that we are using sibling divs for all the cells of the table, we don't have the same notion of what is a row. The console table test is adapted to the new component. MozReview-Commit-ID: HcfzTaRVIcN
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_table.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_table.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_table.js
@@ -146,37 +146,37 @@ add_task(function* () {
     ".message .new-consoletable");
   is(consoleTableNodes.length, testCases.length,
     "console has the expected number of consoleTable items");
   testCases.forEach((testCase, index) => testItem(testCase, nodes[index]));
 });
 function testItem(testCase, node) {
   info(testCase.info);
 
-  let columns = Array.from(node.querySelectorAll("thead th"));
-  let rows = Array.from(node.querySelectorAll("tbody tr"));
+  const columns = Array.from(node.querySelectorAll("[role=columnheader]"));
+  const columnsNumber = columns.length;
+  const cells = Array.from(node.querySelectorAll("[role=gridcell]"));
 
   is(
     JSON.stringify(testCase.expected.columns),
     JSON.stringify(columns.map(column => column.textContent)),
     "table has the expected columns"
   );
 
-  is(testCase.expected.rows.length, rows.length,
+  // We don't really have rows since we are using a CSS grid in order to have a sticky
+  // header on the table. So we check the "rows" by dividing the number of cells by the
+  // number of columns.
+  is(testCase.expected.rows.length, cells.length / columnsNumber,
     "table has the expected number of rows");
 
   testCase.expected.rows.forEach((expectedRow, rowIndex) => {
-    let row = rows[rowIndex];
-    let cells = row.querySelectorAll("td");
-    is(expectedRow.length, cells.length, "row has the expected number of cells");
-
-    expectedRow.forEach((expectedCell, cellIndex) => {
-      let cell = cells[cellIndex];
-      is(expectedCell, cell.textContent, "cell has the expected content");
-    });
+    const startIndex = rowIndex * columnsNumber;
+    // Slicing the cells array so we can get the current "row".
+    const rowCells = cells.slice(startIndex, startIndex + columnsNumber);
+    is(rowCells.map(x => x.textContent).join(" | "), expectedRow.join(" | "));
   });
 }
 
 function findConsoleTable(node, index) {
   let condition = node.querySelector(
     `.message:nth-of-type(${index + 1}) .new-consoletable`);
   return condition;
 }