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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
add_task(async function () {
info("Starting doubly nested tracker test");
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({
set: [
[
"network.cookie.cookieBehavior",
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
],
[
"network.cookie.cookieBehavior.pbmode",
Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER,
],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],
["privacy.trackingprotection.annotate_channels", true],
[
"privacy.restrict3rdpartystorage.userInteractionRequiredForHosts",
"tracking.example.com,tracking.example.org",
],
// Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default"
["network.cookie.sameSite.laxByDefault", false],
],
});
await UrlClassifierTestUtils.addTestTrackers();
let tab = BrowserTestUtils.addTab(gBrowser, TEST_3RD_PARTY_PAGE);
gBrowser.selectedTab = tab;
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
async function loadSubpage() {
async function runChecks() {
is(document.cookie, "", "No cookies for me");
document.cookie = "name=value";
is(document.cookie, "", "I don't have the cookies!");
}
await new Promise(resolve => {
let ifr = document.createElement("iframe");
ifr.onload = _ => {
info("Sending code to the 3rd party content");
ifr.contentWindow.postMessage(runChecks.toString(), "*");
};
addEventListener("message", function msg(event) {
if (event.data.type == "finish") {
removeEventListener("message", msg);
resolve();
return;
}
if (event.data.type == "ok") {
ok(event.data.what, event.data.msg);
return;
}
if (event.data.type == "info") {
info(event.data.msg);
return;
}
ok(false, "Unknown message");
});
document.body.appendChild(ifr);
ifr.src =
"https://tracking.example.org/browser/toolkit/components/antitracking/test/browser/3rdParty.html";
});
}
// We need to use the same scheme in Fission test.
let testAnotherThirdPartyPage = SpecialPowers.useRemoteSubframes
? TEST_ANOTHER_3RD_PARTY_PAGE_HTTPS
: TEST_ANOTHER_3RD_PARTY_PAGE;
await SpecialPowers.spawn(
browser,
[{ page: testAnotherThirdPartyPage, callback: loadSubpage.toString() }],
async function (obj) {
await new content.Promise(resolve => {
let ifr = content.document.createElement("iframe");
ifr.onload = _ => {
info("Sending code to the 3rd party content");
ifr.contentWindow.postMessage(obj.callback, "*");
};
content.addEventListener("message", function msg(event) {
if (event.data.type == "finish") {
content.removeEventListener("message", msg);
resolve();
return;
}
if (event.data.type == "ok") {
ok(event.data.what, event.data.msg);
return;
}
if (event.data.type == "info") {
info(event.data.msg);
return;
}
ok(false, "Unknown message");
});
content.document.body.appendChild(ifr);
ifr.src = obj.page;
});
}
);
BrowserTestUtils.removeTab(tab);
UrlClassifierTestUtils.cleanupTestTrackers();
});
add_task(async function () {
info("Cleaning up.");
SpecialPowers.clearUserPref("network.cookie.sameSite.laxByDefault");
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
resolve()
);
});
});
|