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

"use strict";

add_setup(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["privacy.bounceTrackingProtection.requireStatefulBounces", true],
      ["privacy.bounceTrackingProtection.bounceTrackingGracePeriodSec", 0],
    ],
  });
});

// Tests that bounces in PBM don't affect state in normal browsing.
add_task(async function test_pbm_data_isolated() {
  await runTestBounce({
    bounceType: "client",
    setState: "cookie-client",
    originAttributes: { privateBrowsingId: 1 },
    postBounceCallback: () => {
      // After the PBM bounce assert that we haven't recorded any data for normal browsing.
      Assert.equal(
        bounceTrackingProtection.testGetBounceTrackerCandidateHosts({}).length,
        0,
        "No bounce tracker candidates for normal browsing."
      );
      Assert.equal(
        bounceTrackingProtection.testGetUserActivationHosts({}).length,
        0,
        "No user activations for normal browsing."
      );
    },
  });
});

// Tests that bounces in PBM don't affect state in normal browsing.
add_task(async function test_containers_isolated() {
  await runTestBounce({
    bounceType: "server",
    setState: "cookie-server",
    originAttributes: { userContextId: 2 },
    postBounceCallback: () => {
      // After the bounce in the container tab assert that we haven't recorded any data for normal browsing.
      Assert.equal(
        bounceTrackingProtection.testGetBounceTrackerCandidateHosts({}).length,
        0,
        "No bounce tracker candidates for normal browsing."
      );
      Assert.equal(
        bounceTrackingProtection.testGetUserActivationHosts({}).length,
        0,
        "No user activations for normal browsing."
      );

      // Or in another container tab.
      Assert.equal(
        bounceTrackingProtection.testGetBounceTrackerCandidateHosts({
          userContextId: 1,
        }).length,
        0,
        "No bounce tracker candidates for container tab 1."
      );
      Assert.equal(
        bounceTrackingProtection.testGetUserActivationHosts({
          userContextId: 1,
        }).length,
        0,
        "No user activations for container tab 1."
      );
    },
  });
});