summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/protectionsUI/trackingAPI.js
blob: de5479a70f9af2d31f20e30353f8fc681668380c (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function createIframe(src) {
  let ifr = document.createElement("iframe");
  ifr.src = src;
  document.body.appendChild(ifr);
}

function createImage(src) {
  let img = document.createElement("img");
  img.src = src;
  img.onload = () => {
    parent.postMessage("done", "*");
  };
  document.body.appendChild(img);
}

onmessage = event => {
  switch (event.data) {
    case "tracking":
      createIframe("https://trackertest.org/");
      break;
    case "socialtracking":
      createIframe(
        "https://social-tracking.example.org/browser/browser/base/content/test/protectionsUI/cookieServer.sjs"
      );
      break;
    case "cryptomining":
      // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      createIframe("http://cryptomining.example.com/");
      break;
    case "fingerprinting":
      createIframe("https://fingerprinting.example.com/");
      break;
    case "more-tracking":
      createIframe("https://itisatracker.org/");
      break;
    case "more-tracking-2":
      createIframe("https://tracking.example.com/");
      break;
    case "cookie":
      createIframe(
        "https://trackertest.org/browser/browser/base/content/test/protectionsUI/cookieServer.sjs"
      );
      break;
    case "first-party-cookie":
      // Since the content blocking log doesn't seem to get updated for
      // top-level cookies right now, we just create an iframe with the
      // first party domain...
      createIframe(
        // eslint-disable-next-line @microsoft/sdl/no-insecure-url
        "http://not-tracking.example.com/browser/browser/base/content/test/protectionsUI/cookieServer.sjs"
      );
      break;
    case "third-party-cookie":
      createIframe(
        "https://test1.example.org/browser/browser/base/content/test/protectionsUI/cookieServer.sjs"
      );
      break;
    case "image":
      createImage(
        // eslint-disable-next-line @microsoft/sdl/no-insecure-url
        "http://trackertest.org/browser/browser/base/content/test/protectionsUI/cookieServer.sjs?type=image-no-cookie"
      );
      break;
    case "window-open":
      window.win = window.open(
        // eslint-disable-next-line @microsoft/sdl/no-insecure-url
        "http://trackertest.org/browser/browser/base/content/test/protectionsUI/cookieServer.sjs",
        "_blank",
        "width=100,height=100"
      );
      break;
    case "window-close":
      window.win.close();
      window.win = null;
      break;
  }
};