summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test/browser_jsonview_valid_json.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/client/jsonview/test/browser_jsonview_valid_json.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/jsonview/test/browser_jsonview_valid_json.js')
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_valid_json.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/devtools/client/jsonview/test/browser_jsonview_valid_json.js b/devtools/client/jsonview/test/browser_jsonview_valid_json.js
new file mode 100644
index 0000000000..22e543b6c8
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_valid_json.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "valid_json.json";
+
+add_task(async function() {
+ info("Test valid JSON started");
+
+ const tab = await addJsonViewTab(TEST_JSON_URL);
+
+ ok(
+ tab.linkedBrowser.contentPrincipal.isNullPrincipal,
+ "Should have null principal"
+ );
+
+ is(await countRows(), 3, "There must be three rows");
+
+ 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, "", "The summary is hidden when object is expanded");
+
+ // Clicking the value does not collapse it (so that it can be selected and copied).
+ await clickJsonNode(".jsonPanelBox .treeTable .treeValueCell");
+ is(await countRows(), 3, "There must still be three rows");
+
+ // Clicking the label collapses the auto-expanded node.
+ await clickJsonNode(".jsonPanelBox .treeTable .treeLabel");
+ is(await countRows(), 1, "There must be one row");
+
+ // Collapsed nodes are preserved when switching panels.
+ await selectJsonViewContentTab("headers");
+ await selectJsonViewContentTab("json");
+ is(await countRows(), 1, "There must still be one row");
+});
+
+function countRows() {
+ return getElementCount(".jsonPanelBox .treeTable .treeRow");
+}