зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1267910 - Part 2: Update all existing functions of add() and getCookiesFromHost() to make them origin attributes aware. r=jdm, r=mratcliffe
--HG-- extra : rebase_source : 288c9cab8340c5cc06861d4f2c7ee43ae4de608e
This commit is contained in:
Родитель
cc903e433a
Коммит
8ec727cd19
|
@ -388,7 +388,8 @@ function GetCookiesResource(aProfileFolder) {
|
|||
row.getResultByName("secure"),
|
||||
row.getResultByName("httponly"),
|
||||
false,
|
||||
parseInt(expiresUtc));
|
||||
parseInt(expiresUtc),
|
||||
{});
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
|
|
|
@ -646,7 +646,8 @@ Cookies.prototype = {
|
|||
Number(flags) & 0x1, // secure
|
||||
false, // httpOnly
|
||||
false, // session
|
||||
expireTime);
|
||||
expireTime,
|
||||
{});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ add_task(function* () {
|
|||
"Migrated the expected number of encrypted cookies");
|
||||
|
||||
// Now check the cookie details.
|
||||
let enumerator = Services.cookies.getCookiesFromHost(COOKIE.host);
|
||||
let enumerator = Services.cookies.getCookiesFromHost(COOKIE.host, {});
|
||||
Assert.ok(enumerator.hasMoreElements(), "Cookies available");
|
||||
let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ add_task(function* () {
|
|||
"Migrated the expected number of cookies");
|
||||
|
||||
// Now check the cookie details.
|
||||
let enumerator = Services.cookies.getCookiesFromHost(COOKIE.host);
|
||||
let enumerator = Services.cookies.getCookiesFromHost(COOKIE.host, {});
|
||||
Assert.ok(enumerator.hasMoreElements());
|
||||
let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ var SessionCookiesInternal = {
|
|||
if (!Services.cookies.cookieExists(cookieObj)) {
|
||||
Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
|
||||
cookie.value, !!cookie.secure, !!cookie.httponly,
|
||||
/* isSession = */ true, expiry);
|
||||
/* isSession = */ true, expiry, cookie.originAttributes || {});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -417,6 +417,10 @@ var CookieStore = {
|
|||
jscookie.expiry = cookie.expiry;
|
||||
}
|
||||
|
||||
if (cookie.originAttributes) {
|
||||
jscookie.originAttributes = cookie.originAttributes;
|
||||
}
|
||||
|
||||
this._ensureMap(cookie).set(cookie.name, jscookie);
|
||||
},
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ var pktApi = (function() {
|
|||
function getCookiesFromPocket() {
|
||||
|
||||
var cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
|
||||
var pocketCookies = cookieManager.getCookiesFromHost(pocketSiteHost);
|
||||
var pocketCookies = cookieManager.getCookiesFromHost(pocketSiteHost, {});
|
||||
var cookies = {};
|
||||
while (pocketCookies.hasMoreElements()) {
|
||||
var cookie = pocketCookies.getNext().QueryInterface(Ci.nsICookie2);
|
||||
|
|
|
@ -465,8 +465,10 @@ StorageActors.createActor({
|
|||
|
||||
populateStoresForHost(host) {
|
||||
this.hostVsStores.set(host, new Map());
|
||||
let doc = this.storageActor.document;
|
||||
|
||||
let cookies = this.getCookiesFromHost(host);
|
||||
let cookies = this.getCookiesFromHost(host, doc.nodePrincipal
|
||||
.originAttributes);
|
||||
|
||||
for (let cookie of cookies) {
|
||||
if (this.isCookieAtHost(cookie, host)) {
|
||||
|
@ -570,15 +572,22 @@ StorageActors.createActor({
|
|||
* See editCookie() for format details.
|
||||
*/
|
||||
editItem: Task.async(function* (data) {
|
||||
let doc = this.storageActor.document;
|
||||
data.originAttributes = doc.nodePrincipal
|
||||
.originAttributes;
|
||||
this.editCookie(data);
|
||||
}),
|
||||
|
||||
removeItem: Task.async(function* (host, name) {
|
||||
this.removeCookie(host, name);
|
||||
let doc = this.storageActor.document;
|
||||
this.removeCookie(host, name, doc.nodePrincipal
|
||||
.originAttributes);
|
||||
}),
|
||||
|
||||
removeAll: Task.async(function* (host, domain) {
|
||||
this.removeAllCookies(host, domain);
|
||||
let doc = this.storageActor.document;
|
||||
this.removeAllCookies(host, domain, doc.nodePrincipal
|
||||
.originAttributes);
|
||||
}),
|
||||
|
||||
maybeSetupChildProcess() {
|
||||
|
@ -648,13 +657,13 @@ StorageActors.createActor({
|
|||
});
|
||||
|
||||
var cookieHelpers = {
|
||||
getCookiesFromHost(host) {
|
||||
getCookiesFromHost(host, originAttributes) {
|
||||
// Local files have no host.
|
||||
if (host.startsWith("file:///")) {
|
||||
host = "";
|
||||
}
|
||||
|
||||
let cookies = Services.cookies.getCookiesFromHost(host);
|
||||
let cookies = Services.cookies.getCookiesFromHost(host, originAttributes);
|
||||
let store = [];
|
||||
|
||||
while (cookies.hasMoreElements()) {
|
||||
|
@ -698,7 +707,7 @@ var cookieHelpers = {
|
|||
let origPath = field === "path" ? oldValue : data.items.path;
|
||||
let cookie = null;
|
||||
|
||||
let enumerator = Services.cookies.getCookiesFromHost(origHost);
|
||||
let enumerator = Services.cookies.getCookiesFromHost(origHost, data.originAttributes || {});
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let nsiCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
if (nsiCookie.name === origName && nsiCookie.host === origHost) {
|
||||
|
@ -769,7 +778,8 @@ var cookieHelpers = {
|
|||
cookie.isSecure,
|
||||
cookie.isHttpOnly,
|
||||
cookie.isSession,
|
||||
cookie.isSession ? MAX_COOKIE_EXPIRY : cookie.expires
|
||||
cookie.isSession ? MAX_COOKIE_EXPIRY : cookie.expires,
|
||||
cookie.originAttributes
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -784,7 +794,7 @@ var cookieHelpers = {
|
|||
return cookieHost == host;
|
||||
}
|
||||
|
||||
let enumerator = Services.cookies.getCookiesFromHost(host);
|
||||
let enumerator = Services.cookies.getCookiesFromHost(host, opts.originAttributes || {});
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
if (hostMatches(cookie.host, host) &&
|
||||
|
@ -801,14 +811,14 @@ var cookieHelpers = {
|
|||
}
|
||||
},
|
||||
|
||||
removeCookie(host, name) {
|
||||
removeCookie(host, name, originAttributes) {
|
||||
if (name !== undefined) {
|
||||
this._removeCookies(host, { name });
|
||||
this._removeCookies(host, { name, originAttributes });
|
||||
}
|
||||
},
|
||||
|
||||
removeAllCookies(host, domain) {
|
||||
this._removeCookies(host, { domain });
|
||||
removeAllCookies(host, domain, originAttributes) {
|
||||
this._removeCookies(host, { domain, originAttributes });
|
||||
},
|
||||
|
||||
addCookieObservers() {
|
||||
|
@ -861,7 +871,8 @@ var cookieHelpers = {
|
|||
switch (msg.json.method) {
|
||||
case "getCookiesFromHost": {
|
||||
let host = msg.data.args[0];
|
||||
let cookies = cookieHelpers.getCookiesFromHost(host);
|
||||
let originAttributes = msg.data.args[1];
|
||||
let cookies = cookieHelpers.getCookiesFromHost(host, originAttributes);
|
||||
return JSON.stringify(cookies);
|
||||
}
|
||||
case "addCookieObservers": {
|
||||
|
@ -877,12 +888,14 @@ var cookieHelpers = {
|
|||
case "removeCookie": {
|
||||
let host = msg.data.args[0];
|
||||
let name = msg.data.args[1];
|
||||
return cookieHelpers.removeCookie(host, name);
|
||||
let originAttributes = msg.data.args[2];
|
||||
return cookieHelpers.removeCookie(host, name, originAttributes);
|
||||
}
|
||||
case "removeAllCookies": {
|
||||
let host = msg.data.args[0];
|
||||
let domain = msg.data.args[1];
|
||||
return cookieHelpers.removeAllCookies(host, domain);
|
||||
let originAttributes = msg.data.args[2];
|
||||
return cookieHelpers.removeAllCookies(host, domain, originAttributes);
|
||||
}
|
||||
default:
|
||||
console.error("ERR_DIRECTOR_PARENT_UNKNOWN_METHOD", msg.json.method);
|
||||
|
|
|
@ -86,8 +86,11 @@ exports.items = [
|
|||
"see bug 1221488");
|
||||
}
|
||||
let host = new URL(context.environment.target.url).host;
|
||||
let contentWindow = context.environment.window;
|
||||
host = sanitizeHost(host);
|
||||
let enm = cookieMgr.getCookiesFromHost(host);
|
||||
let enm = cookieMgr.getCookiesFromHost(host, contentWindow.document.
|
||||
nodePrincipal.
|
||||
originAttributes);
|
||||
|
||||
let cookies = [];
|
||||
while (enm.hasMoreElements()) {
|
||||
|
@ -128,8 +131,11 @@ exports.items = [
|
|||
"see bug 1221488");
|
||||
}
|
||||
let host = new URL(context.environment.target.url).host;
|
||||
let contentWindow = context.environment.window;
|
||||
host = sanitizeHost(host);
|
||||
let enm = cookieMgr.getCookiesFromHost(host);
|
||||
let enm = cookieMgr.getCookiesFromHost(host, contentWindow.document.
|
||||
nodePrincipal.
|
||||
originAttributes);
|
||||
|
||||
while (enm.hasMoreElements()) {
|
||||
let cookie = enm.getNext().QueryInterface(Ci.nsICookie);
|
||||
|
@ -271,7 +277,7 @@ exports.items = [
|
|||
let host = new URL(context.environment.target.url).host;
|
||||
host = sanitizeHost(host);
|
||||
let time = Date.parse(args.expires) / 1000;
|
||||
|
||||
let contentWindow = context.environment.window;
|
||||
cookieMgr.add(args.domain ? "." + args.domain : host,
|
||||
args.path ? args.path : "/",
|
||||
args.name,
|
||||
|
@ -279,7 +285,10 @@ exports.items = [
|
|||
args.secure,
|
||||
args.httpOnly,
|
||||
args.session,
|
||||
time);
|
||||
time,
|
||||
contentWindow.document.
|
||||
nodePrincipal.
|
||||
originAttributes);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
@ -86,7 +86,7 @@ addMessageListener("init", ({ domain }) => {
|
|||
info(count + " cookies");
|
||||
|
||||
cs.removeAll();
|
||||
cs.add(domain, "", "oh", "hai", false, false, true, Math.pow(2, 62));
|
||||
cs.add(domain, "", "oh", "hai", false, false, true, Math.pow(2, 62), {});
|
||||
is(cs.countCookiesFromHost(domain), 1, "number of cookies for domain " + domain);
|
||||
|
||||
gObs = new obs();
|
||||
|
|
|
@ -13,7 +13,7 @@ function run_test() {
|
|||
|
||||
// test that variants of 'baz.com' get normalized appropriately, but that
|
||||
// malformed hosts are rejected
|
||||
cm.add("baz.com", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("baz.com", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("baz.com"), 1);
|
||||
do_check_eq(cm.countCookiesFromHost("BAZ.com"), 1);
|
||||
do_check_eq(cm.countCookiesFromHost(".baz.com"), 1);
|
||||
|
@ -34,7 +34,7 @@ function run_test() {
|
|||
do_check_eq(cm.countCookiesFromHost("baz.com"), 0);
|
||||
|
||||
// Test that 'baz.com' and 'baz.com.' are treated differently
|
||||
cm.add("baz.com.", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("baz.com.", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("baz.com"), 0);
|
||||
do_check_eq(cm.countCookiesFromHost("BAZ.com"), 0);
|
||||
do_check_eq(cm.countCookiesFromHost(".baz.com"), 0);
|
||||
|
@ -47,7 +47,7 @@ function run_test() {
|
|||
|
||||
// test that domain cookies are illegal for IP addresses, aliases such as
|
||||
// 'localhost', and eTLD's such as 'co.uk'
|
||||
cm.add("192.168.0.1", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("192.168.0.1", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("192.168.0.1"), 1);
|
||||
do_check_eq(cm.countCookiesFromHost("192.168.0.1."), 0);
|
||||
do_check_throws(function() {
|
||||
|
@ -57,7 +57,7 @@ function run_test() {
|
|||
cm.countCookiesFromHost(".192.168.0.1.");
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
cm.add("localhost", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("localhost", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("localhost"), 1);
|
||||
do_check_eq(cm.countCookiesFromHost("localhost."), 0);
|
||||
do_check_throws(function() {
|
||||
|
@ -67,7 +67,7 @@ function run_test() {
|
|||
cm.countCookiesFromHost(".localhost.");
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
cm.add("co.uk", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("co.uk", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("co.uk"), 1);
|
||||
do_check_eq(cm.countCookiesFromHost("co.uk."), 0);
|
||||
do_check_throws(function() {
|
||||
|
@ -105,26 +105,26 @@ function run_test() {
|
|||
cm.countCookiesFromHost("..");
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
var e = cm.getCookiesFromHost("");
|
||||
var e = cm.getCookiesFromHost("", {});
|
||||
do_check_false(e.hasMoreElements());
|
||||
do_check_throws(function() {
|
||||
cm.getCookiesFromHost(".");
|
||||
cm.getCookiesFromHost(".", {});
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
do_check_throws(function() {
|
||||
cm.getCookiesFromHost("..");
|
||||
cm.getCookiesFromHost("..", {});
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
e = cm.getCookiesFromHost("baz.com");
|
||||
e = cm.getCookiesFromHost("baz.com", {});
|
||||
do_check_true(e.hasMoreElements());
|
||||
do_check_eq(e.getNext().QueryInterface(Ci.nsICookie2).name, "foo");
|
||||
do_check_false(e.hasMoreElements());
|
||||
e = cm.getCookiesFromHost("");
|
||||
e = cm.getCookiesFromHost("", {});
|
||||
do_check_false(e.hasMoreElements());
|
||||
do_check_throws(function() {
|
||||
cm.getCookiesFromHost(".");
|
||||
cm.getCookiesFromHost(".", {});
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
do_check_throws(function() {
|
||||
cm.getCookiesFromHost("..");
|
||||
cm.getCookiesFromHost("..", {});
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
cm.removeAll();
|
||||
|
@ -151,26 +151,26 @@ function run_test() {
|
|||
cm.countCookiesFromHost(".");
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
e = cm.getCookiesFromHost("baz.com");
|
||||
e = cm.getCookiesFromHost("baz.com", {});
|
||||
do_check_false(e.hasMoreElements());
|
||||
e = cm.getCookiesFromHost("");
|
||||
e = cm.getCookiesFromHost("", {});
|
||||
do_check_true(e.hasMoreElements());
|
||||
e.getNext();
|
||||
do_check_true(e.hasMoreElements());
|
||||
e.getNext();
|
||||
do_check_false(e.hasMoreElements());
|
||||
do_check_throws(function() {
|
||||
cm.getCookiesFromHost(".");
|
||||
cm.getCookiesFromHost(".", {});
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
cm.removeAll();
|
||||
|
||||
// test that an empty host to add() or remove() works,
|
||||
// but a host of '.' doesn't
|
||||
cm.add("", "/", "foo2", "bar", false, false, true, expiry);
|
||||
cm.add("", "/", "foo2", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(getCookieCount(), 1);
|
||||
do_check_throws(function() {
|
||||
cm.add(".", "/", "foo3", "bar", false, false, true, expiry);
|
||||
cm.add(".", "/", "foo3", "bar", false, false, true, expiry, {});
|
||||
}, Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
do_check_eq(getCookieCount(), 1);
|
||||
|
||||
|
@ -216,13 +216,13 @@ function testDomainCookie(uriString, domain) {
|
|||
|
||||
var uri = NetUtil.newURI(uriString);
|
||||
cs.setCookieString(uri, null, "foo=bar; domain=" + domain, null);
|
||||
var e = cm.getCookiesFromHost(domain);
|
||||
var e = cm.getCookiesFromHost(domain, {});
|
||||
do_check_true(e.hasMoreElements());
|
||||
do_check_eq(e.getNext().QueryInterface(Ci.nsICookie2).host, domain);
|
||||
cm.removeAll();
|
||||
|
||||
cs.setCookieString(uri, null, "foo=bar; domain=." + domain, null);
|
||||
e = cm.getCookiesFromHost(domain);
|
||||
e = cm.getCookiesFromHost(domain, {});
|
||||
do_check_true(e.hasMoreElements());
|
||||
do_check_eq(e.getNext().QueryInterface(Ci.nsICookie2).host, domain);
|
||||
cm.removeAll();
|
||||
|
|
|
@ -10,7 +10,7 @@ function run_test() {
|
|||
|
||||
// Test our handling of host names with a single character at the beginning
|
||||
// followed by a dot.
|
||||
cm.add("e.mail.com", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("e.mail.com", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("e.mail.com"), 1);
|
||||
do_check_eq(cs.getCookieString(NetUtil.newURI("http://e.mail.com"), null), "foo=bar");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ function run_test() {
|
|||
|
||||
// Test our handling of host names with a single character consisting only
|
||||
// of a single character
|
||||
cm.add("a", "/", "foo", "bar", false, false, true, expiry);
|
||||
cm.add("a", "/", "foo", "bar", false, false, true, expiry, {});
|
||||
do_check_eq(cm.countCookiesFromHost("a"), 1);
|
||||
do_check_eq(cs.getCookieString(NetUtil.newURI("http://a"), null), "foo=bar");
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ function run_test_1(generator)
|
|||
|
||||
// Attempt to insert a cookie with the same (name, host, path) triplet.
|
||||
Services.cookiemgr.add(cookie.host, cookie.path, cookie.name, "hallo",
|
||||
cookie.isSecure, cookie.isHttpOnly, cookie.isSession, cookie.expiry);
|
||||
cookie.isSecure, cookie.isHttpOnly, cookie.isSession, cookie.expiry, {});
|
||||
|
||||
// Check that the cookie service accepted the new cookie.
|
||||
do_check_eq(Services.cookiemgr.countCookiesFromHost(cookie.host), 1);
|
||||
|
@ -189,7 +189,7 @@ function run_test_1(generator)
|
|||
do_load_profile();
|
||||
|
||||
do_check_eq(Services.cookiemgr.countCookiesFromHost("foo.com"), 1);
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost(cookie.host);
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost(cookie.host, {});
|
||||
do_check_true(enumerator.hasMoreElements());
|
||||
let dbcookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
do_check_eq(dbcookie.value, "hallo");
|
||||
|
|
|
@ -54,7 +54,7 @@ function do_run_test() {
|
|||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookiemgr.add("foo.com", "", "oh4", "hai", false, false, false, 0);
|
||||
Services.cookiemgr.add("foo.com", "", "oh4", "hai", false, false, false, 0, {});
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
|
@ -76,7 +76,7 @@ function do_run_test() {
|
|||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookies.getCookiesFromHost("foo.com");
|
||||
Services.cookies.getCookiesFromHost("foo.com", {});
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
// Wait for the database to finish closing.
|
||||
|
|
|
@ -68,16 +68,16 @@ function do_run_test()
|
|||
let shortExpiry = Math.floor(Date.now() / 1000 + 2);
|
||||
setCookies("captchart.com", 49, futureExpiry);
|
||||
Services.cookiemgr.add("captchart.com", "", "test100", "eviction",
|
||||
false, false, false, shortExpiry);
|
||||
false, false, false, shortExpiry, {});
|
||||
do_timeout(2100, continue_test);
|
||||
yield;
|
||||
|
||||
do_check_eq(countCookies("captchart.com", "captchart.com"), 50);
|
||||
Services.cookiemgr.add("captchart.com", "", "test200", "eviction",
|
||||
false, false, false, futureExpiry);
|
||||
false, false, false, futureExpiry, {});
|
||||
do_check_eq(countCookies("captchart.com", "captchart.com"), 50);
|
||||
|
||||
enumerator = Services.cookiemgr.getCookiesFromHost("captchart.com");
|
||||
enumerator = Services.cookiemgr.getCookiesFromHost("captchart.com", {});
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
do_check_true(cookie.expiry == futureExpiry);
|
||||
|
@ -92,7 +92,7 @@ setCookies(aHost, aNumber, aExpiry)
|
|||
{
|
||||
for (let i = 0; i < aNumber; ++i)
|
||||
Services.cookiemgr.add(aHost, "", "test" + i, "eviction",
|
||||
false, false, false, aExpiry);
|
||||
false, false, false, aExpiry, {});
|
||||
}
|
||||
|
||||
// count how many cookies are within domain 'aBaseDomain', using three
|
||||
|
@ -123,7 +123,7 @@ countCookies(aBaseDomain, aHost)
|
|||
cookies.length);
|
||||
do_check_eq(Services.cookiemgr.countCookiesFromHost(aHost), cookies.length);
|
||||
|
||||
enumerator = Services.cookiemgr.getCookiesFromHost(aHost);
|
||||
enumerator = Services.cookiemgr.getCookiesFromHost(aHost, {});
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ function set_cookies(begin, end, expiry)
|
|||
for (let i = begin; i < end; ++i) {
|
||||
let host = "eviction." + i + ".tests";
|
||||
Services.cookiemgr.add(host, "", "test", "eviction", false, false, false,
|
||||
expiry);
|
||||
expiry, {});
|
||||
|
||||
if (i == begin)
|
||||
beginTime = get_creationTime(i);
|
||||
|
@ -219,7 +219,7 @@ function set_cookies(begin, end, expiry)
|
|||
function get_creationTime(i)
|
||||
{
|
||||
let host = "eviction." + i + ".tests";
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost(host);
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost(host, {});
|
||||
do_check_true(enumerator.hasMoreElements());
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
return cookie.creationTime;
|
||||
|
|
|
@ -88,7 +88,7 @@ function do_run_test() {
|
|||
// 3) Only one cookie remains, and it's the one with the highest expiration
|
||||
// time.
|
||||
do_check_eq(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost("baz.com");
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost("baz.com", {});
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
do_check_eq(cookie.expiry, futureExpiry + 44);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ function do_run_test() {
|
|||
// 3) Only one cookie remains, and it's the one with the highest expiration
|
||||
// time.
|
||||
do_check_eq(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost("baz.com");
|
||||
let enumerator = Services.cookiemgr.getCookiesFromHost("baz.com", {});
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
do_check_eq(cookie.expiry, futureExpiry + 44);
|
||||
|
||||
|
@ -116,7 +116,7 @@ function do_run_test() {
|
|||
|
||||
// Test the expected set of cookies.
|
||||
do_check_eq(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
enumerator = Services.cookiemgr.getCookiesFromHost("cat.com");
|
||||
enumerator = Services.cookiemgr.getCookiesFromHost("cat.com", {});
|
||||
cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
|
||||
do_check_eq(cookie.creationTime, 0);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ function run_test() {
|
|||
do_check_neq(cm, null, "Retrieving the cookie manager failed");
|
||||
|
||||
const time = (new Date("Jan 1, 2030")).getTime() / 1000;
|
||||
cm.add("example.com", "/", "C", "V", false, true, false, time);
|
||||
cm.add("example.com", "/", "C", "V", false, true, false, time, {});
|
||||
const now = Math.floor((new Date()).getTime() / 1000);
|
||||
|
||||
var enumerator = cm.enumerator, found = false;
|
||||
|
|
|
@ -2095,7 +2095,8 @@ GeckoDriver.prototype.addCookie = function*(cmd, resp) {
|
|||
cookie.secure,
|
||||
cookie.httpOnly,
|
||||
cookie.session,
|
||||
cookie.expiry);
|
||||
cookie.expiry,
|
||||
{}); // originAttributes
|
||||
return true;
|
||||
};
|
||||
this.mm.addMessageListener("Marionette:addCookie", cb);
|
||||
|
@ -2653,7 +2654,7 @@ GeckoDriver.prototype.receiveMessage = function(message) {
|
|||
let isForCurrentPath = path => currentPath.indexOf(path) != -1;
|
||||
let results = [];
|
||||
|
||||
let en = cookieManager.getCookiesFromHost(host);
|
||||
let en = cookieManager.getCookiesFromHost(host, {});
|
||||
while (en.hasMoreElements()) {
|
||||
let cookie = en.getNext().QueryInterface(Ci.nsICookie2);
|
||||
// take the hostname and progressively shorten
|
||||
|
|
|
@ -146,13 +146,13 @@ function* query(detailsIn, props, extension) {
|
|||
if ("url" in details) {
|
||||
try {
|
||||
uri = NetUtil.newURI(details.url).QueryInterface(Ci.nsIURL);
|
||||
enumerator = Services.cookies.getCookiesFromHost(uri.host);
|
||||
enumerator = Services.cookies.getCookiesFromHost(uri.host, {});
|
||||
} catch (ex) {
|
||||
// This often happens for about: URLs
|
||||
return;
|
||||
}
|
||||
} else if ("domain" in details) {
|
||||
enumerator = Services.cookies.getCookiesFromHost(details.domain);
|
||||
enumerator = Services.cookies.getCookiesFromHost(details.domain, {});
|
||||
} else {
|
||||
enumerator = Services.cookies.enumerator;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ extensions.registerSchemaAPI("cookies", "cookies", (extension, context) => {
|
|||
// The permission check may have modified the domain, so use
|
||||
// the new value instead.
|
||||
Services.cookies.add(cookieAttrs.host, path, name, value,
|
||||
secure, httpOnly, isSession, expiry);
|
||||
secure, httpOnly, isSession, expiry, {});
|
||||
|
||||
return self.cookies.get(details);
|
||||
},
|
||||
|
|
|
@ -126,7 +126,7 @@ function* testCookies(options) {
|
|||
|
||||
function getCookies(host) {
|
||||
let cookies = [];
|
||||
let enum_ = cookieSvc.getCookiesFromHost(host);
|
||||
let enum_ = cookieSvc.getCookiesFromHost(host, {});
|
||||
while (enum_.hasMoreElements()) {
|
||||
cookies.push(enum_.getNext().QueryInterface(SpecialPowers.Ci.nsICookie2));
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ this.ForgetAboutSite = {
|
|||
// Cookies
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].
|
||||
getService(Ci.nsICookieManager2);
|
||||
let enumerator = cm.getCookiesFromHost(aDomain);
|
||||
let enumerator = cm.getCookiesFromHost(aDomain, {});
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);
|
||||
cm.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
|
||||
|
|
|
@ -83,7 +83,7 @@ function add_cookie(aDomain)
|
|||
check_cookie_exists(aDomain, false);
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
|
||||
cm.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
|
||||
COOKIE_EXPIRY);
|
||||
COOKIE_EXPIRY, {});
|
||||
check_cookie_exists(aDomain, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ function test() {
|
|||
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
|
||||
.getService(Components.interfaces.nsICookieManager2);
|
||||
cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
|
||||
false, true, (Date.now() / 1000) + 60);
|
||||
false, true, (Date.now() / 1000) + 60, {});
|
||||
|
||||
var pm = Services.perms;
|
||||
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
||||
|
|
|
@ -10,7 +10,7 @@ function test() {
|
|||
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
|
||||
.getService(Components.interfaces.nsICookieManager2);
|
||||
cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
|
||||
false, true, (Date.now() / 1000) + 60);
|
||||
false, true, (Date.now() / 1000) + 60, {});
|
||||
|
||||
var pm = Services.perms;
|
||||
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
||||
|
|
|
@ -11,7 +11,7 @@ function test() {
|
|||
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
|
||||
.getService(Components.interfaces.nsICookieManager2);
|
||||
cm.add("example.org", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
|
||||
false, true, (Date.now() / 1000) + 60);
|
||||
false, true, (Date.now() / 1000) + 60, {});
|
||||
|
||||
var pm = Services.perms;
|
||||
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
||||
|
|
Загрузка…
Ссылка в новой задаче