// Check if expired cookies are evicted first.
await new Promise(resolve => do_timeout(EXPIRED_TIME * 1000, resolve));
await setCookie("session_foo_path_8", null, "/foo", null, FOO_PATH);
verifyCookies(
["session_foo_path_6", "session_foo_path_7", "session_foo_path_8"],
BASE_URI
);
Services.cookies.removeAll();
});
// Verify that the given cookie names exist, and are ordered from least to most recently accessed function verifyCookies(names, uri) { Assert.equal(Services.cookies.countCookiesFromHost(uri.host), names.length);
let actual_cookies = []; for (let cookie of Services.cookies.getCookiesFromHost(uri.host, {})) {
actual_cookies.push(cookie);
} if (names.length != actual_cookies.length) {
let left = names.filter(function (n) { return (
actual_cookies.findIndex(function (c) { return c.name == n;
}) == -1
);
});
let right = actual_cookies
.filter(function (c) { return (
names.findIndex(function (n) { return c.name == n;
}) == -1
);
})
.map(function (c) { return c.name;
}); if (left.length) {
info("unexpected cookies: " + left);
} if (right.length) {
info("expected cookies: " + right);
}
} Assert.equal(names.length, actual_cookies.length);
actual_cookies.sort(function (a, b) { if (a.lastAccessed < b.lastAccessed) { return -1;
} if (a.lastAccessed > b.lastAccessed) { return 1;
} return 0;
}); for (var i = 0; i < names.length; i++) { Assert.equal(names[i], actual_cookies[i].name); Assert.equal(names[i].startsWith("session"), actual_cookies[i].isSession);
}
}
var lastValue = 0; function setCookie(name, domain, path, maxAge, url) {
let value = name + "=" + ++lastValue; var s = "setting cookie " + value; if (domain) {
value += "; Domain=" + domain;
s += " (d=" + domain + ")";
} if (path) {
value += "; Path=" + path;
s += " (p=" + path + ")";
} if (maxAge) {
value += "; Max-Age=" + maxAge;
s += " (non-session)";
} else {
s += " (session)";
}
s += " for " + url.spec;
info(s);
returnnew Promise(function (resolve) { // Windows XP has low precision timestamps that cause our cookie eviction // algorithm to produce different results from other platforms. We work around // this by ensuring that there's a clear gap between each cookie update.
do_timeout(10, resolve);
});
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.