summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test/browser_jsonview_copy_json.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/jsonview/test/browser_jsonview_copy_json.js')
-rw-r--r--devtools/client/jsonview/test/browser_jsonview_copy_json.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/devtools/client/jsonview/test/browser_jsonview_copy_json.js b/devtools/client/jsonview/test/browser_jsonview_copy_json.js
new file mode 100644
index 0000000000..35503097e3
--- /dev/null
+++ b/devtools/client/jsonview/test/browser_jsonview_copy_json.js
@@ -0,0 +1,34 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_JSON_URL = URL_ROOT + "simple_json.json";
+
+add_task(async function () {
+ info("Test copy JSON started");
+
+ await addJsonViewTab(TEST_JSON_URL);
+
+ const countBefore = await getElementCount(
+ ".jsonPanelBox .treeTable .treeRow"
+ );
+ Assert.equal(countBefore, 1, "There must be one row");
+
+ const text = await getElementText(".jsonPanelBox .treeTable .treeRow");
+ is(text, 'name"value"', "There must be proper JSON displayed");
+
+ // Verify JSON copy into the clipboard.
+ const value = '{ "name": "value" }\n';
+ const browser = gBrowser.selectedBrowser;
+ const selector = ".jsonPanelBox .toolbar button.copy";
+ await waitForClipboardPromise(
+ function setup() {
+ BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
+ },
+ function validator(result) {
+ const str = normalizeNewLines(result);
+ return str == value;
+ }
+ );
+});