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
|
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
// Supported for creating normal windows is very limited in Thunderbird, a url
// in the createData is ignored for example. This test only verifies that all the
// things that are officially not supported, fail.
add_task(async function no_cookies_permission() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.userContext.enabled", true]],
});
let extension = ExtensionTestUtils.loadExtension({
async background() {
await browser.test.assertRejects(
browser.windows.create({ cookieStoreId: "firefox-container-1" }),
/No permission for cookieStoreId/,
"cookieStoreId requires cookies permission"
);
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
add_task(async function invalid_cookieStoreId() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.userContext.enabled", true]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["cookies"],
},
async background() {
await browser.test.assertRejects(
browser.windows.create({ cookieStoreId: "not-firefox-container-1" }),
/Illegal cookieStoreId/,
"cookieStoreId must be valid"
);
await browser.test.assertRejects(
browser.windows.create({ cookieStoreId: "firefox-private" }),
/Illegal to set private cookieStoreId in a non-private window/,
"cookieStoreId cannot be private in a non-private window"
);
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
add_task(async function userContext_disabled() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.userContext.enabled", false]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs", "cookies"],
},
async background() {
await browser.test.assertRejects(
browser.windows.create({ cookieStoreId: "firefox-container-1" }),
/Contextual identities are currently disabled/,
"cookieStoreId cannot be a container tab ID when contextual identities are disabled"
);
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
await SpecialPowers.popPrefEnv();
});
add_task(async function cookieStoreId_and_tabId() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.userContext.enabled", true]],
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["cookies"],
},
async background() {
for (let cookieStoreId of ["firefox-default", "firefox-container-1"]) {
let { id: normalTabId } = await browser.tabs.create({ cookieStoreId });
await browser.test.assertRejects(
browser.windows.create({
cookieStoreId: "firefox-container-2",
tabId: normalTabId,
}),
/`tabId` may not be used in conjunction with `cookieStoreId`/,
"Cannot use cookieStoreId for pre-existing tabs"
);
await browser.tabs.remove(normalTabId);
}
browser.test.sendMessage("done");
},
});
await extension.startup();
await extension.awaitMessage("done");
await extension.unload();
});
|