summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_copy_url.js
blob: 41e73877ae3bbf35fe579c8a4c2034df5a7583f7 (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
39
40
41
42
43
44
45
46
47
48
49
50
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests if copying a request's url works.
 */

add_task(async function () {
  const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, {
    requestCount: 1,
  });
  info("Starting test... ");

  const { document, store, windowRequire } = monitor.panelWin;
  const { getSortedRequests } = windowRequire(
    "devtools/client/netmonitor/src/selectors/index"
  );

  // Execute requests.
  await performRequests(monitor, tab, 1);

  EventUtils.sendMouseEvent(
    { type: "mousedown" },
    document.querySelectorAll(".request-list-item")[0]
  );

  const requestItem = getSortedRequests(store.getState())[0];

  info("Simulating CmdOrCtrl+C on a first element of the request table");
  await waitForClipboardPromise(
    () => synthesizeKeyShortcut("CmdOrCtrl+C"),
    requestItem.url
  );

  emptyClipboard();

  info("Simulating context click on a first element of the request table");
  EventUtils.sendMouseEvent(
    { type: "contextmenu" },
    document.querySelectorAll(".request-list-item")[0]
  );

  await waitForClipboardPromise(async function setup() {
    await selectContextMenuItem(monitor, "request-list-context-copy-url");
  }, requestItem.url);

  await teardown(monitor);
});