blob: e4ae649d0a676d9a342025ec12dddc1114894e1e (
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
async function openTabInUserContext(uri, userContextId) {
// open the tab in the correct userContextId
let tab = BrowserTestUtils.addTab(gBrowser, uri, { userContextId });
let browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser, false, uri);
return { tab };
}
/**
* When a container's colour changes, the tab colour should update.
*/
add_task(async function test_tab_color_updates() {
const kId = 2;
let { tab } = await openTabInUserContext("https://example.com/", kId);
let contextIdInfo = ContextualIdentityService.getPublicIdentityFromId(kId);
ok(
tab.classList.contains("identity-color-" + contextIdInfo.color),
`Should use color ${contextIdInfo.color} for tab`
);
// The container has a localized name which isn't in the contextIdInfo object.
// We need to pass a valid name for the update to go through, so make one up.
let name = "Foo";
// Don't hardcode a colour so changes in defaults won't cause the following
// test to fail or be a no-op.
let otherColor = contextIdInfo.color == "green" ? "orange" : "green";
registerCleanupFunction(() => ContextualIdentityService.resetDefault());
ContextualIdentityService.update(kId, name, contextIdInfo.icon, otherColor);
ok(
tab.classList.contains("identity-color-" + otherColor),
`Should use color ${otherColor} for tab after update`
);
BrowserTestUtils.removeTab(tab);
});
|