1
0
Fork 0
firefox/devtools/client/jsonview/test/browser_jsonview_copy_json.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

34 lines
1,009 B
JavaScript

/* 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;
}
);
});