summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test/browser_jsonview_copy_headers.js
blob: faa6e4335467488e1edb4276a8493815d0966ef1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* 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");

  await addJsonViewTab(TEST_JSON_URL);

  // Select the RawData tab
  await selectJsonViewContentTab("headers");

  // Check displayed headers
  const count = await getElementCount(".headersPanelBox .netHeadersGroup");
  is(count, 2, "There must be two header groups");

  const text = await getElementText(".headersPanelBox .netInfoHeadersTable");
  isnot(text, "", "Headers text must not be empty");

  const browser = gBrowser.selectedBrowser;

  // Verify JSON copy into the clipboard.
  await waitForClipboardPromise(
    function setup() {
      BrowserTestUtils.synthesizeMouseAtCenter(
        ".headersPanelBox .toolbar button.copy",
        {},
        browser
      );
    },
    function validator(value) {
      return value.indexOf("application/json") > 0;
    }
  );
});