summaryrefslogtreecommitdiffstats
path: root/toolkit/components/antitracking/bouncetrackingprotection/test/browser/browser_bouncetracking_stateful.js
blob: e7fb4521a7cfa97aa6068039d8c0c3b9adc5a2af (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

let bounceTrackingProtection;

add_setup(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["privacy.bounceTrackingProtection.requireStatefulBounces", true],
      ["privacy.bounceTrackingProtection.bounceTrackingGracePeriodSec", 0],
    ],
  });
  bounceTrackingProtection = Cc[
    "@mozilla.org/bounce-tracking-protection;1"
  ].getService(Ci.nsIBounceTrackingProtection);
});

// Cookie tests.

add_task(async function test_bounce_stateful_cookies_client() {
  info("Test client bounce with cookie.");
  await runTestBounce({
    bounceType: "client",
    setState: "cookie-client",
  });
  info("Test client bounce without cookie.");
  await runTestBounce({
    bounceType: "client",
    setState: null,
    expectCandidate: false,
    expectPurge: false,
  });
});

add_task(async function test_bounce_stateful_cookies_server() {
  info("Test server bounce with cookie.");
  await runTestBounce({
    bounceType: "server",
    setState: "cookie-server",
  });
  info("Test server bounce without cookie.");
  await runTestBounce({
    bounceType: "server",
    setState: null,
    expectCandidate: false,
    expectPurge: false,
  });
});

// Storage tests.

// TODO: Bug 1848406: Implement stateful bounce detection for localStorage.
add_task(async function test_bounce_stateful_localStorage() {
  info("TODO: client bounce with localStorage.");
  await runTestBounce({
    bounceType: "client",
    setState: "localStorage",
    expectCandidate: false,
    expectPurge: false,
  });
});