зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1407695 - Do not return expiry key for session cookies; r=ato
MozReview-Commit-ID: 7qAgwSZx9JI --HG-- extra : rebase_source : bc59f1b653b61f262a10e366cc88a4bcd535b4e2
This commit is contained in:
Родитель
076182907c
Коммит
d6d4b4b5e4
|
@ -206,15 +206,20 @@ cookie.iter = function* (host, currentPath = "/") {
|
||||||
do {
|
do {
|
||||||
if ((cookie.host == "." + hostname || cookie.host == hostname) &&
|
if ((cookie.host == "." + hostname || cookie.host == hostname) &&
|
||||||
isForCurrentPath(cookie.path)) {
|
isForCurrentPath(cookie.path)) {
|
||||||
yield {
|
let data = {
|
||||||
"name": cookie.name,
|
"name": cookie.name,
|
||||||
"value": cookie.value,
|
"value": cookie.value,
|
||||||
"path": cookie.path,
|
"path": cookie.path,
|
||||||
"domain": cookie.host,
|
"domain": cookie.host,
|
||||||
"secure": cookie.isSecure,
|
"secure": cookie.isSecure,
|
||||||
"httpOnly": cookie.isHttpOnly,
|
"httpOnly": cookie.isHttpOnly,
|
||||||
"expiry": cookie.expiry,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!cookie.isSession) {
|
||||||
|
data["expiry"] = cookie.expiry;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield data;
|
||||||
}
|
}
|
||||||
hostname = hostname.replace(/^.*?\./, "");
|
hostname = hostname.replace(/^.*?\./, "");
|
||||||
} while (hostname.indexOf(".") != -1);
|
} while (hostname.indexOf(".") != -1);
|
||||||
|
|
|
@ -24,7 +24,7 @@ cookie.manager = {
|
||||||
cookie.manager.cookies.push(newCookie);
|
cookie.manager.cookies.push(newCookie);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function (host, name, path, blocked, originAttributes) {;
|
remove: function (host, name, path, blocked, originAttributes) {
|
||||||
for (let i = 0; i < this.cookies.length; ++i) {
|
for (let i = 0; i < this.cookies.length; ++i) {
|
||||||
let candidate = this.cookies[i];
|
let candidate = this.cookies[i];
|
||||||
if (candidate.host === host &&
|
if (candidate.host === host &&
|
||||||
|
@ -248,11 +248,39 @@ add_test(function test_remove() {
|
||||||
add_test(function test_iter() {
|
add_test(function test_iter() {
|
||||||
cookie.manager.cookies = [];
|
cookie.manager.cookies = [];
|
||||||
|
|
||||||
cookie.add({name: "0", value: "", domain: "foo.example.com"});
|
cookie.add({
|
||||||
cookie.add({name: "1", value: "", domain: "bar.example.com"});
|
session: false,
|
||||||
|
name: "0",
|
||||||
|
value: "",
|
||||||
|
domain: "foo.example.com",
|
||||||
|
});
|
||||||
|
cookie.add({
|
||||||
|
session: false,
|
||||||
|
name: "1",
|
||||||
|
value: "",
|
||||||
|
domain: "bar.example.com",
|
||||||
|
});
|
||||||
|
|
||||||
let fooCookies = [...cookie.iter("foo.example.com")];
|
let fooCookies = [...cookie.iter("foo.example.com")];
|
||||||
equal(1, fooCookies.length);
|
equal(1, fooCookies.length);
|
||||||
equal(".foo.example.com", fooCookies[0].domain);
|
equal(".foo.example.com", fooCookies[0].domain);
|
||||||
|
equal(true, fooCookies[0].hasOwnProperty("expiry"));
|
||||||
|
|
||||||
|
// here we're explicitly setting session to true as a workaround until
|
||||||
|
// bug 1408962 has been fixed. when that bug has been fixed the cookie
|
||||||
|
// will be created as session cookie simply by leaving out the 'expiry'
|
||||||
|
// property.
|
||||||
|
cookie.add({
|
||||||
|
session: true,
|
||||||
|
name: "aSessionCookie",
|
||||||
|
value: "",
|
||||||
|
domain: "session.com",
|
||||||
|
});
|
||||||
|
|
||||||
|
let sessionCookies = [...cookie.iter("session.com")];
|
||||||
|
equal(1, sessionCookies.length);
|
||||||
|
equal("aSessionCookie", sessionCookies[0].name);
|
||||||
|
equal(false, sessionCookies[0].hasOwnProperty("expiry"));
|
||||||
|
|
||||||
run_next_test();
|
run_next_test();
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче