--- a/toolkit/components/extensions/ext-contextualIdentities.js
+++ b/toolkit/components/extensions/ext-contextualIdentities.js
@@ -14,32 +14,38 @@ const CONTAINER_PREF_INSTALL_DEFAULTS =
"privacy.userContext.enabled": true,
"privacy.userContext.longPressBehavior": 2,
"privacy.userContext.ui.enabled": true,
"privacy.usercontext.about_newtab_segregation.enabled": true,
};
const CONTAINERS_ENABLED_SETTING_NAME = "privacy.containers";
+function getContainerIcon(iconName) {
+ return `resource://gre-resources/usercontext/${iconName}.svg`;
+}
+
const convertIdentity = identity => {
let result = {
name: ContextualIdentityService.getUserContextLabel(identity.userContextId),
icon: identity.icon,
+ iconUrl: getContainerIcon(identity.icon),
color: identity.color,
cookieStoreId: getCookieStoreIdForContainer(identity.userContextId),
};
return result;
};
const convertIdentityFromObserver = wrappedIdentity => {
let identity = wrappedIdentity.wrappedJSObject;
let result = {
name: identity.name,
icon: identity.icon,
+ iconUrl: getContainerIcon(identity.icon),
color: identity.color,
cookieStoreId: getCookieStoreIdForContainer(identity.userContextId),
};
return result;
};
ExtensionPreferencesManager.addSetting(CONTAINERS_ENABLED_SETTING_NAME, {
--- a/toolkit/components/extensions/test/xpcshell/test_ext_contextual_identities.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_contextual_identities.js
@@ -44,46 +44,49 @@ add_task(async function test_contextualI
resolve(change);
};
browser.contextualIdentities[type].addListener(listener);
} catch (e) {
reject(e);
}
});
}
+ function iconUrl(iconName) {
+ return `resource://gre-resources/usercontext/${iconName}.svg`;
+ }
function assertExpected(expected, container) {
for (let key of Object.keys(container)) {
browser.test.assertTrue(key in expected, `found property ${key}`);
browser.test.assertEq(expected[key], container[key], `property value for ${key} is correct`);
}
browser.test.assertEq(Object.keys(expected).length, Object.keys(container).length, "all expected properties found");
}
let onCreatePromise = createOneTimeListener("onCreated");
let containerObj = {name: "foobar", color: "red", icon: "icon"};
let ci = await browser.contextualIdentities.create(containerObj);
browser.test.assertTrue(!!ci, "We have an identity");
const onCreateListenerResponse = await onCreatePromise;
const cookieStoreId = ci.cookieStoreId;
- assertExpected(onCreateListenerResponse.contextualIdentity, Object.assign(containerObj, {cookieStoreId}));
+ assertExpected(onCreateListenerResponse.contextualIdentity, Object.assign(containerObj, {cookieStoreId, iconUrl: iconUrl(containerObj.icon)}));
let onUpdatedPromise = createOneTimeListener("onUpdated");
let updateContainerObj = {name: "testing", color: "blue", icon: "thing"};
ci = await browser.contextualIdentities.update(cookieStoreId, updateContainerObj);
browser.test.assertTrue(!!ci, "We have an update identity");
const onUpdatedListenerResponse = await onUpdatedPromise;
- assertExpected(onUpdatedListenerResponse.contextualIdentity, Object.assign(updateContainerObj, {cookieStoreId}));
+ assertExpected(onUpdatedListenerResponse.contextualIdentity, Object.assign(updateContainerObj, {cookieStoreId, iconUrl: iconUrl(containerObj.icon)}));
let onRemovePromise = createOneTimeListener("onRemoved");
ci = await browser.contextualIdentities.remove(updateContainerObj.cookieStoreId);
browser.test.assertTrue(!!ci, "We have an remove identity");
const onRemoveListenerResponse = await onRemovePromise;
- assertExpected(onRemoveListenerResponse.contextualIdentity, Object.assign(updateContainerObj, {cookieStoreId}));
+ assertExpected(onRemoveListenerResponse.contextualIdentity, Object.assign(updateContainerObj, {cookieStoreId, iconUrl: iconUrl(updateContainerObj.icon)}));
browser.test.notifyPass("contextualIdentities_events");
}
let extension = ExtensionTestUtils.loadExtension({
background,
useAddonManager: "temporary",
manifest: {