browser_jsonview_copy_json.js 1014 B

12345678910111213141516171819202122232425262728293031
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. "use strict";
  5. const TEST_JSON_URL = URL_ROOT + "simple_json.json";
  6. add_task(function* () {
  7. info("Test copy JSON started");
  8. yield addJsonViewTab(TEST_JSON_URL);
  9. let countBefore = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
  10. ok(countBefore == 1, "There must be one row");
  11. let text = yield getElementText(".jsonPanelBox .treeTable .treeRow");
  12. is(text, "name\"value\"", "There must be proper JSON displayed");
  13. // Verify JSON copy into the clipboard.
  14. let value = "{\"name\": \"value\"}\n";
  15. let browser = gBrowser.selectedBrowser;
  16. let selector = ".jsonPanelBox .toolbar button.copy";
  17. yield waitForClipboardPromise(function setup() {
  18. BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
  19. }, function validator(result) {
  20. let str = normalizeNewLines(result);
  21. return str == value;
  22. });
  23. });