Bug 1337964 - SiteDataManager should check correctly if a cookie belongs to a private identity or not, r=aryx, r=gijs
This commit is contained in:
@@ -4205,7 +4205,7 @@ function updateUserContextUIIndicator() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let identity = ContextualIdentityService.getIdentityFromId(userContextId);
|
let identity = ContextualIdentityService.getPublicIdentityFromId(userContextId);
|
||||||
if (!identity) {
|
if (!identity) {
|
||||||
hbox.setAttribute("data-identity-color", "");
|
hbox.setAttribute("data-identity-color", "");
|
||||||
hbox.hidden = true;
|
hbox.hidden = true;
|
||||||
|
|||||||
@@ -475,7 +475,7 @@ function createUserContextMenu(event, {
|
|||||||
docfrag.appendChild(menuseparator);
|
docfrag.appendChild(menuseparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextualIdentityService.getIdentities().forEach(identity => {
|
ContextualIdentityService.getPublicIdentities().forEach(identity => {
|
||||||
if (identity.userContextId == excludeUserContextId) {
|
if (identity.userContextId == excludeUserContextId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1140,7 +1140,7 @@ const CustomizableWidgets = [
|
|||||||
let fragment = doc.createDocumentFragment();
|
let fragment = doc.createDocumentFragment();
|
||||||
let bundle = doc.getElementById("bundle_browser");
|
let bundle = doc.getElementById("bundle_browser");
|
||||||
|
|
||||||
ContextualIdentityService.getIdentities().forEach(identity => {
|
ContextualIdentityService.getPublicIdentities().forEach(identity => {
|
||||||
let label = ContextualIdentityService.getUserContextLabel(identity.userContextId);
|
let label = ContextualIdentityService.getUserContextLabel(identity.userContextId);
|
||||||
|
|
||||||
let item = doc.createElementNS(kNSXUL, "toolbarbutton");
|
let item = doc.createElementNS(kNSXUL, "toolbarbutton");
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ this.SiteDataManager = {
|
|||||||
|
|
||||||
isPrivateCookie(cookie) {
|
isPrivateCookie(cookie) {
|
||||||
let { userContextId } = cookie.originAttributes;
|
let { userContextId } = cookie.originAttributes;
|
||||||
return userContextId && !ContextualIdentityService.getIdentityFromId(userContextId).public;
|
// A private cookie is when its userContextId points to a private identity.
|
||||||
|
return userContextId && !ContextualIdentityService.getPublicIdentityFromId(userContextId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ let gContainersPane = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_rebuildView() {
|
_rebuildView() {
|
||||||
const containers = ContextualIdentityService.getIdentities();
|
const containers = ContextualIdentityService.getPublicIdentities();
|
||||||
while (this._list.firstChild) {
|
while (this._list.firstChild) {
|
||||||
this._list.firstChild.remove();
|
this._list.firstChild.remove();
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ let gContainersPane = {
|
|||||||
};
|
};
|
||||||
let title;
|
let title;
|
||||||
if (userContextId) {
|
if (userContextId) {
|
||||||
identity = ContextualIdentityService.getIdentityFromId(userContextId);
|
identity = ContextualIdentityService.getPublicIdentityFromId(userContextId);
|
||||||
// This is required to get the translation string from defaults
|
// This is required to get the translation string from defaults
|
||||||
identity.name = ContextualIdentityService.getUserContextLabel(identity.userContextId);
|
identity.name = ContextualIdentityService.getUserContextLabel(identity.userContextId);
|
||||||
title = containersBundle.formatStringFromName("containers.updateContainerTitle", [identity.name], 1);
|
title = containersBundle.formatStringFromName("containers.updateContainerTitle", [identity.name], 1);
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ _ContextualIdentityService.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getIdentities() {
|
getPublicIdentities() {
|
||||||
this.ensureDataReady();
|
this.ensureDataReady();
|
||||||
return Cu.cloneInto(this._identities.filter(info => info.public), {});
|
return Cu.cloneInto(this._identities.filter(info => info.public), {});
|
||||||
},
|
},
|
||||||
@@ -254,15 +254,15 @@ _ContextualIdentityService.prototype = {
|
|||||||
return Cu.cloneInto(this._identities.find(info => !info.public && info.name == name), {});
|
return Cu.cloneInto(this._identities.find(info => !info.public && info.name == name), {});
|
||||||
},
|
},
|
||||||
|
|
||||||
getIdentityFromId(userContextId) {
|
getPublicIdentityFromId(userContextId) {
|
||||||
this.ensureDataReady();
|
this.ensureDataReady();
|
||||||
return Cu.cloneInto(this._identities.find(info => info.userContextId == userContextId &&
|
return Cu.cloneInto(this._identities.find(info => info.userContextId == userContextId &&
|
||||||
info.public), {});
|
info.public), {});
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserContextLabel(userContextId) {
|
getUserContextLabel(userContextId) {
|
||||||
let identity = this.getIdentityFromId(userContextId);
|
let identity = this.getPublicIdentityFromId(userContextId);
|
||||||
if (!identity || !identity.public) {
|
if (!identity) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ _ContextualIdentityService.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let userContextId = tab.getAttribute("usercontextid");
|
let userContextId = tab.getAttribute("usercontextid");
|
||||||
let identity = this.getIdentityFromId(userContextId);
|
let identity = this.getPublicIdentityFromId(userContextId);
|
||||||
tab.setAttribute("data-identity-color", identity ? identity.color : "");
|
tab.setAttribute("data-identity-color", identity ? identity.color : "");
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -320,10 +320,10 @@ _ContextualIdentityService.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
telemetry(userContextId) {
|
telemetry(userContextId) {
|
||||||
let identity = this.getIdentityFromId(userContextId);
|
let identity = this.getPublicIdentityFromId(userContextId);
|
||||||
|
|
||||||
// Let's ignore unknown identities for now.
|
// Let's ignore unknown identities for now.
|
||||||
if (!identity || !identity.public) {
|
if (!identity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ add_task(function() {
|
|||||||
cis = ContextualIdentityService.createNewInstanceForTesting(TEST_STORE_FILE_NAME);
|
cis = ContextualIdentityService.createNewInstanceForTesting(TEST_STORE_FILE_NAME);
|
||||||
ok(!!cis, "We have our instance of ContextualIdentityService");
|
ok(!!cis, "We have our instance of ContextualIdentityService");
|
||||||
|
|
||||||
equal(cis.getIdentities().length, 4, "By default, 4 containers.");
|
equal(cis.getPublicIdentities().length, 4, "By default, 4 containers.");
|
||||||
equal(cis.getIdentityFromId(0), null, "No identity with id 0");
|
equal(cis.getPublicIdentityFromId(0), null, "No identity with id 0");
|
||||||
|
|
||||||
ok(!!cis.getIdentityFromId(1), "Identity 1 exists");
|
ok(!!cis.getPublicIdentityFromId(1), "Identity 1 exists");
|
||||||
ok(!!cis.getIdentityFromId(2), "Identity 2 exists");
|
ok(!!cis.getPublicIdentityFromId(2), "Identity 2 exists");
|
||||||
ok(!!cis.getIdentityFromId(3), "Identity 3 exists");
|
ok(!!cis.getPublicIdentityFromId(3), "Identity 3 exists");
|
||||||
ok(!!cis.getIdentityFromId(4), "Identity 4 exists");
|
ok(!!cis.getPublicIdentityFromId(4), "Identity 4 exists");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a new identity
|
// Create a new identity
|
||||||
add_task(function() {
|
add_task(function() {
|
||||||
equal(cis.getIdentities().length, 4, "By default, 4 containers.");
|
equal(cis.getPublicIdentities().length, 4, "By default, 4 containers.");
|
||||||
|
|
||||||
let identity = cis.create("New Container", "Icon", "Color");
|
let identity = cis.create("New Container", "Icon", "Color");
|
||||||
ok(!!identity, "New container created");
|
ok(!!identity, "New container created");
|
||||||
@@ -36,36 +36,36 @@ add_task(function() {
|
|||||||
equal(identity.icon, "Icon", "Icon matches");
|
equal(identity.icon, "Icon", "Icon matches");
|
||||||
equal(identity.color, "Color", "Color matches");
|
equal(identity.color, "Color", "Color matches");
|
||||||
|
|
||||||
equal(cis.getIdentities().length, 5, "Expected 5 containers.");
|
equal(cis.getPublicIdentities().length, 5, "Expected 5 containers.");
|
||||||
|
|
||||||
ok(!!cis.getIdentityFromId(identity.userContextId), "Identity exists");
|
ok(!!cis.getPublicIdentityFromId(identity.userContextId), "Identity exists");
|
||||||
equal(cis.getIdentityFromId(identity.userContextId).name, "New Container", "Identity name is OK");
|
equal(cis.getPublicIdentityFromId(identity.userContextId).name, "New Container", "Identity name is OK");
|
||||||
equal(cis.getIdentityFromId(identity.userContextId).icon, "Icon", "Identity icon is OK");
|
equal(cis.getPublicIdentityFromId(identity.userContextId).icon, "Icon", "Identity icon is OK");
|
||||||
equal(cis.getIdentityFromId(identity.userContextId).color, "Color", "Identity color is OK");
|
equal(cis.getPublicIdentityFromId(identity.userContextId).color, "Color", "Identity color is OK");
|
||||||
equal(cis.getUserContextLabel(identity.userContextId), "New Container", "Identity label is OK");
|
equal(cis.getUserContextLabel(identity.userContextId), "New Container", "Identity label is OK");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove an identity
|
// Remove an identity
|
||||||
add_task(function() {
|
add_task(function() {
|
||||||
equal(cis.getIdentities().length, 5, "Expected 5 containers.");
|
equal(cis.getPublicIdentities().length, 5, "Expected 5 containers.");
|
||||||
|
|
||||||
equal(cis.remove(-1), false, "cis.remove() returns false if identity doesn't exist.");
|
equal(cis.remove(-1), false, "cis.remove() returns false if identity doesn't exist.");
|
||||||
equal(cis.remove(1), true, "cis.remove() returns true if identity exists.");
|
equal(cis.remove(1), true, "cis.remove() returns true if identity exists.");
|
||||||
|
|
||||||
equal(cis.getIdentities().length, 4, "Expected 4 containers.");
|
equal(cis.getPublicIdentities().length, 4, "Expected 4 containers.");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update an identity
|
// Update an identity
|
||||||
add_task(function() {
|
add_task(function() {
|
||||||
ok(!!cis.getIdentityFromId(2), "Identity 2 exists");
|
ok(!!cis.getPublicIdentityFromId(2), "Identity 2 exists");
|
||||||
|
|
||||||
equal(cis.update(-1, "Container", "Icon", "Color"), false, "Update returns true if everything is OK");
|
equal(cis.update(-1, "Container", "Icon", "Color"), false, "Update returns true if everything is OK");
|
||||||
|
|
||||||
equal(cis.update(2, "Container", "Icon", "Color"), true, "Update returns true if everything is OK");
|
equal(cis.update(2, "Container", "Icon", "Color"), true, "Update returns true if everything is OK");
|
||||||
|
|
||||||
ok(!!cis.getIdentityFromId(2), "Identity exists");
|
ok(!!cis.getPublicIdentityFromId(2), "Identity exists");
|
||||||
equal(cis.getIdentityFromId(2).name, "Container", "Identity name is OK");
|
equal(cis.getPublicIdentityFromId(2).name, "Container", "Identity name is OK");
|
||||||
equal(cis.getIdentityFromId(2).icon, "Icon", "Identity icon is OK");
|
equal(cis.getPublicIdentityFromId(2).icon, "Icon", "Identity icon is OK");
|
||||||
equal(cis.getIdentityFromId(2).color, "Color", "Identity color is OK");
|
equal(cis.getPublicIdentityFromId(2).color, "Color", "Identity color is OK");
|
||||||
equal(cis.getUserContextLabel(2), "Container", "Identity label is OK");
|
equal(cis.getUserContextLabel(2), "Container", "Identity label is OK");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ add_task(function() {
|
|||||||
cis = ContextualIdentityService.createNewInstanceForTesting(TEST_STORE_FILE_NAME);
|
cis = ContextualIdentityService.createNewInstanceForTesting(TEST_STORE_FILE_NAME);
|
||||||
ok(!!cis, "We have our instance of ContextualIdentityService");
|
ok(!!cis, "We have our instance of ContextualIdentityService");
|
||||||
|
|
||||||
equal(cis.getIdentities().length, 4, "By default, 4 containers.");
|
equal(cis.getPublicIdentities().length, 4, "By default, 4 containers.");
|
||||||
equal(cis.getIdentityFromId(0), null, "No identity with id 0");
|
equal(cis.getPublicIdentityFromId(0), null, "No identity with id 0");
|
||||||
|
|
||||||
ok(!!cis.getIdentityFromId(1), "Identity 1 exists");
|
ok(!!cis.getPublicIdentityFromId(1), "Identity 1 exists");
|
||||||
ok(!!cis.getIdentityFromId(2), "Identity 2 exists");
|
ok(!!cis.getPublicIdentityFromId(2), "Identity 2 exists");
|
||||||
ok(!!cis.getIdentityFromId(3), "Identity 3 exists");
|
ok(!!cis.getPublicIdentityFromId(3), "Identity 3 exists");
|
||||||
ok(!!cis.getIdentityFromId(4), "Identity 4 exists");
|
ok(!!cis.getPublicIdentityFromId(4), "Identity 4 exists");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a new identity
|
// Create a new identity
|
||||||
add_task(function() {
|
add_task(function() {
|
||||||
equal(cis.getIdentities().length, 4, "By default, 4 containers.");
|
equal(cis.getPublicIdentities().length, 4, "By default, 4 containers.");
|
||||||
|
|
||||||
let identity = cis.create("New Container", "Icon", "Color");
|
let identity = cis.create("New Container", "Icon", "Color");
|
||||||
ok(!!identity, "New container created");
|
ok(!!identity, "New container created");
|
||||||
@@ -36,32 +36,32 @@ add_task(function() {
|
|||||||
equal(identity.icon, "Icon", "Icon matches");
|
equal(identity.icon, "Icon", "Icon matches");
|
||||||
equal(identity.color, "Color", "Color matches");
|
equal(identity.color, "Color", "Color matches");
|
||||||
|
|
||||||
equal(cis.getIdentities().length, 5, "Expected 5 containers.");
|
equal(cis.getPublicIdentities().length, 5, "Expected 5 containers.");
|
||||||
|
|
||||||
ok(!!cis.getIdentityFromId(identity.userContextId), "Identity exists");
|
ok(!!cis.getPublicIdentityFromId(identity.userContextId), "Identity exists");
|
||||||
equal(cis.getIdentityFromId(identity.userContextId).name, "New Container", "Identity name is OK");
|
equal(cis.getPublicIdentityFromId(identity.userContextId).name, "New Container", "Identity name is OK");
|
||||||
equal(cis.getIdentityFromId(identity.userContextId).icon, "Icon", "Identity icon is OK");
|
equal(cis.getPublicIdentityFromId(identity.userContextId).icon, "Icon", "Identity icon is OK");
|
||||||
equal(cis.getIdentityFromId(identity.userContextId).color, "Color", "Identity color is OK");
|
equal(cis.getPublicIdentityFromId(identity.userContextId).color, "Color", "Identity color is OK");
|
||||||
equal(cis.getUserContextLabel(identity.userContextId), "New Container", "Identity label is OK");
|
equal(cis.getUserContextLabel(identity.userContextId), "New Container", "Identity label is OK");
|
||||||
|
|
||||||
// Remove an identity
|
// Remove an identity
|
||||||
equal(cis.remove(-1), false, "cis.remove() returns false if identity doesn't exist.");
|
equal(cis.remove(-1), false, "cis.remove() returns false if identity doesn't exist.");
|
||||||
equal(cis.remove(1), true, "cis.remove() returns true if identity exists.");
|
equal(cis.remove(1), true, "cis.remove() returns true if identity exists.");
|
||||||
|
|
||||||
equal(cis.getIdentities().length, 4, "Expected 4 containers.");
|
equal(cis.getPublicIdentities().length, 4, "Expected 4 containers.");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update an identity
|
// Update an identity
|
||||||
add_task(function() {
|
add_task(function() {
|
||||||
ok(!!cis.getIdentityFromId(2), "Identity 2 exists");
|
ok(!!cis.getPublicIdentityFromId(2), "Identity 2 exists");
|
||||||
|
|
||||||
equal(cis.update(-1, "Container", "Icon", "Color"), false, "Update returns false if the identity doesn't exist");
|
equal(cis.update(-1, "Container", "Icon", "Color"), false, "Update returns false if the identity doesn't exist");
|
||||||
|
|
||||||
equal(cis.update(2, "Container", "Icon", "Color"), true, "Update returns true if everything is OK");
|
equal(cis.update(2, "Container", "Icon", "Color"), true, "Update returns true if everything is OK");
|
||||||
|
|
||||||
ok(!!cis.getIdentityFromId(2), "Identity exists");
|
ok(!!cis.getPublicIdentityFromId(2), "Identity exists");
|
||||||
equal(cis.getIdentityFromId(2).name, "Container", "Identity name is OK");
|
equal(cis.getPublicIdentityFromId(2).name, "Container", "Identity name is OK");
|
||||||
equal(cis.getIdentityFromId(2).icon, "Icon", "Identity icon is OK");
|
equal(cis.getPublicIdentityFromId(2).icon, "Icon", "Identity icon is OK");
|
||||||
equal(cis.getIdentityFromId(2).color, "Color", "Identity color is OK");
|
equal(cis.getPublicIdentityFromId(2).color, "Color", "Identity color is OK");
|
||||||
equal(cis.getUserContextLabel(2), "Container", "Identity label is OK");
|
equal(cis.getUserContextLabel(2), "Container", "Identity label is OK");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ extensions.registerSchemaAPI("contextualIdentities", "addon_parent", context =>
|
|||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
let identity = ContextualIdentityService.getIdentityFromId(containerId);
|
let identity = ContextualIdentityService.getPublicIdentityFromId(containerId);
|
||||||
return Promise.resolve(convert(identity));
|
return Promise.resolve(convert(identity));
|
||||||
},
|
},
|
||||||
|
|
||||||
query(details) {
|
query(details) {
|
||||||
let identities = [];
|
let identities = [];
|
||||||
ContextualIdentityService.getIdentities().forEach(identity => {
|
ContextualIdentityService.getPublicIdentities().forEach(identity => {
|
||||||
if (details.name &&
|
if (details.name &&
|
||||||
ContextualIdentityService.getUserContextLabel(identity.userContextId) != details.name) {
|
ContextualIdentityService.getUserContextLabel(identity.userContextId) != details.name) {
|
||||||
return;
|
return;
|
||||||
@@ -56,7 +56,7 @@ extensions.registerSchemaAPI("contextualIdentities", "addon_parent", context =>
|
|||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
let identity = ContextualIdentityService.getIdentityFromId(containerId);
|
let identity = ContextualIdentityService.getPublicIdentityFromId(containerId);
|
||||||
if (!identity) {
|
if (!identity) {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ extensions.registerSchemaAPI("contextualIdentities", "addon_parent", context =>
|
|||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
let identity = ContextualIdentityService.getIdentityFromId(containerId);
|
let identity = ContextualIdentityService.getPublicIdentityFromId(containerId);
|
||||||
if (!identity) {
|
if (!identity) {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ global.getContainerForCookieStoreId = function(storeId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let containerId = storeId.substring(CONTAINER_STORE.length);
|
let containerId = storeId.substring(CONTAINER_STORE.length);
|
||||||
if (ContextualIdentityService.getIdentityFromId(containerId)) {
|
if (ContextualIdentityService.getPublicIdentityFromId(containerId)) {
|
||||||
return parseInt(containerId, 10);
|
return parseInt(containerId, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user