зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1766228) for causing lint failures on test_restrequest.js CLOSED TREE
Backed out changeset 5ff1634cfe18 (bug 1766228) Backed out changeset 01642c97e7a5 (bug 1766228) Backed out changeset cbba28151712 (bug 1766228) Backed out changeset 76a32127865d (bug 1766228) Backed out changeset 2c7ef1ad380a (bug 1766228)
This commit is contained in:
Родитель
1be10545ab
Коммит
7cd43cc697
|
@ -12,8 +12,6 @@
|
|||
// This fixture is probably doing too much and should be reduced to the minimum
|
||||
// needed to pass the tests.
|
||||
|
||||
/* eslint-disable mozilla/valid-services */
|
||||
|
||||
// Some constants from nsIPrefBranch.idl.
|
||||
const PREF_INVALID = 0;
|
||||
const PREF_STRING = 32;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
valid-services
|
||||
==============
|
||||
|
||||
Ensures that accesses of the ``Services`` object are valid.
|
||||
|
||||
Examples of incorrect code for this rule:
|
||||
-----------------------------------------
|
||||
|
||||
Assuming ``foo`` is not defined within Services.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
Services.foo.fn();
|
||||
|
||||
Examples of correct code for this rule:
|
||||
---------------------------------------
|
||||
|
||||
Assuming ``bar`` is defined within Services.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
Services.bar.fn();
|
|
@ -61,9 +61,7 @@ Classes = [
|
|||
'js_name': 'uriFixup',
|
||||
'cid': '{c6cf88b7-452e-47eb-bdc9-86e3561648ef}',
|
||||
'contract_ids': ['@mozilla.org/docshell/uri-fixup;1'],
|
||||
'interfaces': ['nsIURIFixup'],
|
||||
'jsm': 'resource://gre/modules/URIFixup.jsm',
|
||||
'singleton': True,
|
||||
'constructor': 'URIFixup',
|
||||
},
|
||||
{
|
||||
|
|
|
@ -578,7 +578,7 @@ Classes = [
|
|||
'@mozilla.org/cookieService;1',
|
||||
'@mozilla.org/cookiemanager;1',
|
||||
],
|
||||
'interfaces': ['nsICookieService', 'nsICookieManager'],
|
||||
'interfaces': ['nsICookieManager'],
|
||||
'singleton': True,
|
||||
'type': 'nsICookieService',
|
||||
'constructor': 'mozilla::net::CookieService::GetXPCOMSingleton',
|
||||
|
|
|
@ -3,6 +3,8 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
const URI = Services.io.newURI("http://example.org/");
|
||||
|
||||
const cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
function run_test() {
|
||||
// Allow all cookies.
|
||||
Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
|
||||
|
@ -79,7 +81,7 @@ function setCookie(value, expected) {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(URI, valueInternal, channel);
|
||||
cs.setCookieStringFromHttp(URI, valueInternal, channel);
|
||||
Services.obs.removeObserver(observer, "cookie-changed");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ add_task(async () => {
|
|||
true
|
||||
);
|
||||
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
let uri = NetUtil.newURI("http://example.org/");
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -26,9 +28,9 @@ add_task(async () => {
|
|||
|
||||
let set = "foo=bar\nbaz=foo";
|
||||
let expected = "foo=bar; baz=foo";
|
||||
Services.cookies.setCookieStringFromHttp(uri, set, channel);
|
||||
cs.setCookieStringFromHttp(uri, set, channel);
|
||||
|
||||
let actual = Services.cookies.getCookieStringFromHttp(uri, channel);
|
||||
let actual = cs.getCookieStringFromHttp(uri, channel);
|
||||
Assert.equal(actual, expected);
|
||||
|
||||
await CookieXPCShellUtils.setCookieToDocument("http://example.net/", set);
|
||||
|
|
|
@ -193,7 +193,8 @@ function setCookie(name, domain, path, maxAge, url) {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(url, value, channel);
|
||||
const cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
cs.setCookieStringFromHttp(url, value, channel);
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
// Windows XP has low precision timestamps that cause our cookie eviction
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
const cm = cs.QueryInterface(Ci.nsICookieManager);
|
||||
|
||||
function setCookie(name, url) {
|
||||
let value = `${name}=${Math.random()}; Path=/; Max-Age=1000; sameSite=none; Secure`;
|
||||
info(`Setting cookie ${value} for ${url.spec}`);
|
||||
|
@ -11,7 +14,7 @@ function setCookie(name, url) {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(url, value, channel);
|
||||
cs.setCookieStringFromHttp(url, value, channel);
|
||||
}
|
||||
|
||||
async function sleep() {
|
||||
|
@ -46,26 +49,24 @@ add_task(async function() {
|
|||
await setCookie("D", Services.io.newURI("https://example.com/D/"));
|
||||
await sleep();
|
||||
|
||||
Assert.equal(Services.cookies.cookies.length, 4, "Cookie check");
|
||||
Assert.equal(cm.cookies.length, 4, "Cookie check");
|
||||
|
||||
const cookies = Services.cookies.getCookiesSince(0);
|
||||
const cookies = cm.getCookiesSince(0);
|
||||
Assert.equal(cookies.length, 4, "We retrieve all the 4 cookies");
|
||||
checkSorting(cookies);
|
||||
|
||||
let someCookies = Services.cookies.getCookiesSince(
|
||||
cookies[0].creationTime + 1
|
||||
);
|
||||
let someCookies = cm.getCookiesSince(cookies[0].creationTime + 1);
|
||||
Assert.equal(someCookies.length, 3, "We retrieve some cookies");
|
||||
checkSorting(someCookies);
|
||||
|
||||
someCookies = Services.cookies.getCookiesSince(cookies[1].creationTime + 1);
|
||||
someCookies = cm.getCookiesSince(cookies[1].creationTime + 1);
|
||||
Assert.equal(someCookies.length, 2, "We retrieve some cookies");
|
||||
checkSorting(someCookies);
|
||||
|
||||
someCookies = Services.cookies.getCookiesSince(cookies[2].creationTime + 1);
|
||||
someCookies = cm.getCookiesSince(cookies[2].creationTime + 1);
|
||||
Assert.equal(someCookies.length, 1, "We retrieve some cookies");
|
||||
checkSorting(someCookies);
|
||||
|
||||
someCookies = Services.cookies.getCookiesSince(cookies[3].creationTime + 1);
|
||||
someCookies = cm.getCookiesSince(cookies[3].creationTime + 1);
|
||||
Assert.equal(someCookies.length, 0, "We retrieve some cookies");
|
||||
});
|
||||
|
|
|
@ -15,6 +15,8 @@ function run_test() {
|
|||
);
|
||||
}
|
||||
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
let uri = NetUtil.newURI("http://example.org/");
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -23,9 +25,9 @@ function run_test() {
|
|||
});
|
||||
|
||||
let set = "foo=bar";
|
||||
Services.cookies.setCookieStringFromHttp(uri, set, channel);
|
||||
cs.setCookieStringFromHttp(uri, set, channel);
|
||||
|
||||
let expected = "foo=bar";
|
||||
let actual = Services.cookies.getCookieStringFromHttp(uri, channel);
|
||||
let actual = cs.getCookieStringFromHttp(uri, channel);
|
||||
Assert.equal(actual, expected);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ function run_test() {
|
|||
);
|
||||
}
|
||||
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
let uri = NetUtil.newURI("http://example.org/");
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -23,9 +25,9 @@ function run_test() {
|
|||
});
|
||||
|
||||
let set = "foo=b;max-age=3600, c=d;path=/";
|
||||
Services.cookies.setCookieStringFromHttp(uri, set, channel);
|
||||
cs.setCookieStringFromHttp(uri, set, channel);
|
||||
|
||||
let expected = "foo=b";
|
||||
let actual = Services.cookies.getCookieStringFromHttp(uri, channel);
|
||||
let actual = cs.getCookieStringFromHttp(uri, channel);
|
||||
Assert.equal(actual, expected);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ add_task(async _ => {
|
|||
);
|
||||
}
|
||||
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
let uri = NetUtil.newURI("http://example.org/");
|
||||
|
||||
let principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
|
@ -95,7 +97,7 @@ add_task(async _ => {
|
|||
Services.obs.addObserver(observer, "cookie-saved-on-disk");
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(uri, test.cookie, channel);
|
||||
cs.setCookieStringFromHttp(uri, test.cookie, channel);
|
||||
|
||||
await promise;
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ const { CookieXPCShellUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/CookieXPCShellUtils.jsm"
|
||||
);
|
||||
|
||||
let CookieXPCShellUtilsInitialized = false;
|
||||
let cookieXPCShellUtilsInitialized = false;
|
||||
function maybeInitializeCookieXPCShellUtils() {
|
||||
if (!CookieXPCShellUtilsInitialized) {
|
||||
CookieXPCShellUtilsInitialized = true;
|
||||
if (!cookieXPCShellUtilsInitialized) {
|
||||
cookieXPCShellUtilsInitialized = true;
|
||||
CookieXPCShellUtils.init(this);
|
||||
|
||||
CookieXPCShellUtils.createServer({ hosts: ["example.org"] });
|
||||
|
@ -38,6 +38,8 @@ add_task(async _ => {
|
|||
);
|
||||
}
|
||||
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
info("Let's set a cookie from HTTP example.org");
|
||||
|
||||
let uri = NetUtil.newURI("http://example.org/");
|
||||
|
@ -52,7 +54,7 @@ add_task(async _ => {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(uri, "a=b; sameSite=lax", channel);
|
||||
cs.setCookieStringFromHttp(uri, "a=b; sameSite=lax", channel);
|
||||
|
||||
let cookies = Services.cookies.getCookiesFromHost("example.org", {});
|
||||
Assert.equal(cookies.length, 1, "We expect 1 cookie only");
|
||||
|
@ -70,7 +72,7 @@ add_task(async _ => {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(uri, "a=b; sameSite=lax", channel);
|
||||
cs.setCookieStringFromHttp(uri, "a=b; sameSite=lax", channel);
|
||||
|
||||
cookies = Services.cookies.getCookiesFromHost("example.org", {});
|
||||
Assert.equal(cookies.length, 1, "We expect 1 cookie only");
|
||||
|
@ -104,6 +106,8 @@ add_task(async _ => {
|
|||
);
|
||||
}
|
||||
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
info(
|
||||
`Testing schemefulSameSite=${schemefulComparison}. Let's set a cookie from HTTPS example.org`
|
||||
);
|
||||
|
@ -120,7 +124,7 @@ add_task(async _ => {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
cs.setCookieStringFromHttp(
|
||||
https_uri,
|
||||
"a=b; sameSite=lax",
|
||||
same_site_channel
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"use strict";
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
|
||||
var observer = {
|
||||
observe(subject, topic, data) {
|
||||
|
|
|
@ -16,6 +16,20 @@ Services.prefs.setCharPref("permissions.manager.defaultsUrl", "");
|
|||
|
||||
CookieXPCShellUtils.init(this);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
Services,
|
||||
"cookiesvc",
|
||||
"@mozilla.org/cookieService;1",
|
||||
"nsICookieService"
|
||||
);
|
||||
// eslint-disable-next-line mozilla/use-services
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
Services,
|
||||
"cookiemgr",
|
||||
"@mozilla.org/cookiemanager;1",
|
||||
"nsICookieManager"
|
||||
);
|
||||
|
||||
function do_check_throws(f, result, stack) {
|
||||
if (!stack) {
|
||||
stack = Components.stack.caller;
|
||||
|
@ -142,8 +156,8 @@ function do_load_profile(generator) {
|
|||
// Set a single session cookie using http and test the cookie count
|
||||
// against 'expected'
|
||||
function do_set_single_http_cookie(uri, channel, expected) {
|
||||
Services.cookies.setCookieStringFromHttp(uri, "foo=bar", channel);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri.host), expected);
|
||||
Services.cookiesvc.setCookieStringFromHttp(uri, "foo=bar", channel);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected);
|
||||
}
|
||||
|
||||
// Set two cookies; via document.channel and via http request.
|
||||
|
@ -175,15 +189,15 @@ async function do_set_cookies(uri, channel, session, expected) {
|
|||
);
|
||||
await contentPage.close();
|
||||
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri.host), expected[0]);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[0]);
|
||||
|
||||
// via http request
|
||||
Services.cookies.setCookieStringFromHttp(uri, "hot=dog" + suffix, channel);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri.host), expected[1]);
|
||||
Services.cookiesvc.setCookieStringFromHttp(uri, "hot=dog" + suffix, channel);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri.host), expected[1]);
|
||||
}
|
||||
|
||||
function do_count_cookies() {
|
||||
return Services.cookies.cookies.length;
|
||||
return Services.cookiemgr.cookies.length;
|
||||
}
|
||||
|
||||
// Helper object to store cookie data.
|
||||
|
|
|
@ -13,6 +13,7 @@ add_task(async () => {
|
|||
);
|
||||
Services.prefs.setBoolPref("dom.security.https_first", false);
|
||||
|
||||
var serv = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
|
||||
var uri = makeURI("http://example.com/");
|
||||
var channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -35,7 +36,7 @@ add_task(async () => {
|
|||
);
|
||||
|
||||
// Now sanity check
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
serv.setCookieStringFromHttp(
|
||||
uri,
|
||||
"test2=test2; path=/; domain=example.com;",
|
||||
channel
|
||||
|
|
|
@ -19,19 +19,18 @@ add_task(async () => {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
cookieURI,
|
||||
"BadCookie1=\x01",
|
||||
channel
|
||||
var cookieService = Cc["@mozilla.org/cookieService;1"].getService(
|
||||
Ci.nsICookieService
|
||||
);
|
||||
Services.cookies.setCookieStringFromHttp(cookieURI, "BadCookie2=\v", channel);
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
cookieService.setCookieStringFromHttp(cookieURI, "BadCookie1=\x01", channel);
|
||||
cookieService.setCookieStringFromHttp(cookieURI, "BadCookie2=\v", channel);
|
||||
cookieService.setCookieStringFromHttp(
|
||||
cookieURI,
|
||||
"Bad\x07Name=illegal",
|
||||
channel
|
||||
);
|
||||
Services.cookies.setCookieStringFromHttp(cookieURI, GOOD_COOKIE, channel);
|
||||
Services.cookies.setCookieStringFromHttp(cookieURI, SPACEY_COOKIE, channel);
|
||||
cookieService.setCookieStringFromHttp(cookieURI, GOOD_COOKIE, channel);
|
||||
cookieService.setCookieStringFromHttp(cookieURI, SPACEY_COOKIE, channel);
|
||||
|
||||
CookieXPCShellUtils.createServer({ hosts: ["mozilla.org"] });
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ async function run_test_1() {
|
|||
db.close();
|
||||
|
||||
// Attempt to insert a cookie with the same (name, host, path) triplet.
|
||||
Services.cookies.add(
|
||||
Services.cookiemgr.add(
|
||||
cookie.host,
|
||||
cookie.path,
|
||||
cookie.name,
|
||||
|
@ -155,7 +155,7 @@ async function run_test_1() {
|
|||
);
|
||||
|
||||
// Check that the cookie service accepted the new cookie.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(cookie.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(cookie.host), 1);
|
||||
|
||||
let isRebuildingDone = false;
|
||||
let rebuildingObserve = function(subject, topic, data) {
|
||||
|
@ -169,7 +169,7 @@ async function run_test_1() {
|
|||
// cookie thread. Trigger some access of cookies to ensure we won't crash in
|
||||
// the chaos status.
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(cookie.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(cookie.host), 1);
|
||||
await new Promise(resolve => executeSoon(resolve));
|
||||
}
|
||||
|
||||
|
@ -182,8 +182,8 @@ async function run_test_1() {
|
|||
await new Promise(resolve => executeSoon(resolve));
|
||||
|
||||
// At this point, the cookies should still be in memory.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(cookie.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(cookie.host), 1);
|
||||
Assert.equal(do_count_cookies(), 2);
|
||||
|
||||
// Close the profile.
|
||||
|
@ -199,8 +199,8 @@ async function run_test_1() {
|
|||
// Load the profile, and check that it contains the new cookie.
|
||||
do_load_profile();
|
||||
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 1);
|
||||
let cookies = Services.cookies.getCookiesFromHost(cookie.host, {});
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 1);
|
||||
let cookies = Services.cookiemgr.getCookiesFromHost(cookie.host, {});
|
||||
Assert.equal(cookies.length, 1);
|
||||
let dbcookie = cookies[0];
|
||||
Assert.equal(dbcookie.value, "hallo");
|
||||
|
@ -219,7 +219,7 @@ async function run_test_2() {
|
|||
// Load the profile and populate it.
|
||||
do_load_profile();
|
||||
|
||||
Services.cookies.runInTransaction(_ => {
|
||||
Services.cookiesvc.runInTransaction(_ => {
|
||||
let uri = NetUtil.newURI("http://foo.com/");
|
||||
const channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -229,7 +229,7 @@ async function run_test_2() {
|
|||
|
||||
for (let i = 0; i < 3000; ++i) {
|
||||
let uri = NetUtil.newURI("http://" + i + ".com/");
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -251,7 +251,7 @@ async function run_test_2() {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile.
|
||||
|
@ -264,7 +264,7 @@ async function run_test_2() {
|
|||
db.close();
|
||||
|
||||
do_load_profile();
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile.
|
||||
|
@ -284,7 +284,7 @@ async function run_test_3() {
|
|||
|
||||
// Load the profile and populate it.
|
||||
do_load_profile();
|
||||
Services.cookies.runInTransaction(_ => {
|
||||
Services.cookiesvc.runInTransaction(_ => {
|
||||
let uri = NetUtil.newURI("http://hither.com/");
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -292,7 +292,7 @@ async function run_test_3() {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh" + i + "=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -305,7 +305,7 @@ async function run_test_3() {
|
|||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
for (let i = 10; i < 3000; ++i) {
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh" + i + "=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -327,8 +327,8 @@ async function run_test_3() {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("hither.com"), 0);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("haithur.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("hither.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("haithur.com"), 0);
|
||||
|
||||
// Close the profile.
|
||||
await promise_close_profile();
|
||||
|
@ -374,7 +374,7 @@ async function run_test_3() {
|
|||
async function run_test_4() {
|
||||
// Load the profile and populate it.
|
||||
do_load_profile();
|
||||
Services.cookies.runInTransaction(_ => {
|
||||
Services.cookiesvc.runInTransaction(_ => {
|
||||
let uri = NetUtil.newURI("http://foo.com/");
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
|
@ -383,7 +383,7 @@ async function run_test_4() {
|
|||
});
|
||||
for (let i = 0; i < 3000; ++i) {
|
||||
let uri = NetUtil.newURI("http://" + i + ".com/");
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -405,7 +405,7 @@ async function run_test_4() {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
|
||||
// Queue up an INSERT for the same base domain. This should also go into
|
||||
// memory and be written out during database rebuild.
|
||||
|
@ -415,7 +415,7 @@ async function run_test_4() {
|
|||
);
|
||||
|
||||
// At this point, the cookies should still be in memory.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 1);
|
||||
|
||||
// Close the profile.
|
||||
|
@ -427,7 +427,7 @@ async function run_test_4() {
|
|||
|
||||
// Load the profile, and check that it contains the new cookie.
|
||||
do_load_profile();
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 1);
|
||||
Assert.equal(do_count_cookies(), 1);
|
||||
|
||||
// Close the profile.
|
||||
|
@ -443,21 +443,21 @@ async function run_test_4() {
|
|||
async function run_test_5() {
|
||||
// Load the profile and populate it.
|
||||
do_load_profile();
|
||||
Services.cookies.runInTransaction(_ => {
|
||||
Services.cookiesvc.runInTransaction(_ => {
|
||||
let uri = NetUtil.newURI("http://bar.com/");
|
||||
const channel = NetUtil.newChannel({
|
||||
uri,
|
||||
loadUsingSystemPrincipal: true,
|
||||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; path=/; max-age=1000",
|
||||
channel
|
||||
);
|
||||
for (let i = 0; i < 3000; ++i) {
|
||||
let uri = NetUtil.newURI("http://" + i + ".com/");
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -479,8 +479,8 @@ async function run_test_5() {
|
|||
Assert.ok(!do_get_backup_file(profile).exists());
|
||||
|
||||
// Recreate a new database since it was corrupted
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 0);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
|
@ -498,8 +498,8 @@ async function run_test_5() {
|
|||
Assert.ok(do_get_backup_file(profile).exists());
|
||||
Assert.equal(do_get_backup_file(profile).fileSize, size);
|
||||
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 0);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("0.com"), 0);
|
||||
Assert.equal(do_count_cookies(), 0);
|
||||
|
||||
// Close the profile. We do not need to wait for completion, because the
|
||||
|
|
|
@ -49,12 +49,12 @@ add_task(async () => {
|
|||
let uri2 = NetUtil.newURI("http://bar.com/bar.html");
|
||||
|
||||
// Set a cookie for host 1.
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri1,
|
||||
"oh=hai; max-age=1000",
|
||||
make_channel(uri1.spec)
|
||||
);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri1.host), 1);
|
||||
|
||||
// Enter private browsing mode, set a cookie for host 2, and check the counts.
|
||||
var chan1 = make_channel(uri1.spec);
|
||||
|
@ -65,7 +65,11 @@ add_task(async () => {
|
|||
chan2.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
||||
chan2.setPrivate(true);
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2);
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri2,
|
||||
"oh=hai; max-age=1000",
|
||||
chan2
|
||||
);
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), "");
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai");
|
||||
|
||||
|
@ -74,26 +78,34 @@ add_task(async () => {
|
|||
Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), "");
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "");
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2);
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri2,
|
||||
"oh=hai; max-age=1000",
|
||||
chan2
|
||||
);
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai");
|
||||
|
||||
// Leave private browsing mode and check counts.
|
||||
Services.obs.notifyObservers(null, "last-pb-context-exited");
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri2.host), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri2.host), 0);
|
||||
|
||||
// Fake a profile change.
|
||||
await promise_close_profile();
|
||||
do_load_profile();
|
||||
|
||||
// Check that the right cookie persisted.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri2.host), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri2.host), 0);
|
||||
|
||||
// Enter private browsing mode, set a cookie for host 2, and check the counts.
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), "");
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "");
|
||||
Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2);
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri2,
|
||||
"oh=hai; max-age=1000",
|
||||
chan2
|
||||
);
|
||||
Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai");
|
||||
|
||||
// Fake a profile change.
|
||||
|
@ -107,8 +119,8 @@ add_task(async () => {
|
|||
|
||||
// Leave private browsing mode and check counts.
|
||||
Services.obs.notifyObservers(null, "last-pb-context-exited");
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri2.host), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri2.host), 0);
|
||||
|
||||
// Enter private browsing mode.
|
||||
|
||||
|
@ -123,8 +135,8 @@ add_task(async () => {
|
|||
|
||||
// Leave private browsing mode and check counts.
|
||||
Services.obs.notifyObservers(null, "last-pb-context-exited");
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(uri2.host), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri1.host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(uri2.host), 0);
|
||||
|
||||
// Let's release the last PB window.
|
||||
privateBrowsingHolder.close();
|
||||
|
|
|
@ -37,7 +37,7 @@ add_task(async () => {
|
|||
"oh=hai; max-age=1000"
|
||||
);
|
||||
|
||||
let cookies = Services.cookies.cookies;
|
||||
let cookies = Services.cookiemgr.cookies;
|
||||
Assert.ok(cookies.length == 1);
|
||||
let cookie = cookies[0];
|
||||
|
||||
|
@ -52,26 +52,26 @@ add_task(async () => {
|
|||
""
|
||||
);
|
||||
|
||||
Assert.equal(Services.cookies.getCookieStringFromHttp(uri, channel), "");
|
||||
Assert.equal(Services.cookiesvc.getCookieStringFromHttp(uri, channel), "");
|
||||
|
||||
await CookieXPCShellUtils.setCookieToDocument(uri.spec, "oh2=hai");
|
||||
|
||||
Services.cookies.setCookieStringFromHttp(uri, "oh3=hai", channel);
|
||||
Services.cookiesvc.setCookieStringFromHttp(uri, "oh3=hai", channel);
|
||||
Assert.equal(
|
||||
await CookieXPCShellUtils.getCookieStringFromDocument("http://foo.com/"),
|
||||
""
|
||||
);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookies.cookies;
|
||||
Services.cookiemgr.cookies;
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookies.add(
|
||||
Services.cookiemgr.add(
|
||||
"foo.com",
|
||||
"",
|
||||
"oh4",
|
||||
|
@ -87,11 +87,11 @@ add_task(async () => {
|
|||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookies.remove("foo.com", "", "oh4", {});
|
||||
Services.cookiemgr.remove("foo.com", "", "oh4", {});
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {});
|
||||
Services.cookiemgr.cookieExists(cookie.host, cookie.path, cookie.name, {});
|
||||
}, Cr.NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
do_check_throws(function() {
|
||||
|
@ -108,7 +108,7 @@ add_task(async () => {
|
|||
// Load the profile and check that the API is available.
|
||||
do_load_profile();
|
||||
Assert.ok(
|
||||
Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {})
|
||||
Services.cookiemgr.cookieExists(cookie.host, cookie.path, cookie.name, {})
|
||||
);
|
||||
Services.prefs.clearUserPref("dom.security.https_first");
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(async () => {
|
|||
|
||||
// Start the cookieservice, to force creation of a database.
|
||||
// Get the sessionCookies to join the initialization in cookie thread
|
||||
Services.cookies.sessionCookies;
|
||||
Services.cookiemgr.sessionCookies;
|
||||
|
||||
// Open a database connection now, after synchronous initialization has
|
||||
// completed. We may not be able to open one later once asynchronous writing
|
||||
|
@ -39,7 +39,7 @@ add_task(async () => {
|
|||
});
|
||||
for (let i = 0; i < CMAX; ++i) {
|
||||
let uri = NetUtil.newURI("http://" + i + ".com/");
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -65,11 +65,11 @@ add_task(async () => {
|
|||
do_load_profile();
|
||||
|
||||
// test a few random cookies
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("999.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("abc.com"), 0);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("100.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("400.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("xyz.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("999.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("abc.com"), 0);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("100.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("400.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("xyz.com"), 0);
|
||||
|
||||
// force synchronous load of everything
|
||||
Assert.equal(do_count_cookies(), CMAX);
|
||||
|
@ -77,7 +77,7 @@ add_task(async () => {
|
|||
// check that everything's precisely correct
|
||||
for (let i = 0; i < CMAX; ++i) {
|
||||
let host = i.toString() + ".com";
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(host), 1);
|
||||
}
|
||||
|
||||
// reload again, to make sure the additions were written correctly
|
||||
|
@ -87,11 +87,11 @@ add_task(async () => {
|
|||
// remove some of the cookies, in both reverse and forward order
|
||||
for (let i = 100; i-- > 0; ) {
|
||||
let host = i.toString() + ".com";
|
||||
Services.cookies.remove(host, "oh", "/", {});
|
||||
Services.cookiemgr.remove(host, "oh", "/", {});
|
||||
}
|
||||
for (let i = CMAX - 100; i < CMAX; ++i) {
|
||||
let host = i.toString() + ".com";
|
||||
Services.cookies.remove(host, "oh", "/", {});
|
||||
Services.cookiemgr.remove(host, "oh", "/", {});
|
||||
}
|
||||
|
||||
// check the count
|
||||
|
@ -112,7 +112,7 @@ add_task(async () => {
|
|||
Assert.equal(do_count_cookies(), CMAX - 200);
|
||||
for (let i = 100; i < CMAX - 100; ++i) {
|
||||
let host = i.toString() + ".com";
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(host), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(host), 1);
|
||||
}
|
||||
|
||||
Services.prefs.clearUserPref("network.cookie.sameSite.laxByDefault");
|
||||
|
|
|
@ -182,7 +182,7 @@ function* run_test_1(generator) {
|
|||
});
|
||||
|
||||
// Load the profile and populate it.
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; max-age=1000",
|
||||
channel
|
||||
|
@ -217,7 +217,7 @@ function* run_test_2(generator) {
|
|||
loadUsingSystemPrincipal: true,
|
||||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
Services.cookies.setCookieStringFromHttp(
|
||||
Services.cookiesvc.setCookieStringFromHttp(
|
||||
uri,
|
||||
"oh=hai; max-age=1000",
|
||||
channel
|
||||
|
|
|
@ -58,7 +58,7 @@ function* do_run_test() {
|
|||
setCookies("tasty.horse.radish", 50, futureExpiry);
|
||||
Assert.equal(countCookies("horse.radish", "horse.radish"), 50);
|
||||
|
||||
for (let cookie of Services.cookies.cookies) {
|
||||
for (let cookie of Services.cookiemgr.cookies) {
|
||||
if (cookie.host == "horse.radish") {
|
||||
do_throw("cookies not evicted by lastAccessed order");
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ function* do_run_test() {
|
|||
// Test that expired cookies for a domain are evicted before live ones.
|
||||
let shortExpiry = Math.floor(Date.now() / 1000 + 2);
|
||||
setCookies("captchart.com", 49, futureExpiry);
|
||||
Services.cookies.add(
|
||||
Services.cookiemgr.add(
|
||||
"captchart.com",
|
||||
"",
|
||||
"test100",
|
||||
|
@ -84,7 +84,7 @@ function* do_run_test() {
|
|||
yield;
|
||||
|
||||
Assert.equal(countCookies("captchart.com", "captchart.com"), 50);
|
||||
Services.cookies.add(
|
||||
Services.cookiemgr.add(
|
||||
"captchart.com",
|
||||
"",
|
||||
"test200",
|
||||
|
@ -99,7 +99,10 @@ function* do_run_test() {
|
|||
);
|
||||
Assert.equal(countCookies("captchart.com", "captchart.com"), 50);
|
||||
|
||||
for (let cookie of Services.cookies.getCookiesFromHost("captchart.com", {})) {
|
||||
for (let cookie of Services.cookiemgr.getCookiesFromHost(
|
||||
"captchart.com",
|
||||
{}
|
||||
)) {
|
||||
Assert.ok(cookie.expiry == futureExpiry);
|
||||
}
|
||||
|
||||
|
@ -109,7 +112,7 @@ function* do_run_test() {
|
|||
// set 'aNumber' cookies with host 'aHost', with distinct names.
|
||||
function setCookies(aHost, aNumber, aExpiry) {
|
||||
for (let i = 0; i < aNumber; ++i) {
|
||||
Services.cookies.add(
|
||||
Services.cookiemgr.add(
|
||||
aHost,
|
||||
"",
|
||||
"test" + i,
|
||||
|
@ -135,7 +138,7 @@ function countCookies(aBaseDomain, aHost) {
|
|||
// count how many cookies are within domain 'aBaseDomain' using the cookies
|
||||
// array.
|
||||
let cookies = [];
|
||||
for (let cookie of Services.cookies.cookies) {
|
||||
for (let cookie of Services.cookiemgr.cookies) {
|
||||
if (
|
||||
cookie.host.length >= aBaseDomain.length &&
|
||||
cookie.host.slice(cookie.host.length - aBaseDomain.length) == aBaseDomain
|
||||
|
@ -147,12 +150,12 @@ function countCookies(aBaseDomain, aHost) {
|
|||
// confirm the count using countCookiesFromHost and getCookiesFromHost.
|
||||
let result = cookies.length;
|
||||
Assert.equal(
|
||||
Services.cookies.countCookiesFromHost(aBaseDomain),
|
||||
Services.cookiemgr.countCookiesFromHost(aBaseDomain),
|
||||
cookies.length
|
||||
);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost(aHost), cookies.length);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost(aHost), cookies.length);
|
||||
|
||||
for (let cookie of Services.cookies.getCookiesFromHost(aHost, {})) {
|
||||
for (let cookie of Services.cookiemgr.getCookiesFromHost(aHost, {})) {
|
||||
if (
|
||||
cookie.host.length >= aBaseDomain.length &&
|
||||
cookie.host.slice(cookie.host.length - aBaseDomain.length) == aBaseDomain
|
||||
|
|
|
@ -66,7 +66,7 @@ function* do_run_test() {
|
|||
// we test the following cases of eviction:
|
||||
// 1) excess and age are satisfied, but only some of the excess are old enough
|
||||
// to be purged.
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
if (!set_cookies(0, 5, expiry)) {
|
||||
repeat_test();
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ function* do_run_test() {
|
|||
|
||||
// 2) excess and age are satisfied, and all of the excess are old enough
|
||||
// to be purged.
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
if (!set_cookies(0, 10, expiry)) {
|
||||
repeat_test();
|
||||
return;
|
||||
|
@ -107,7 +107,7 @@ function* do_run_test() {
|
|||
|
||||
// 3) excess and age are satisfied, and more than the excess are old enough
|
||||
// to be purged.
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
if (!set_cookies(0, 50, expiry)) {
|
||||
repeat_test();
|
||||
return;
|
||||
|
@ -125,7 +125,7 @@ function* do_run_test() {
|
|||
Assert.ok(check_remaining_cookies(111, 50, 101));
|
||||
|
||||
// 4) excess but not age are satisfied.
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
if (!set_cookies(0, 120, expiry)) {
|
||||
repeat_test();
|
||||
return;
|
||||
|
@ -137,7 +137,7 @@ function* do_run_test() {
|
|||
Assert.ok(check_remaining_cookies(120, 0, 120));
|
||||
|
||||
// 5) age but not excess are satisfied.
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
if (!set_cookies(0, 20, expiry)) {
|
||||
repeat_test();
|
||||
return;
|
||||
|
@ -156,7 +156,7 @@ function* do_run_test() {
|
|||
|
||||
// 6) Excess and age are satisfied, but the cookie limit can be satisfied by
|
||||
// purging expired cookies.
|
||||
Services.cookies.removeAll();
|
||||
Services.cookiemgr.removeAll();
|
||||
let shortExpiry = Math.floor(Date.now() / 1000) + gShortExpiry;
|
||||
if (!set_cookies(0, 20, shortExpiry)) {
|
||||
repeat_test();
|
||||
|
@ -191,7 +191,7 @@ function set_cookies(begin, end, expiry) {
|
|||
let beginTime;
|
||||
for (let i = begin; i < end; ++i) {
|
||||
let host = "eviction." + i + ".tests";
|
||||
Services.cookies.add(
|
||||
Services.cookiemgr.add(
|
||||
host,
|
||||
"",
|
||||
"test",
|
||||
|
@ -223,7 +223,7 @@ function set_cookies(begin, end, expiry) {
|
|||
|
||||
function get_creationTime(i) {
|
||||
let host = "eviction." + i + ".tests";
|
||||
let cookies = Services.cookies.getCookiesFromHost(host, {});
|
||||
let cookies = Services.cookiemgr.getCookiesFromHost(host, {});
|
||||
Assert.ok(cookies.length);
|
||||
let cookie = cookies[0];
|
||||
return cookie.creationTime;
|
||||
|
@ -236,7 +236,7 @@ function get_creationTime(i) {
|
|||
// + 10% are exceeded.
|
||||
function check_remaining_cookies(aNumberTotal, aNumberOld, aNumberToExpect) {
|
||||
let i = 0;
|
||||
for (let cookie of Services.cookies.cookies) {
|
||||
for (let cookie of Services.cookiemgr.cookies) {
|
||||
++i;
|
||||
|
||||
if (aNumberTotal != aNumberToExpect) {
|
||||
|
|
|
@ -25,7 +25,7 @@ function* do_run_test() {
|
|||
|
||||
// Start the cookieservice, to force creation of a database.
|
||||
// Get the sessionCookies to join the initialization in cookie thread
|
||||
Services.cookies.sessionCookies;
|
||||
Services.cookiemgr.sessionCookies;
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(test_generator);
|
||||
|
@ -165,15 +165,15 @@ function* do_run_test() {
|
|||
do_load_profile();
|
||||
|
||||
// 1) All unexpired, unique cookies exist.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
|
||||
// 2) All expired, unique cookies exist.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
|
||||
// 3) Only one cookie remains, and it's the one with the highest expiration
|
||||
// time.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookies.getCookiesFromHost("baz.com", {});
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookiemgr.getCookiesFromHost("baz.com", {});
|
||||
let cookie = cookies[0];
|
||||
Assert.equal(cookie.expiry, futureExpiry + 40);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ function* do_run_test() {
|
|||
|
||||
// Start the cookieservice, to force creation of a database.
|
||||
// Get the sessionCookies to join the initialization in cookie thread
|
||||
Services.cookies.sessionCookies;
|
||||
Services.cookiemgr.sessionCookies;
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(test_generator);
|
||||
|
@ -154,15 +154,15 @@ function* do_run_test() {
|
|||
do_load_profile();
|
||||
|
||||
// 1) All unexpired, unique cookies exist.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
|
||||
// 2) All expired, unique cookies exist.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
|
||||
// 3) Only one cookie remains, and it's the one with the highest expiration
|
||||
// time.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookies.getCookiesFromHost("baz.com", {});
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookiemgr.getCookiesFromHost("baz.com", {});
|
||||
let cookie = cookies[0];
|
||||
Assert.equal(cookie.expiry, futureExpiry + 44);
|
||||
|
||||
|
@ -244,10 +244,10 @@ function* do_run_test() {
|
|||
yield;
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("cat.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
@ -260,10 +260,10 @@ function* do_run_test() {
|
|||
do_load_profile();
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("cat.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
@ -284,10 +284,10 @@ function* do_run_test() {
|
|||
Assert.equal(do_count_cookies(), 81);
|
||||
|
||||
// Test the expected set of cookies.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("cat.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 40);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20);
|
||||
|
||||
do_close_profile(test_generator);
|
||||
yield;
|
||||
|
|
|
@ -25,7 +25,7 @@ function* do_run_test() {
|
|||
|
||||
// Start the cookieservice, to force creation of a database.
|
||||
// Get the sessionCookies to join the initialization in cookie thread
|
||||
Services.cookies.sessionCookies;
|
||||
Services.cookiemgr.sessionCookies;
|
||||
|
||||
// Close the profile.
|
||||
do_close_profile(test_generator);
|
||||
|
@ -154,15 +154,15 @@ function* do_run_test() {
|
|||
do_load_profile();
|
||||
|
||||
// 1) All unexpired, unique cookies exist.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("foo.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 20);
|
||||
|
||||
// 2) All expired, unique cookies exist.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("bar.com"), 20);
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("bar.com"), 20);
|
||||
|
||||
// 3) Only one cookie remains, and it's the one with the highest expiration
|
||||
// time.
|
||||
Assert.equal(Services.cookies.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookies.getCookiesFromHost("baz.com", {});
|
||||
Assert.equal(Services.cookiemgr.countCookiesFromHost("baz.com"), 1);
|
||||
let cookies = Services.cookiemgr.getCookiesFromHost("baz.com", {});
|
||||
let cookie = cookies[0];
|
||||
Assert.equal(cookie.expiry, futureExpiry + 44);
|
||||
|
||||
|
|
|
@ -842,13 +842,16 @@ add_task(async function test_not_sending_cookie() {
|
|||
}
|
||||
let server = httpd_setup({ "/test": handler });
|
||||
|
||||
let cookieSer = Cc["@mozilla.org/cookieService;1"].getService(
|
||||
Ci.nsICookieService
|
||||
);
|
||||
let uri = CommonUtils.makeURI(server.baseURI);
|
||||
let channel = NetUtil.newChannel({
|
||||
uri,
|
||||
loadUsingSystemPrincipal: true,
|
||||
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
||||
});
|
||||
Services.cookies.setCookieStringFromHttp(uri, "test=test; path=/;", channel);
|
||||
cookieSer.setCookieStringFromHttp(uri, "test=test; path=/;", channel);
|
||||
|
||||
let res = new RESTRequest(server.baseURI + "/test");
|
||||
let response = await res.get();
|
||||
|
|
|
@ -11,7 +11,6 @@ Classes = [
|
|||
'contract_ids': ['@mozilla.org/extensions/blocklist;1'],
|
||||
'jsm': 'resource://gre/modules/addonManager.js',
|
||||
'constructor': 'BlocklistService',
|
||||
'interfaces': ['nsIBlocklistService'],
|
||||
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -179,7 +179,6 @@ module.exports = {
|
|||
"mozilla/use-ownerGlobal": "error",
|
||||
"mozilla/use-returnValue": "error",
|
||||
"mozilla/use-services": "error",
|
||||
"mozilla/valid-services": "error",
|
||||
|
||||
// Use [] instead of Array()
|
||||
"no-array-constructor": "error",
|
||||
|
|
|
@ -73,7 +73,6 @@ module.exports = {
|
|||
"use-isInstance": require("./rules/use-isInstance"),
|
||||
"use-returnValue": require("../lib/rules/use-returnValue"),
|
||||
"use-services": require("../lib/rules/use-services"),
|
||||
"valid-services": require("../lib/rules/valid-services"),
|
||||
"var-only-at-top-level": require("../lib/rules/var-only-at-top-level"),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Require use of Services.* rather than getService.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
const helpers = require("../helpers");
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
docs: {
|
||||
url:
|
||||
"https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint-plugin-mozilla/use-services.html",
|
||||
},
|
||||
type: "problem",
|
||||
},
|
||||
|
||||
create(context) {
|
||||
let servicesInterfaceMap = helpers.servicesData;
|
||||
let serviceAliases = new Set([
|
||||
...Object.values(servicesInterfaceMap),
|
||||
// This is defined only for Android, so most builds won't pick it up.
|
||||
"androidBridge",
|
||||
// These are defined without interfaces and hence are not in the services map.
|
||||
"cpmm",
|
||||
"crashmanager",
|
||||
"mm",
|
||||
"ppmm",
|
||||
// The new xulStore also does not have an interface.
|
||||
"xulStore",
|
||||
]);
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
if (node.computed || node.object.type !== "Identifier") {
|
||||
return;
|
||||
}
|
||||
|
||||
let alias;
|
||||
if (node.object.name == "Services") {
|
||||
alias = node.property.name;
|
||||
} else if (
|
||||
node.property.name == "Services" &&
|
||||
node.parent.type == "MemberExpression"
|
||||
) {
|
||||
alias = node.parent.property.name;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!serviceAliases.has(alias)) {
|
||||
context.report(node, `Unknown Services member property ${alias}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
|
@ -5,14 +5,12 @@
|
|||
"mozIStorageService": "storage",
|
||||
"nsIAppShellService": "appShell",
|
||||
"nsIAppStartup": "startup",
|
||||
"nsIBlocklistService": "blocklist",
|
||||
"nsICacheStorageService": "cache2",
|
||||
"nsICategoryManager": "catMan",
|
||||
"nsIClearDataService": "clearData",
|
||||
"nsIClipboard": "clipboard",
|
||||
"nsIConsoleService": "console",
|
||||
"nsICookieManager": "cookies",
|
||||
"nsICookieService": "cookies",
|
||||
"nsIDOMRequestService": "DOMRequest",
|
||||
"nsIDOMStorageManager": "domStorageManager",
|
||||
"nsIDirectoryService": "dirsvc",
|
||||
|
@ -45,7 +43,6 @@
|
|||
"nsITelemetry": "telemetry",
|
||||
"nsITextToSubURI": "textToSubURI",
|
||||
"nsIThreadManager": "tm",
|
||||
"nsIURIFixup": "uriFixup",
|
||||
"nsIURLFormatter": "urlFormatter",
|
||||
"nsIUUIDGenerator": "uuid",
|
||||
"nsIVersionComparator": "vc",
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
var rule = require("../lib/rules/valid-services");
|
||||
var RuleTester = require("eslint").RuleTester;
|
||||
|
||||
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Tests
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
function invalidCode(code, name) {
|
||||
let message = `Unknown Services member property ${name}`;
|
||||
return { code, errors: [{ message }] };
|
||||
}
|
||||
|
||||
ruleTester.run("valid-services", rule, {
|
||||
valid: ["Services.crashmanager", "lazy.Services.crashmanager"],
|
||||
invalid: [
|
||||
invalidCode("Services.foo", "foo"),
|
||||
invalidCode("Services.foo()", "foo"),
|
||||
invalidCode("lazy.Services.foo", "foo"),
|
||||
invalidCode("Services.foo.bar()", "foo"),
|
||||
invalidCode("lazy.Services.foo.bar()", "foo"),
|
||||
],
|
||||
});
|
Загрузка…
Ссылка в новой задаче