summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test/browser_jsonview_bug_1380828.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/jsonview/test/browser_jsonview_bug_1380828.js')
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_bug_1380828.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/devtools/client/jsonview/test/browser_jsonview_bug_1380828.js b/devtools/client/jsonview/test/browser_jsonview_bug_1380828.js
new file mode 100644
index 0000000000..6d698e8930
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_bug_1380828.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const VALID_JSON_URL = URL_ROOT + "valid_json.json";
+const INVALID_JSON_URL = URL_ROOT + "invalid_json.json";
+const prettyPrintButtonClass = ".textPanelBox .toolbar button.prettyprint";
+
+add_task(async function () {
+ info("Test 'Pretty Print' button disappears on parsing invalid JSON");
+
+ const count = await testPrettyPrintButton(INVALID_JSON_URL);
+ is(count, 0, "There must be no pretty-print button for invalid json");
+});
+
+add_task(async function () {
+ info("Test 'Pretty Print' button is present on parsing valid JSON");
+
+ const count = await testPrettyPrintButton(VALID_JSON_URL);
+ is(count, 1, "There must be pretty-print button for valid json");
+});
+
+async function testPrettyPrintButton(url) {
+ await addJsonViewTab(url);
+
+ await selectJsonViewContentTab("rawdata");
+ info("Switched to Raw Data tab.");
+
+ const count = await getElementCount(prettyPrintButtonClass);
+ return count;
+}