summaryrefslogtreecommitdiff
path: root/browser/devtools/netmonitor/test/browser_net_copy_url.js
blob: d2e54f17d1a175d02bf49c71f53e43042cd44a5d (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

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

function test() {
  initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
    info("Starting test... ");

    let { NetMonitorView } = aMonitor.panelWin;
    let { RequestsMenu } = NetMonitorView;

    waitForNetworkEvents(aMonitor, 1).then(() => {
      let requestItem = RequestsMenu.getItemAtIndex(0);
      RequestsMenu.selectedItem = requestItem;

      waitForClipboard(requestItem.attachment.url, function setup() {
        RequestsMenu.copyUrl();
      }, function onSuccess() {
        ok(true, "Clipboard contains the currently selected item's url.");
        cleanUp();
      }, function onFailure() {
        ok(false, "Copying the currently selected item's url was unsuccessful.");
        cleanUp();
      });
    });

    aDebuggee.performRequests(1);

    function cleanUp(){
      teardown(aMonitor).then(finish);
    }
  });
}