summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_tracking-resources.js
blob: 6d7365cb73e6bc30b7a7ee710faafba2e7e9a4ba (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";

const { UrlClassifierTestUtils } = ChromeUtils.importESModule(
  "resource://testing-common/UrlClassifierTestUtils.sys.mjs"
);

const TEST_URI =
  "https://example.com/browser/devtools/client/" +
  "netmonitor/test/html_tracking-protection.html";

registerCleanupFunction(function () {
  UrlClassifierTestUtils.cleanupTestTrackers();
});

/**
 * Test that tracking resources are properly marked in the Network panel.
 */
add_task(async function () {
  await UrlClassifierTestUtils.addTestTrackers();

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

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

  store.dispatch(Actions.batchEnable(false));

  // Execute request with third party tracking protection flag.
  await performRequests(monitor, tab, 1);

  const domainRequests = document.querySelectorAll(
    ".requests-list-domain .tracking-resource"
  );
  const UrlRequests = document.querySelectorAll(
    ".requests-list-url .tracking-resource"
  );

  is(
    domainRequests.length,
    1,
    "There should be one domain column tracking request"
  );
  is(UrlRequests.length, 1, "There should be one URL column tracking request");

  await teardown(monitor);
});