Bug 1362464 - Fix feedback from Storage Inspector's head.js methods r?pbro
MozReview-Commit-ID: G5lOr9bU13B
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -616,63 +616,84 @@ function getRowValues(id, includeHidden
*/
function getRowCells(id, includeHidden = false) {
let doc = gPanelWindow.document;
let table = gUI.table;
let item = doc.querySelector(".table-widget-column#" + table.uniqueId +
" .table-widget-cell[value='" + id + "']");
if (!item) {
- ok(false, "Row id '" + id + "' exists");
-
- showAvailableIds();
+ ok(false, `The row id '${id}' that was passed to getRowCells() does not ` +
+ `exist. ${getAvailableIds()}`);
}
let index = table.columns.get(table.uniqueId).cellNodes.indexOf(item);
let cells = {};
for (let [name, column] of [...table.columns]) {
if (!includeHidden && column.column.parentNode.hidden) {
continue;
}
cells[name] = column.cellNodes[index];
}
return cells;
}
/**
- * Show available ids.
+ * Get available ids... useful for error reporting.
*/
-function showAvailableIds() {
+function getAvailableIds() {
let doc = gPanelWindow.document;
let table = gUI.table;
- info("Available ids:");
+ let out = "Available ids:\n";
let cells = doc.querySelectorAll(".table-widget-column#" + table.uniqueId +
" .table-widget-cell");
for (let cell of cells) {
- info(" - " + cell.getAttribute("value"));
+ out += ` - ${cell.getAttribute("value")}\n`;
}
+
+ return out;
+}
+
+/**
+ * Show available ids.
+ */
+function showAvailableIds() {
+ info(getAvailableIds);
}
/**
* Get a cell value.
*
* @param {String} id
* The uniqueId of the row.
* @param {String} column
* The id of the column
*
* @yield {String}
* The cell value.
*/
function getCellValue(id, column) {
let row = getRowValues(id, true);
+ if (typeof row[column] === "undefined") {
+ let out = "";
+ for (let key in row) {
+ let value = row[key];
+
+ out += ` - ${key} = ${value}\n`;
+ }
+
+ ok(false, `The column name '${column}' that was passed to ` +
+ `getCellValue() does not exist. Current column names and row ` +
+ `values are:\n${out}`);
+ }
+
return row[column];
}
/**
* Edit a cell value. The cell is assumed to be in edit mode, see startCellEdit.
*
* @param {String} id
* The uniqueId of the row.