Bug 1370443 - Do not hide the summary when expanding an empty object in JSON Viewer. r=Honza

This commit is contained in:
Oriol 2017-06-15 07:30:00 -04:00
Родитель 80944c40d8
Коммит 08f93f542e
3 изменённых файлов: 56 добавлений и 3 удалений

Просмотреть файл

@ -21,6 +21,10 @@ define(function (require, exports, module) {
const AUTO_EXPAND_MAX_SIZE = 100 * 1024;
const AUTO_EXPAND_MAX_LEVEL = 7;
function isObject(value) {
return Object(value) === value;
}
/**
* This template represents the 'JSON' panel. The panel is
* responsible for rendering an expandable tree that allows simple
@ -90,8 +94,8 @@ define(function (require, exports, module) {
renderValue: props => {
let member = props.member;
// Hide object summary when object is expanded (bug 1244912).
if (typeof member.value == "object" && member.open) {
// Hide object summary when non-empty object is expanded (bug 1244912).
if (isObject(member.value) && member.hasChildren && member.open) {
return null;
}
@ -131,7 +135,7 @@ define(function (require, exports, module) {
let data = this.props.data;
try {
if (typeof data == "object") {
if (isObject(data)) {
content = this.renderTree();
} else {
content = div({className: "jsonParseError"},

Просмотреть файл

@ -27,6 +27,7 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32
[browser_jsonview_copy_rawdata.js]
subsuite = clipboard
skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
[browser_jsonview_empty_object.js]
[browser_jsonview_filter.js]
[browser_jsonview_invalid_json.js]
[browser_jsonview_manifest.js]

Просмотреть файл

@ -0,0 +1,48 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function testRootObject(objExpr, summary = objExpr) {
return function* () {
info("Test JSON with root empty object " + objExpr + " started");
let TEST_JSON_URL = "data:application/json," + objExpr;
yield addJsonViewTab(TEST_JSON_URL);
let objectText = yield getElementText(
".jsonPanelBox .panelContent");
is(objectText, summary, "The root object " + objExpr + " is visible");
};
}
function testNestedObject(objExpr, summary = objExpr) {
return function* () {
info("Test JSON with nested empty object " + objExpr + " started");
let TEST_JSON_URL = "data:application/json,[" + objExpr + "]";
yield addJsonViewTab(TEST_JSON_URL);
let objectCellCount = yield getElementCount(
".jsonPanelBox .treeTable .objectCell");
is(objectCellCount, 1, "There must be one object cell");
let objectCellText = yield getElementText(
".jsonPanelBox .treeTable .objectCell");
is(objectCellText, summary, objExpr + " has a visible summary");
// Collapsed auto-expanded node.
yield clickJsonNode(".jsonPanelBox .treeTable .treeLabel");
let textAfter = yield 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("{}", "Object"));