fune/devtools/client/jsonview/test/browser_jsonview_empty_object.js
Nicolas Chevobbe 925311bc77 Bug 1568779 - Remove editors settings comments in devtools files. r=pbro.
Differential Revision: https://phabricator.services.mozilla.com/D42300

--HG--
extra : moz-landing-system : lando
2019-08-19 12:48:16 +00:00

48 lines
1.5 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function testRootObject(objExpr, summary = objExpr) {
return async function() {
info("Test JSON with root empty object " + objExpr + " started");
const TEST_JSON_URL = "data:application/json," + objExpr;
await addJsonViewTab(TEST_JSON_URL);
const objectText = await getElementText(".jsonPanelBox .panelContent");
is(objectText, summary, "The root object " + objExpr + " is visible");
};
}
function testNestedObject(objExpr, summary = objExpr) {
return async function() {
info("Test JSON with nested empty object " + objExpr + " started");
const TEST_JSON_URL = "data:application/json,[" + objExpr + "]";
await addJsonViewTab(TEST_JSON_URL);
const objectCellCount = await getElementCount(
".jsonPanelBox .treeTable .objectCell"
);
is(objectCellCount, 1, "There must be one object cell");
const objectCellText = await getElementText(
".jsonPanelBox .treeTable .objectCell"
);
is(objectCellText, summary, objExpr + " has a visible summary");
// Collapse auto-expanded node.
await clickJsonNode(".jsonPanelBox .treeTable .treeLabel");
const textAfter = await getElementText(
".jsonPanelBox .treeTable .objectCell"
);
is(textAfter, summary, objExpr + " still has a visible summary");
};
}
add_task(testRootObject("null"));
add_task(testNestedObject("null"));
add_task(testNestedObject("[]"));
add_task(testNestedObject("{}"));