author | Andrea Marchesini <amarchesini@mozilla.com> |
Fri, 31 May 2019 09:36:44 +0000 | |
changeset 476343 | fd04e3ff79c48f86b7f4f5ada7fb18a93ed600a1 |
parent 476342 | 519ab3e488483b7a13c5787164e469cda3795ad0 |
child 476344 | ad895c9bac527615763ac1bab5d3afee732d0bab |
push id | 36092 |
push user | archaeopteryx@coole-files.de |
push date | Fri, 31 May 2019 17:03:46 +0000 |
treeherder | mozilla-central@8384972e1f6a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Ehsan |
bugs | 1554464 |
milestone | 69.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/base/content/test/sanitize/browser_cookiePermission_subDomains.js +++ b/browser/base/content/test/sanitize/browser_cookiePermission_subDomains.js @@ -17,26 +17,26 @@ add_task(async function subDomains() { ]}); // Domains and data let uriA = Services.io.newURI("https://www.mozilla.org"); Services.perms.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_SESSION); Services.cookies.add(uriA.host, "/test", "a", "b", false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); await createIndexedDB(uriA.host, {}); let uriB = Services.io.newURI("https://mozilla.org"); Services.perms.add(uriB, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW); Services.cookies.add(uriB.host, "/test", "c", "d", false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); await createIndexedDB(uriB.host, {}); // Check ok(await checkCookie(uriA.host, {}), "We have cookies for URI: " + uriA.host); ok(await checkIndexedDB(uriA.host, {}), "We have IDB for URI: " + uriA.host); ok(await checkCookie(uriB.host, {}), "We have cookies for URI: " + uriB.host); ok(await checkIndexedDB(uriB.host, {}), "We have IDB for URI: " + uriB.host); @@ -71,25 +71,25 @@ add_task(async function subDomains() { ]}); // Domains and data let uriA = Services.io.newURI("https://sub.mozilla.org"); Services.perms.add(uriA, "cookie", Ci.nsICookiePermission.ACCESS_ALLOW); Services.cookies.add(uriA.host, "/test", "a", "b", false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); await createIndexedDB(uriA.host, {}); let uriB = Services.io.newURI("https://www.mozilla.org"); Services.cookies.add(uriB.host, "/test", "c", "d", false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); await createIndexedDB(uriB.host, {}); // Check ok(await checkCookie(uriA.host, {}), "We have cookies for URI: " + uriA.host); ok(await checkIndexedDB(uriA.host, {}), "We have IDB for URI: " + uriA.host); ok(await checkCookie(uriB.host, {}), "We have cookies for URI: " + uriB.host); ok(await checkIndexedDB(uriB.host, {}), "We have IDB for URI: " + uriB.host);
--- a/browser/base/content/test/sanitize/head.js +++ b/browser/base/content/test/sanitize/head.js @@ -29,23 +29,23 @@ function checkIndexedDB(host, originAttr resolve(data); }; }); } function createHostCookie(host, originAttributes) { Services.cookies.add(host, "/test", "foo", "bar", false, false, false, Date.now() + 24000 * 60 * 60, originAttributes, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } function createDomainCookie(host, originAttributes) { Services.cookies.add("." + host, "/test", "foo", "bar", false, false, false, Date.now() + 24000 * 60 * 60, originAttributes, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } function checkCookie(host, originAttributes) { for (let cookie of Services.cookies.enumerator) { if (ChromeUtils.isOriginAttributesEqual(originAttributes, cookie.originAttributes) && cookie.host.includes(host)) { return true;
--- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js +++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js @@ -60,17 +60,17 @@ add_task(async function test_cookie_getC BrowserTestUtils.removeTab(tabs[userContextId].tab); } // Check that cookies have been set properly. for (let userContextId of Object.keys(USER_CONTEXTS)) { let enumerator = getCookiesForOA(TEST_HOST, userContextId); ok(enumerator.hasMoreElements(), "Cookies available"); - let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie); is(foundCookie.name, cookieName, "Check cookie name"); is(foundCookie.value, USER_CONTEXTS[userContextId], "Check cookie value"); } // Using getCookiesWithOriginAttributes() to get all cookies for a certain // domain by using the originAttributes pattern, and clear all these cookies. for (let cookie of Services.cookies.getCookiesWithOriginAttributes(JSON.stringify({}), TEST_HOST)) { Services.cookies.remove(cookie.host, cookie.name, cookie.path, false, cookie.originAttributes);
--- a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js +++ b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js @@ -127,17 +127,17 @@ async function test_cookie_cleared() { // Close this tab. BrowserTestUtils.removeTab(tabs[userContextId].tab); } // Check that cookies have been set properly. for (let userContextId of Object.keys(USER_CONTEXTS)) { let enumerator = getCookiesForOA(TEST_HOST, userContextId); ok(enumerator.hasMoreElements(), "Cookies available"); - let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.equal(foundCookie.name, COOKIE_NAME, "Check cookie name"); Assert.equal(foundCookie.value, USER_CONTEXTS[userContextId], "Check cookie value"); } // Forget the site. await ForgetAboutSite.removeDataFromDomain(TEST_HOST); // Check that whether cookies has been cleared or not.
--- a/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js +++ b/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js @@ -51,17 +51,17 @@ add_task(async function setup() { function checkCookies(ignoreContext = null) { for (let userContextId of Object.keys(USER_CONTEXTS)) { if (ignoreContext && userContextId === String(ignoreContext)) { continue; } let enumerator = getCookiesForOA(TEST_HOST, userContextId); ok(enumerator.hasMoreElements(), "Cookies available"); - let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie); is(foundCookie.name, COOKIE_NAME, "Check cookie name"); is(foundCookie.value, USER_CONTEXTS[userContextId], "Check cookie value"); } } function deleteCookies(onlyContext = null) { // Using getCookiesWithOriginAttributes() to get all cookies for a certain // domain by using the originAttributes pattern, and clear all these cookies. @@ -87,17 +87,17 @@ add_task(async function test_cookie_getC BrowserTestUtils.removeTab(tabs[userContextId].tab); } // Check that cookies have been set properly. for (let userContextId of Object.keys(USER_CONTEXTS)) { let enumerator = getCookiesForOA(TEST_HOST, userContextId); ok(enumerator.hasMoreElements(), "Cookies available"); - let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie); is(foundCookie.name, COOKIE_NAME, "Check cookie name"); is(foundCookie.value, USER_CONTEXTS[userContextId], "Check cookie value"); } checkCookies(); deleteCookies(DELETE_CONTEXT); checkCookies(DELETE_CONTEXT);
--- a/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js @@ -2,21 +2,21 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; const HOSTNAME_DOMAIN = "browser_policy_clear_blocked_cookies.com"; const ORIGIN_DOMAIN = "browser_policy_clear_blocked_cookies.org"; add_task(async function setup() { const expiry = Date.now() + 24 * 60 * 60; - Services.cookies.add(HOSTNAME_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); - Services.cookies.add(HOSTNAME_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); - Services.cookies.add(ORIGIN_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); - Services.cookies.add(ORIGIN_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); - Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + Services.cookies.add(HOSTNAME_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); + Services.cookies.add(HOSTNAME_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); + Services.cookies.add(ORIGIN_DOMAIN, "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); + Services.cookies.add(ORIGIN_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); + Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); await setupPolicyEngineWithJson({ "policies": { "Cookies": { "Block": [ `http://${HOSTNAME_DOMAIN}`, `https://${ORIGIN_DOMAIN}:8080`, ], },
--- a/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js +++ b/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js @@ -19,17 +19,17 @@ const COOKIE_NET = { const COOKIE_ORG = { host: "example.org", name: "test_cookie", path: "/", }; let since, oldCookie; function addCookie(cookie) { - Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, Date.now() / 1000 + 10000, {}, Ci.nsICookie2.SAMESITE_NONE); + Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, Date.now() / 1000 + 10000, {}, Ci.nsICookie.SAMESITE_NONE); ok(Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {}), `Cookie ${cookie.name} was created.`); } async function setUpCookies() { Services.cookies.removeAll(); // Add a cookie which will end up with an older creationTime. oldCookie = Object.assign({}, COOKIE, {name: Date.now()});
--- a/browser/components/migration/ChromeProfileMigrator.jsm +++ b/browser/components/migration/ChromeProfileMigrator.jsm @@ -331,17 +331,17 @@ async function GetCookiesResource(aProfi row.getResultByName("path"), row.getResultByName("name"), row.getResultByName("value"), row.getResultByName(isSecure), row.getResultByName(isHttponly), false, parseInt(expiresUtc), {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } catch (e) { Cu.reportError(e); } } aCallback(true); }, }; }
--- a/browser/components/migration/MSMigrationUtils.jsm +++ b/browser/components/migration/MSMigrationUtils.jsm @@ -635,17 +635,17 @@ Cookies.prototype = { path, name, value, Number(flags) & 0x1, // secure false, // httpOnly false, // session expireTime, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } }, }; function getTypedURLs(registryKeyPath) { // The list of typed URLs is a sort of annotation stored in the registry. // The number of entries stored is not UI-configurable, but has changed // between different Windows versions. We just keep reading up to the first
--- a/browser/components/migration/tests/marionette/test_refresh_firefox.py +++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py @@ -136,17 +136,17 @@ class TestFirefoxRefresh(MarionetteTestC }).then(resolve); """) def createCookie(self): self.runCode(""" // Expire in 15 minutes: let expireTime = Math.floor(Date.now() / 1000) + 15 * 60; Services.cookies.add(arguments[0], arguments[1], arguments[2], arguments[3], - true, false, false, expireTime, {}, Ci.nsICookie2.SAMESITE_NONE); + true, false, false, expireTime, {}, Ci.nsICookie.SAMESITE_NONE); """, script_args=(self._cookieHost, self._cookiePath, self._cookieName, self._cookieValue)) def createSession(self): self.runAsyncCode(""" let resolve = arguments[arguments.length - 1]; const COMPLETE_STATE = Ci.nsIWebProgressListener.STATE_STOP + Ci.nsIWebProgressListener.STATE_IS_NETWORK; let {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {}); @@ -315,17 +315,17 @@ class TestFirefoxRefresh(MarionetteTestC def checkCookie(self): cookieInfo = self.runCode(""" try { let cookieEnum = Services.cookies.getCookiesFromHost(arguments[0], {}); let cookie = null; while (cookieEnum.hasMoreElements()) { let hostCookie = cookieEnum.getNext(); - hostCookie.QueryInterface(Ci.nsICookie2); + hostCookie.QueryInterface(Ci.nsICookie); // getCookiesFromHost returns any cookie from the BASE host. if (hostCookie.rawHost != arguments[0]) continue; if (cookie != null) { return "more than 1 cookie! That shouldn't happen!"; } cookie = hostCookie; }
--- a/browser/components/migration/tests/unit/test_Chrome_cookies.js +++ b/browser/components/migration/tests/unit/test_Chrome_cookies.js @@ -33,17 +33,17 @@ add_task(async function() { Assert.equal(Services.cookies.countCookiesFromHost(COOKIE.host), 1, "Migrated the expected number of unencrypted cookies"); Assert.equal(Services.cookies.countCookiesFromHost("encryptedcookie.invalid"), 0, "Migrated the expected number of encrypted cookies"); // Now check the cookie details. let enumerator = Services.cookies.getCookiesFromHost(COOKIE.host, {}); Assert.ok(enumerator.hasMoreElements(), "Cookies available"); - let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie); for (let prop of Object.keys(COOKIE)) { Assert.equal(foundCookie[prop], COOKIE[prop], "Check cookie " + prop); } // Cleanup. await ForgetAboutSite.removeDataFromDomain(COOKIE.host); Assert.equal(Services.cookies.countCookiesFromHost(COOKIE.host), 0,
--- a/browser/components/migration/tests/unit/test_IE_cookies.js +++ b/browser/components/migration/tests/unit/test_IE_cookies.js @@ -112,15 +112,15 @@ add_task(async function() { await promiseMigration(migrator, MigrationUtils.resourceTypes.COOKIES); Assert.equal(Services.cookies.countCookiesFromHost(COOKIE.host), 1, "Migrated the expected number of cookies"); // Now check the cookie details. let enumerator = Services.cookies.getCookiesFromHost(COOKIE.host, {}); Assert.ok(enumerator.hasMoreElements()); - let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let foundCookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.equal(foundCookie.name, COOKIE.name); Assert.equal(foundCookie.value, COOKIE.value); Assert.equal(foundCookie.host, "." + COOKIE.host); Assert.equal(foundCookie.expiry, Math.floor(COOKIE.expiry / 1000)); });
--- a/browser/components/preferences/in-content/tests/siteData/browser_siteData.js +++ b/browser/components/preferences/in-content/tests/siteData/browser_siteData.js @@ -132,37 +132,37 @@ add_task(async function() { // Test showing and removing sites with cookies. add_task(async function() { // Add some test cookies. let uri = Services.io.newURI("https://example.com"); let uri2 = Services.io.newURI("https://example.org"); Services.cookies.add(uri.host, uri.pathQueryRef, "test1", "1", false, false, false, Date.now() + 1000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Services.cookies.add(uri.host, uri.pathQueryRef, "test2", "2", false, false, false, Date.now() + 1000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Services.cookies.add(uri2.host, uri2.pathQueryRef, "test1", "1", false, false, false, Date.now() + 1000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); // Ensure that private browsing cookies are ignored. Services.cookies.add(uri.host, uri.pathQueryRef, "test3", "3", false, false, false, Date.now() + 1000 * 60 * 60, { privateBrowsingId: 1 }, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); // Get the exact creation date from the cookies (to avoid intermittents // from minimal time differences, since we round up to minutes). let cookiesEnum1 = Services.cookies.getCookiesFromHost(uri.host, {}); // We made two valid cookies for example.com. cookiesEnum1.getNext(); let cookiesEnum2 = Services.cookies.getCookiesFromHost(uri2.host, {}); - let cookie1 = cookiesEnum1.getNext().QueryInterface(Ci.nsICookie2); - let cookie2 = cookiesEnum2.getNext().QueryInterface(Ci.nsICookie2); + let cookie1 = cookiesEnum1.getNext().QueryInterface(Ci.nsICookie); + let cookie2 = cookiesEnum2.getNext().QueryInterface(Ci.nsICookie); let fullFormatter = new Services.intl.DateTimeFormat(undefined, { dateStyle: "short", timeStyle: "short", }); await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true }); // Open the site data manager and remove one site.
--- a/browser/components/sessionstore/SessionCookies.jsm +++ b/browser/components/sessionstore/SessionCookies.jsm @@ -59,17 +59,17 @@ var SessionCookiesInternal = { Cu.reportError(`nsCookieService::CookieExists failed with error '${ex}' for '${JSON.stringify(cookie)}'.`); } if (!exists) { try { Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "", cookie.value, !!cookie.secure, !!cookie.httponly, /* isSession = */ true, expiry, cookie.originAttributes || {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } catch (ex) { Cu.reportError(`nsCookieService::Add failed with error '${ex}' for cookie ${JSON.stringify(cookie)}.`); } } } }, /** @@ -115,55 +115,55 @@ var SessionCookiesInternal = { this._reloadCookies(); }); }, /** * Adds a given cookie to the store. */ _addCookie(cookie) { - cookie.QueryInterface(Ci.nsICookie2); + cookie.QueryInterface(Ci.nsICookie); // Store only session cookies, obey the privacy level. if (cookie.isSession && PrivacyLevel.canSave(cookie.isSecure)) { CookieStore.add(cookie); } }, /** * Updates a given cookie. */ _updateCookie(cookie) { - cookie.QueryInterface(Ci.nsICookie2); + cookie.QueryInterface(Ci.nsICookie); // Store only session cookies, obey the privacy level. if (cookie.isSession && PrivacyLevel.canSave(cookie.isSecure)) { CookieStore.add(cookie); } else { CookieStore.delete(cookie); } }, /** * Removes a given cookie from the store. */ _removeCookie(cookie) { - cookie.QueryInterface(Ci.nsICookie2); + cookie.QueryInterface(Ci.nsICookie); if (cookie.isSession) { CookieStore.delete(cookie); } }, /** * Removes a given list of cookies from the store. */ _removeCookies(cookies) { for (let i = 0; i < cookies.length; i++) { - this._removeCookie(cookies.queryElementAt(i, Ci.nsICookie2)); + this._removeCookie(cookies.queryElementAt(i, Ci.nsICookie)); } }, /** * Iterates all cookies in the cookies service and puts them into the store * if they're session cookies. Obeys the user's chosen privacy level. */ _reloadCookies() { @@ -188,17 +188,17 @@ var CookieStore = { * The internal map holding all known session cookies. */ _entries: new Map(), /** * Stores a given cookie. * * @param cookie - * The nsICookie2 object to add to the storage. + * The nsICookie object to add to the storage. */ add(cookie) { let jscookie = {host: cookie.host, value: cookie.value}; // Only add properties with non-default values to save a few bytes. if (cookie.path) { jscookie.path = cookie.path; } @@ -225,17 +225,17 @@ var CookieStore = { this._entries.set(this._getKeyForCookie(cookie), jscookie); }, /** * Removes a given cookie. * * @param cookie - * The nsICookie2 object to be removed from storage. + * The nsICookie object to be removed from storage. */ delete(cookie) { this._entries.delete(this._getKeyForCookie(cookie)); }, /** * Removes all cookies. */ @@ -251,17 +251,17 @@ var CookieStore = { }, /** * Returns the key needed to properly store and identify a given cookie. * A cookie is uniquely identified by the combination of its host, name, * path, and originAttributes properties. * * @param cookie - * The nsICookie2 object to compute a key for. + * The nsICookie object to compute a key for. * @return string */ _getKeyForCookie(cookie) { return JSON.stringify({ host: cookie.host, name: cookie.name, path: cookie.path, attr: ChromeUtils.originAttributesToSuffix(cookie.originAttributes),
--- a/browser/components/sessionstore/test/browser_cookies_legacy.js +++ b/browser/components/sessionstore/test/browser_cookies_legacy.js @@ -24,17 +24,17 @@ function waitForNewCookie({host, name, v info(`waiting for cookie ${name}=${value} from ${host}...`); return new Promise(resolve => { Services.obs.addObserver(function observer(subj, topic, data) { if (data != "added") { return; } - let cookie = subj.QueryInterface(Ci.nsICookie2); + let cookie = subj.QueryInterface(Ci.nsICookie); if (cookie.host == host && cookie.name == name && cookie.value == value) { ok(true, "cookie added by the cookie service"); Services.obs.removeObserver(observer, topic); resolve(); } }, "session-cookie-changed"); }); }
--- a/browser/components/sessionstore/test/browser_cookies_privacy.js +++ b/browser/components/sessionstore/test/browser_cookies_privacy.js @@ -4,17 +4,17 @@ const MAX_EXPIRY = Math.pow(2, 62); function addCookie(scheme, secure = false) { let cookie = createTestCookie("http", secure); Services.cookies.add(cookie.host, cookie.path, cookie.name, cookie.value, cookie.secure, /* isHttpOnly = */ false, /* isSession = */ true, MAX_EXPIRY, /* originAttributes = */ {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); return cookie; } function createTestCookie(scheme, secure = false) { let r = Math.round(Math.random() * 100000); let cookie = { host: `${scheme}://example.com`,
--- a/browser/modules/Discovery.jsm +++ b/browser/modules/Discovery.jsm @@ -106,14 +106,14 @@ const DiscoveryInternal = { continue; } Services.cookies.add(site, "/", TAAR_COOKIE_NAME, id, true, // secure true, // httpOnly true, // session Date.now(), originAttributes, - Ci.nsICookie2.SAMESITE_LAX); + Ci.nsICookie.SAMESITE_LAX); } } } }, };
--- a/browser/modules/test/unit/test_discovery.js +++ b/browser/modules/test/unit/test_discovery.js @@ -41,17 +41,17 @@ add_task(async function test_discovery() ok(!Services.cookies.cookieExists(uri.host, "/", TAAR_COOKIE_NAME, {privateBrowsingId: 1}), "no private cookie exists"); ContextualIdentityService.getPublicIdentities().forEach(identity => { let {userContextId} = identity; equal(Services.cookies.cookieExists(uri.host, "/", TAAR_COOKIE_NAME, {userContextId}), identity.public, "cookie exists"); }); // Test the addition of a new container. let changed = TestUtils.topicObserved("cookie-changed", (subject, data) => { - let cookie = subject.QueryInterface(Ci.nsICookie2); + let cookie = subject.QueryInterface(Ci.nsICookie); equal(cookie.name, TAAR_COOKIE_NAME, "taar cookie exists"); equal(cookie.host, uri.host, "cookie exists for host"); equal(cookie.originAttributes.userContextId, container.userContextId, "cookie userContextId is correct"); return true; }); let container = ContextualIdentityService.create("New Container", "Icon", "Color"); await changed; @@ -80,17 +80,17 @@ add_task(async function test_discovery() ok(!Services.cookies.cookieExists(uri.host, "/", TAAR_COOKIE_NAME, {userContextId}), "no cookie exists"); }); // Make sure clientId changes update discovery changed = TestUtils.topicObserved("cookie-changed", (subject, data) => { if (data !== "added") { return false; } - let cookie = subject.QueryInterface(Ci.nsICookie2); + let cookie = subject.QueryInterface(Ci.nsICookie); equal(cookie.name, TAAR_COOKIE_NAME, "taar cookie exists"); equal(cookie.host, uri.host, "cookie exists for host"); return true; }); ClientID.resetClientID(); await changed; // Make sure disabling telemetry disables discovery.
--- a/devtools/server/actors/storage.js +++ b/devtools/server/actors/storage.js @@ -995,25 +995,25 @@ var cookieHelpers = { switch (topic) { case "cookie-changed": if (data === "batch-deleted") { const cookiesNoInterface = subject.QueryInterface(Ci.nsIArray); const cookies = []; for (let i = 0; i < cookiesNoInterface.length; i++) { - const cookie = cookiesNoInterface.queryElementAt(i, Ci.nsICookie2); + const cookie = cookiesNoInterface.queryElementAt(i, Ci.nsICookie); cookies.push(cookie); } cookieHelpers.onCookieChanged(cookies, topic, data); return; } - const cookie = subject.QueryInterface(Ci.nsICookie2); + const cookie = subject.QueryInterface(Ci.nsICookie); cookieHelpers.onCookieChanged(cookie, topic, data); break; } }, handleParentRequest(msg) { switch (msg.json.method) { case "onCookieChanged":
--- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1862,18 +1862,18 @@ def addExternalIface(iface, nativeType=N } if not nativeType is None: domInterface['nativeType'] = nativeType if not headerFile is None: domInterface['headerFile'] = headerFile domInterface['notflattened'] = notflattened DOMInterfaces[iface] = domInterface -addExternalIface('Cookie', nativeType='nsICookie2', - headerFile='nsICookie2.h', notflattened=True) +addExternalIface('Cookie', nativeType='nsICookie', + headerFile='nsICookie.h', notflattened=True) addExternalIface('ContentSecurityPolicy', nativeType='nsIContentSecurityPolicy', notflattened=True) addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LoadContext', nativeType='nsILoadContext', notflattened=True) addExternalIface('LoadInfo', nativeType='nsILoadInfo', headerFile='nsILoadInfo.h', notflattened=True)
--- a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_cookies_cache.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_cookies_cache.html @@ -18,17 +18,17 @@ const COOKIE = { host: "example.com", name: "test_cookie", path: "/", }; let since, oldCookie; function addCookie(cookie) { let expiry = Date.now() / 1000 + 10000; - Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + Services.cookies.add(cookie.host, cookie.path, cookie.name, "test", false, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); ok(Services.cookies.cookieExists(cookie.host, cookie.path, cookie.name, {}), `Cookie ${cookie.name} was created.`); } async function setUpCookies() { // Add a cookie which will end up with an older creationTime. oldCookie = Object.assign({}, COOKIE, {name: Date.now()}); addCookie(oldCookie); await new Promise(resolve => setTimeout(resolve, 20));
--- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -322,22 +322,22 @@ void CookieServiceChild::GetCookieString // if the cookie is secure and the host scheme isn't, we can't send it if (cookie->IsSecure() && !isSecure) continue; int32_t sameSiteAttr = 0; cookie->GetSameSite(&sameSiteAttr); if (aIsSameSiteForeign) { // it if's a cross origin request and the cookie is same site only // (strict) don't send it - if (sameSiteAttr == nsICookie2::SAMESITE_STRICT) { + if (sameSiteAttr == nsICookie::SAMESITE_STRICT) { continue; } // if it's a cross origin request, the cookie is same site lax, but it's // not a top-level navigation, don't send it - if (sameSiteAttr == nsICookie2::SAMESITE_LAX && !aIsSafeTopLevelNav) { + if (sameSiteAttr == nsICookie::SAMESITE_LAX && !aIsSafeTopLevelNav) { continue; } } // if the nsIURI path doesn't match the cookie path, don't send it back if (!nsCookieService::PathMatches(cookie, pathFromURI)) continue; // check if the cookie has expired
--- a/netwerk/cookie/moz.build +++ b/netwerk/cookie/moz.build @@ -5,17 +5,16 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. with Files('**'): BUG_COMPONENT = ('Core', 'Networking: Cookies') # export required interfaces, even if --disable-cookies has been given XPIDL_SOURCES += [ 'nsICookie.idl', - 'nsICookie2.idl', 'nsICookieManager.idl', 'nsICookiePermission.idl', 'nsICookieService.idl', 'nsICookieSettings.idl', ] XPIDL_MODULE = 'necko_cookie'
--- a/netwerk/cookie/nsCookie.cpp +++ b/netwerk/cookie/nsCookie.cpp @@ -63,18 +63,18 @@ already_AddRefed<nsCookie> nsCookie::Cre // If the creationTime given to us is higher than the running maximum, update // our maximum. if (cookie->mData.creationTime() > gLastCreationTime) { gLastCreationTime = cookie->mData.creationTime(); } // If aSameSite is not a sensible value, assume strict if (cookie->mData.sameSite() < 0 || - cookie->mData.sameSite() > nsICookie2::SAMESITE_STRICT) { - cookie->mData.sameSite() = nsICookie2::SAMESITE_STRICT; + cookie->mData.sameSite() > nsICookie::SAMESITE_STRICT) { + cookie->mData.sameSite() = nsICookie::SAMESITE_STRICT; } return cookie.forget(); } size_t nsCookie::SizeOfIncludingThis( mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + @@ -167,9 +167,9 @@ nsCookie::GetExpires(uint64_t* aExpires) if (IsSession()) { *aExpires = 0; } else { *aExpires = Expiry() > 0 ? Expiry() : 1; } return NS_OK; } -NS_IMPL_ISUPPORTS(nsCookie, nsICookie2, nsICookie) +NS_IMPL_ISUPPORTS(nsCookie, nsICookie)
--- a/netwerk/cookie/nsCookie.h +++ b/netwerk/cookie/nsCookie.h @@ -2,44 +2,41 @@ /* 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/. */ #ifndef nsCookie_h__ #define nsCookie_h__ #include "nsICookie.h" -#include "nsICookie2.h" #include "nsString.h" #include "mozilla/MemoryReporting.h" #include "mozilla/BasePrincipal.h" #include "mozilla/net/NeckoChannelParams.h" using mozilla::OriginAttributes; /** * The nsCookie class is the main cookie storage medium for use within cookie - * code. It implements nsICookie2, which extends nsICookie, a frozen interface - * for xpcom access of cookie objects. + * code. */ /****************************************************************************** * nsCookie: * implementation ******************************************************************************/ -class nsCookie final : public nsICookie2 { +class nsCookie final : public nsICookie { MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) public: // nsISupports NS_DECL_ISUPPORTS NS_DECL_NSICOOKIE - NS_DECL_NSICOOKIE2 private: // for internal use only. see nsCookie::Create(). nsCookie(const mozilla::net::CookieStruct& aCookieData, const OriginAttributes& aOriginAttributes) : mData(aCookieData), mOriginAttributes(aOriginAttributes) {} public:
--- a/netwerk/cookie/nsCookiePermission.cpp +++ b/netwerk/cookie/nsCookiePermission.cpp @@ -1,17 +1,17 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 sw=2 et: */ /* 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/. */ #include "nsCookiePermission.h" -#include "nsICookie2.h" +#include "nsICookie.h" #include "nsIServiceManager.h" #include "nsICookieManager.h" #include "nsICookieService.h" #include "nsNetUtil.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIProtocolHandler.h" #include "nsIURI.h" #include "nsIChannel.h" @@ -75,17 +75,17 @@ nsCookiePermission::SetAccess(nsIURI* aU // this is nice because it avoids conversion code. // return mPermMgr->Add(aURI, kPermissionType, aAccess, nsIPermissionManager::EXPIRE_NEVER, 0); } NS_IMETHODIMP nsCookiePermission::CanSetCookie(nsIURI* aURI, nsIChannel* aChannel, - nsICookie2* aCookie, bool* aIsSession, + nsICookie* aCookie, bool* aIsSession, int64_t* aExpiry, bool* aResult) { NS_ASSERTION(aURI, "null uri"); *aResult = kDefaultPolicy; // Lazily initialize ourselves if (!EnsureInitialized()) return NS_ERROR_UNEXPECTED;
--- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -2259,25 +2259,25 @@ void nsCookieService::NotifyChanged(nsIS if (!cookie->IsSession() && !aOldCookieIsSession) { return; } } os->NotifyObservers(aSubject, "session-cookie-changed", aData); } already_AddRefed<nsIArray> nsCookieService::CreatePurgeList( - nsICookie2* aCookie) { + nsICookie* aCookie) { nsCOMPtr<nsIMutableArray> removedList = do_CreateInstance(NS_ARRAY_CONTRACTID); removedList->AppendElement(aCookie); return removedList.forget(); } void nsCookieService::CreateOrUpdatePurgeList(nsIArray** aPurgedList, - nsICookie2* aCookie) { + nsICookie* aCookie) { if (!*aPurgedList) { COOKIE_LOGSTRING(LogLevel::Debug, ("Creating new purge list")); nsCOMPtr<nsIArray> purgedList = CreatePurgeList(aCookie); purgedList.forget(aPurgedList); return; } nsCOMPtr<nsIMutableArray> purgedList = do_QueryInterface(*aPurgedList); @@ -2395,17 +2395,17 @@ nsCookieService::GetEnumerator(nsISimple nsCOMArray<nsICookie> cookieList(mDBState->cookieCount); for (auto iter = mDBState->hostTable.Iter(); !iter.Done(); iter.Next()) { const nsCookieEntry::ArrayType& cookies = iter.Get()->GetCookies(); for (nsCookieEntry::IndexType i = 0; i < cookies.Length(); ++i) { cookieList.AppendObject(cookies[i]); } } - return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie2)); + return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie)); } NS_IMETHODIMP nsCookieService::GetSessionEnumerator(nsISimpleEnumerator** aEnumerator) { if (!mDBState) { NS_WARNING("No DBState! Profile already closed?"); return NS_ERROR_NOT_AVAILABLE; } @@ -2419,17 +2419,17 @@ nsCookieService::GetSessionEnumerator(ns nsCookie* cookie = cookies[i]; // Filter out non-session cookies. if (cookie->IsSession()) { cookieList.AppendObject(cookie); } } } - return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie2)); + return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie)); } NS_IMETHODIMP nsCookieService::Add(const nsACString& aHost, const nsACString& aPath, const nsACString& aName, const nsACString& aValue, bool aIsSecure, bool aIsHttpOnly, bool aIsSession, int64_t aExpiry, JS::HandleValue aOriginAttributes, int32_t aSameSite, JSContext* aCx) { @@ -2854,17 +2854,17 @@ nsCookieService::ImportCookies(nsIFile* RefPtr<nsCookie> newCookie = nsCookie::Create( Substring(buffer, nameIndex, cookieIndex - nameIndex - 1), Substring(buffer, cookieIndex, buffer.Length() - cookieIndex), host, Substring(buffer, pathIndex, secureIndex - pathIndex - 1), expires, lastAccessedCounter, nsCookie::GenerateUniqueCreationTime(currentTimeInUsec), false, Substring(buffer, secureIndex, expiresIndex - secureIndex - 1) .EqualsLiteral(kTrue), - isHttpOnly, key.mOriginAttributes, nsICookie2::SAMESITE_NONE); + isHttpOnly, key.mOriginAttributes, nsICookie::SAMESITE_NONE); if (!newCookie) { return NS_ERROR_OUT_OF_MEMORY; } // trick: preserve the most-recently-used cookie ordering, // by successively decrementing the lastAccessed time lastAccessedCounter--; @@ -3039,22 +3039,22 @@ void nsCookieService::GetCookiesForURI( // if the cookie is secure and the host scheme isn't, we can't send it if (cookie->IsSecure() && !isSecure) continue; int32_t sameSiteAttr = 0; cookie->GetSameSite(&sameSiteAttr); if (aIsSameSiteForeign) { // it if's a cross origin request and the cookie is same site only // (strict) don't send it - if (sameSiteAttr == nsICookie2::SAMESITE_STRICT) { + if (sameSiteAttr == nsICookie::SAMESITE_STRICT) { continue; } // if it's a cross origin request, the cookie is same site lax, but it's // not a top-level navigation, don't send it - if (sameSiteAttr == nsICookie2::SAMESITE_LAX && !aIsSafeTopLevelNav) { + if (sameSiteAttr == nsICookie::SAMESITE_LAX && !aIsSafeTopLevelNav) { continue; } } // if the cookie is httpOnly and it's not going directly to the HTTP // connection, don't send it if (cookie->IsHttpOnly() && !aHttpBound) continue; @@ -3306,18 +3306,17 @@ bool nsCookieService::CanSetCookie(nsIUR if (aCookieData.isSecure() && !isHTTPS) { COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, aCookieHeader, "non-https cookie can't set secure flag"); return newCookie; } // If the new cookie is same-site but in a cross site context, // browser must ignore the cookie. - if ((aCookieData.sameSite() != nsICookie2::SAMESITE_NONE) && - aThirdPartyUtil) { + if ((aCookieData.sameSite() != nsICookie::SAMESITE_NONE) && aThirdPartyUtil) { // Do not treat loads triggered by web extensions as foreign bool addonAllowsLoad = false; if (aChannel) { nsCOMPtr<nsIURI> channelURI; NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI)); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo(); addonAllowsLoad = BasePrincipal::Cast(loadInfo->TriggeringPrincipal()) ->AddonAllowsLoad(channelURI); @@ -3371,17 +3370,17 @@ bool nsCookieService::SetCookieInternal( if (!cookie) return newCookie; // check permissions from site permission list, or ask the user, // to determine if we can set the cookie if (mPermissionService) { bool permission; mPermissionService->CanSetCookie( aHostURI, aChannel, - static_cast<nsICookie2*>(static_cast<nsCookie*>(cookie)), + static_cast<nsICookie*>(static_cast<nsCookie*>(cookie)), &cookieData.isSession(), &cookieData.expiry(), &permission); if (!permission) { COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, "cookie rejected by permission manager"); NotifyRejected( aHostURI, aChannel, nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION, OPERATION_WRITE); @@ -3749,17 +3748,17 @@ bool nsCookieService::ParseAttributes(ns nsACString::const_char_iterator tempBegin, tempEnd; nsACString::const_char_iterator cookieStart, cookieEnd; aCookieHeader.BeginReading(cookieStart); aCookieHeader.EndReading(cookieEnd); aCookieData.isSecure() = false; aCookieData.isHttpOnly() = false; - aCookieData.sameSite() = nsICookie2::SAMESITE_NONE; + aCookieData.sameSite() = nsICookie::SAMESITE_NONE; nsDependentCSubstring tokenString(cookieStart, cookieStart); nsDependentCSubstring tokenValue(cookieStart, cookieStart); bool newCookie, equalsFound; // extract cookie <NAME> & <VALUE> (first attribute), and copy the strings. // if we find multiple cookies, return for processing // note: if there's no '=', we assume token is <VALUE>. this is required by @@ -3803,19 +3802,19 @@ bool nsCookieService::ParseAttributes(ns // ignore any tokenValue for isHttpOnly (see bug 178993); // just set the boolean else if (tokenString.LowerCaseEqualsLiteral(kHttpOnly)) aCookieData.isHttpOnly() = true; else if (tokenString.LowerCaseEqualsLiteral(kSameSite)) { if (tokenValue.LowerCaseEqualsLiteral(kSameSiteLax)) { - aCookieData.sameSite() = nsICookie2::SAMESITE_LAX; + aCookieData.sameSite() = nsICookie::SAMESITE_LAX; } else if (tokenValue.LowerCaseEqualsLiteral(kSameSiteStrict)) { - aCookieData.sameSite() = nsICookie2::SAMESITE_STRICT; + aCookieData.sameSite() = nsICookie::SAMESITE_STRICT; } } } // rebind aCookieHeader, in case we need to process another cookie aCookieHeader.Rebind(cookieStart, cookieEnd); return newCookie; } @@ -4584,17 +4583,17 @@ nsCookieService::GetCookiesFromHost(cons if (!entry) return NS_NewEmptyEnumerator(aEnumerator); nsCOMArray<nsICookie> cookieList(mMaxCookiesPerHost); const nsCookieEntry::ArrayType& cookies = entry->GetCookies(); for (nsCookieEntry::IndexType i = 0; i < cookies.Length(); ++i) { cookieList.AppendObject(cookies[i]); } - return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie2)); + return NS_NewArrayEnumerator(aEnumerator, cookieList, NS_GET_IID(nsICookie)); } NS_IMETHODIMP nsCookieService::GetCookiesWithOriginAttributes( const nsAString& aPattern, const nsACString& aHost, nsISimpleEnumerator** aEnumerator) { mozilla::OriginAttributesPattern pattern; if (!pattern.Init(aPattern)) { @@ -4641,17 +4640,17 @@ nsresult nsCookieService::GetCookiesWith const nsCookieEntry::ArrayType& entryCookies = entry->GetCookies(); for (nsCookieEntry::IndexType i = 0; i < entryCookies.Length(); ++i) { cookies.AppendObject(entryCookies[i]); } } - return NS_NewArrayEnumerator(aEnumerator, cookies, NS_GET_IID(nsICookie2)); + return NS_NewArrayEnumerator(aEnumerator, cookies, NS_GET_IID(nsICookie)); } NS_IMETHODIMP nsCookieService::RemoveCookiesWithOriginAttributes(const nsAString& aPattern, const nsACString& aHost) { MOZ_ASSERT(XRE_IsParentProcess()); mozilla::OriginAttributesPattern pattern;
--- a/netwerk/cookie/nsCookieService.h +++ b/netwerk/cookie/nsCookieService.h @@ -320,19 +320,19 @@ class nsCookieService final : public nsI void FindStaleCookies(nsCookieEntry* aEntry, int64_t aCurrentTime, bool aIsSecure, nsTArray<nsListIter>& aOutput, uint32_t aLimit); void NotifyAccepted(nsIChannel* aChannel); void NotifyRejected(nsIURI* aHostURI, nsIChannel* aChannel, uint32_t aRejectedReason, CookieOperation aOperation); void NotifyChanged(nsISupports* aSubject, const char16_t* aData, bool aOldCookieIsSession = false, bool aFromHttp = false); - void NotifyPurged(nsICookie2* aCookie); - already_AddRefed<nsIArray> CreatePurgeList(nsICookie2* aCookie); - void CreateOrUpdatePurgeList(nsIArray** aPurgeList, nsICookie2* aCookie); + void NotifyPurged(nsICookie* aCookie); + already_AddRefed<nsIArray> CreatePurgeList(nsICookie* aCookie); + void CreateOrUpdatePurgeList(nsIArray** aPurgeList, nsICookie* aCookie); void UpdateCookieOldestTime(DBState* aDBState, nsCookie* aCookie); nsresult GetCookiesWithOriginAttributes( const mozilla::OriginAttributesPattern& aPattern, const nsCString& aBaseDomain, nsISimpleEnumerator** aEnumerator); nsresult RemoveCookiesWithOriginAttributes( const mozilla::OriginAttributesPattern& aPattern, const nsCString& aBaseDomain);
--- a/netwerk/cookie/nsICookie.idl +++ b/netwerk/cookie/nsICookie.idl @@ -2,25 +2,27 @@ * * 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/. */ #include "nsISupports.idl" /** - * An optional interface for accessing the HTTP or - * javascript cookie object + * Main cookie object interface. */ typedef long nsCookieStatus; typedef long nsCookiePolicy; [builtinclass, scriptable, uuid(adf0db5e-211e-45a3-be14-4486ac430a58)] interface nsICookie : nsISupports { + const uint32_t SAMESITE_NONE = 0; + const uint32_t SAMESITE_LAX = 1; + const uint32_t SAMESITE_STRICT = 2; /** * the name of the cookie */ readonly attribute ACString name; /** * the cookie value @@ -33,32 +35,88 @@ interface nsICookie : nsISupports { readonly attribute boolean isDomain; /** * the host (possibly fully qualified) of the cookie */ readonly attribute AUTF8String host; /** + * the host (possibly fully qualified) of the cookie, + * without a leading dot to represent if it is a + * domain cookie. + */ + readonly attribute AUTF8String rawHost; + + /** * the path pertaining to the cookie */ readonly attribute AUTF8String path; /** * true if the cookie was transmitted over ssl, false otherwise */ readonly attribute boolean isSecure; /** - * @DEPRECATED use nsICookie2.expiry and nsICookie2.isSession instead. + * @DEPRECATED use nsICookie.expiry and nsICookie.isSession instead. * * expiration time in seconds since midnight (00:00:00), January 1, 1970 UTC. * expires = 0 represents a session cookie. * expires = 1 represents an expiration time earlier than Jan 1, 1970. */ readonly attribute uint64_t expires; /** + * the actual expiry time of the cookie, in seconds + * since midnight (00:00:00), January 1, 1970 UTC. + * + * this is distinct from nsICookie::expires, which + * has different and obsolete semantics. + */ + readonly attribute int64_t expiry; + + /** * The origin attributes for this cookie */ [implicit_jscontext] readonly attribute jsval originAttributes; + + /** + * true if the cookie is a session cookie. + * note that expiry time will also be honored + * for session cookies (see below); thus, whichever is + * the more restrictive of the two will take effect. + */ + readonly attribute boolean isSession; + + /** + * true if the cookie is an http only cookie + */ + readonly attribute boolean isHttpOnly; + + /** + * the creation time of the cookie, in microseconds + * since midnight (00:00:00), January 1, 1970 UTC. + */ + readonly attribute int64_t creationTime; + + /** + * the last time the cookie was accessed (i.e. created, + * modified, or read by the server), in microseconds + * since midnight (00:00:00), January 1, 1970 UTC. + * + * note that this time may be approximate. + */ + readonly attribute int64_t lastAccessed; + + /** + * the sameSite attribute; this controls the cookie behavior for cross-site + * requests as per + * https://tools.ietf.org/html/draft-west-first-party-cookies-07 + * + * This should be one of: + * - SAMESITE_NONE - the SameSite attribute is not present + * - SAMESITE_LAX - the SameSite attribute is present, but not strict + * - SAMESITE_STRICT - the SameSite attribute is present and strict + */ + readonly attribute int32_t sameSite; };
deleted file mode 100644 --- a/netwerk/cookie/nsICookie2.idl +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "nsICookie.idl" - -/** - * Main cookie object interface for use by consumers: - * extends nsICookie, a frozen interface for external - * access of cookie objects - */ - -[builtinclass, scriptable, uuid(be205dae-4f4c-11e6-80ba-ea5cd310c1a8)] -interface nsICookie2 : nsICookie -{ - const uint32_t SAMESITE_NONE = 0; - const uint32_t SAMESITE_LAX = 1; - const uint32_t SAMESITE_STRICT = 2; - - /** - * the host (possibly fully qualified) of the cookie, - * without a leading dot to represent if it is a - * domain cookie. - */ - readonly attribute AUTF8String rawHost; - - /** - * true if the cookie is a session cookie. - * note that expiry time will also be honored - * for session cookies (see below); thus, whichever is - * the more restrictive of the two will take effect. - */ - readonly attribute boolean isSession; - - /** - * the actual expiry time of the cookie, in seconds - * since midnight (00:00:00), January 1, 1970 UTC. - * - * this is distinct from nsICookie::expires, which - * has different and obsolete semantics. - */ - readonly attribute int64_t expiry; - - /** - * true if the cookie is an http only cookie - */ - readonly attribute boolean isHttpOnly; - - /** - * the creation time of the cookie, in microseconds - * since midnight (00:00:00), January 1, 1970 UTC. - */ - readonly attribute int64_t creationTime; - - /** - * the last time the cookie was accessed (i.e. created, - * modified, or read by the server), in microseconds - * since midnight (00:00:00), January 1, 1970 UTC. - * - * note that this time may be approximate. - */ - readonly attribute int64_t lastAccessed; - - /** - * the sameSite attribute; this controls the cookie behavior for cross-site - * requests as per - * https://tools.ietf.org/html/draft-west-first-party-cookies-07 - * - * This should be one of: - * - SAMESITE_NONE - the SameSite attribute is not present - * - SAMESITE_LAX - the SameSite attribute is present, but not strict - * - SAMESITE_STRICT - the SameSite attribute is present and strict - */ - readonly attribute int32_t sameSite; -};
--- a/netwerk/cookie/nsICookieManager.idl +++ b/netwerk/cookie/nsICookieManager.idl @@ -9,17 +9,17 @@ namespace mozilla { class OriginAttributes; } // mozilla namespace %} [ptr] native OriginAttributesPtr(mozilla::OriginAttributes); interface nsISimpleEnumerator; -interface nsICookie2; +interface nsICookie; interface nsIFile; [scriptable, function, uuid(20709db8-8dad-4e45-b33e-6e7c761dfc5d)] interface nsIPrivateModeCallback : nsISupports { void callback(); }; @@ -195,17 +195,17 @@ interface nsICookieManager : nsISupports * * @param aHost * the host string to search for, e.g. "google.com". this should consist * of only the host portion of a URI. see @add for a description of * acceptable host strings. * @param aOriginAttributes The originAttributes of cookies that would be * retrived. * - * @return an nsISimpleEnumerator of nsICookie2 objects. + * @return an nsISimpleEnumerator of nsICookie objects. * * @see countCookiesFromHost */ [implicit_jscontext] nsISimpleEnumerator getCookiesFromHost(in AUTF8String aHost, in jsval aOriginAttributes); /**
--- a/netwerk/cookie/nsICookiePermission.idl +++ b/netwerk/cookie/nsICookiePermission.idl @@ -1,15 +1,15 @@ /* 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/. */ #include "nsISupports.idl" -interface nsICookie2; +interface nsICookie; interface nsIURI; interface nsIChannel; interface nsIPrincipal; typedef long nsCookieAccess; /** * An interface to test for cookie permissions @@ -77,13 +77,13 @@ interface nsICookiePermission : nsISuppo * when canSetCookie is invoked, this is the current expiry time of * the cookie. canSetCookie may leave this value unchanged to * preserve this attribute of the cookie. * * @return true if the cookie can be set. */ boolean canSetCookie(in nsIURI aURI, in nsIChannel aChannel, - in nsICookie2 aCookie, + in nsICookie aCookie, inout boolean aIsSession, inout int64_t aExpiry); };
--- a/netwerk/cookie/nsICookieService.idl +++ b/netwerk/cookie/nsICookieService.idl @@ -37,29 +37,29 @@ interface nsICookieTransactionCallback : * immediately followed by "added". You may check the state of the cookie * list to determine if this is the case. * * topic : "cookie-changed" * broadcast whenever the cookie list changes in some way. see * explanation of data strings below. * subject: see below. * data : "deleted" - * a cookie was deleted. the subject is an nsICookie2 representing + * a cookie was deleted. the subject is an nsICookie representing * the deleted cookie. * "added" - * a cookie was added. the subject is an nsICookie2 representing + * a cookie was added. the subject is an nsICookie representing * the added cookie. * "changed" - * a cookie was changed. the subject is an nsICookie2 representing + * a cookie was changed. the subject is an nsICookie representing * the new cookie. (note that host, path, and name are invariant * for a given cookie; other parameters may change.) * "batch-deleted" * a set of cookies was purged (typically, because they have either * expired or because the cookie list has grown too large). The subject - * is an nsIArray of nsICookie2's representing the deleted cookies. + * is an nsIArray of nsICookie's representing the deleted cookies. * Note that the array could contain a single cookie. * "cleared" * the entire cookie list was cleared. the subject is null. * * topic : "cookie-rejected" * broadcast whenever a cookie was rejected from being set as a * result of user prefs. * subject: an nsIURI interface pointer representing the URI that attempted
--- a/netwerk/cookie/test/unit/test_bug1155169.js +++ b/netwerk/cookie/test/unit/test_bug1155169.js @@ -47,17 +47,17 @@ function setCookie(value, expected) { do_throw("no notification expected"); return; } // Check we saw the right notification. Assert.equal(data, expectedInternal.type); // Check cookie details. - let cookie = subject.QueryInterface(Ci.nsICookie2); + let cookie = subject.QueryInterface(Ci.nsICookie); Assert.equal(cookie.isSession, expectedInternal.isSession); Assert.equal(cookie.isSecure, expectedInternal.isSecure); Assert.equal(cookie.isHttpOnly, expectedInternal.isHttpOnly); } Services.obs.addObserver(observer, "cookie-changed"); cs.setCookieStringFromHttp(URI, null, null, valueInternal, null, null); Services.obs.removeObserver(observer, "cookie-changed");
--- a/netwerk/test/TestCookie.cpp +++ b/netwerk/test/TestCookie.cpp @@ -3,17 +3,17 @@ * 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/. */ #include "TestCommon.h" #include "gtest/gtest.h" #include "nsIServiceManager.h" #include "nsICookieService.h" #include "nsICookieManager.h" -#include "nsICookie2.h" +#include "nsICookie.h" #include <stdio.h> #include "plstr.h" #include "nsNetUtil.h" #include "nsIChannel.h" #include "nsIPrincipal.h" #include "nsIScriptSecurityManager.h" #include "nsISimpleEnumerator.h" #include "nsServiceManagerUtils.h" @@ -852,53 +852,53 @@ TEST(TestCookie, TestCookieMain) NS_LITERAL_CSTRING("/foo"), // path NS_LITERAL_CSTRING("test1"), // name NS_LITERAL_CSTRING("yes"), // value false, // is secure false, // is httponly true, // is session INT64_MAX, // expiry time &attrs, // originAttributes - nsICookie2::SAMESITE_NONE))); + nsICookie::SAMESITE_NONE))); EXPECT_TRUE(NS_SUCCEEDED( cookieMgr2->AddNative(NS_LITERAL_CSTRING("cookiemgr.test"), // domain NS_LITERAL_CSTRING("/foo"), // path NS_LITERAL_CSTRING("test2"), // name NS_LITERAL_CSTRING("yes"), // value false, // is secure true, // is httponly true, // is session PR_Now() / PR_USEC_PER_SEC + 2, // expiry time &attrs, // originAttributes - nsICookie2::SAMESITE_NONE))); + nsICookie::SAMESITE_NONE))); EXPECT_TRUE(NS_SUCCEEDED( cookieMgr2->AddNative(NS_LITERAL_CSTRING("new.domain"), // domain NS_LITERAL_CSTRING("/rabbit"), // path NS_LITERAL_CSTRING("test3"), // name NS_LITERAL_CSTRING("yes"), // value false, // is secure false, // is httponly true, // is session INT64_MAX, // expiry time &attrs, // originAttributes - nsICookie2::SAMESITE_NONE))); + nsICookie::SAMESITE_NONE))); // confirm using enumerator nsCOMPtr<nsISimpleEnumerator> enumerator; EXPECT_TRUE( NS_SUCCEEDED(cookieMgr->GetEnumerator(getter_AddRefs(enumerator)))); int32_t i = 0; bool more; - nsCOMPtr<nsICookie2> expiredCookie, newDomainCookie; + nsCOMPtr<nsICookie> expiredCookie, newDomainCookie; while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) { nsCOMPtr<nsISupports> cookie; if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break; ++i; // keep tabs on the second and third cookies, so we can check them later - nsCOMPtr<nsICookie2> cookie2(do_QueryInterface(cookie)); + nsCOMPtr<nsICookie> cookie2(do_QueryInterface(cookie)); if (!cookie2) break; nsAutoCString name; cookie2->GetName(name); if (name.EqualsLiteral("test2")) expiredCookie = cookie2; else if (name.EqualsLiteral("test3")) newDomainCookie = cookie2; } @@ -936,17 +936,17 @@ TEST(TestCookie, TestCookieMain) NS_LITERAL_CSTRING("/rabbit"), // path NS_LITERAL_CSTRING("test3"), // name NS_LITERAL_CSTRING("yes"), // value false, // is secure false, // is httponly true, // is session INT64_MIN, // expiry time &attrs, // originAttributes - nsICookie2::SAMESITE_NONE))); + nsICookie::SAMESITE_NONE))); EXPECT_TRUE(NS_SUCCEEDED(cookieMgr2->CookieExistsNative( NS_LITERAL_CSTRING("new.domain"), NS_LITERAL_CSTRING("/rabbit"), NS_LITERAL_CSTRING("test3"), &attrs, &found))); EXPECT_FALSE(found); // sleep four seconds, to make sure the second cookie has expired PR_Sleep(4 * PR_TicksPerSecond()); // check that both CountCookiesFromHost() and CookieExistsNative() count the // expired cookie @@ -1067,34 +1067,34 @@ TEST(TestCookie, TestCookieMain) // check the cookies for the required samesite value while (NS_SUCCEEDED(enumerator->HasMoreElements(&more)) && more) { nsCOMPtr<nsISupports> cookie; if (NS_FAILED(enumerator->GetNext(getter_AddRefs(cookie)))) break; ++i; // keep tabs on the second and third cookies, so we can check them later - nsCOMPtr<nsICookie2> cookie2(do_QueryInterface(cookie)); + nsCOMPtr<nsICookie> cookie2(do_QueryInterface(cookie)); if (!cookie2) break; nsAutoCString name; cookie2->GetName(name); int32_t sameSiteAttr; cookie2->GetSameSite(&sameSiteAttr); if (name.EqualsLiteral("unset")) { - EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE); + EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_NONE); } else if (name.EqualsLiteral("unspecified")) { - EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE); + EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_NONE); } else if (name.EqualsLiteral("empty")) { - EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE); + EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_NONE); } else if (name.EqualsLiteral("bogus")) { - EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_NONE); + EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_NONE); } else if (name.EqualsLiteral("strict")) { - EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_STRICT); + EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_STRICT); } else if (name.EqualsLiteral("lax")) { - EXPECT_TRUE(sameSiteAttr == nsICookie2::SAMESITE_LAX); + EXPECT_TRUE(sameSiteAttr == nsICookie::SAMESITE_LAX); } } EXPECT_TRUE(i == 6); // *** SameSite attribute // Clear the cookies EXPECT_TRUE(NS_SUCCEEDED(cookieMgr->RemoveAll()));
--- a/netwerk/test/mochitests/file_1331680.js +++ b/netwerk/test/mochitests/file_1331680.js @@ -1,15 +1,15 @@ const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); var observer = { observe: function(subject, topic, data) { if (topic == "cookie-changed") { - let cookie = subject.QueryInterface(Ci.nsICookie2); + let cookie = subject.QueryInterface(Ci.nsICookie); sendAsyncMessage("cookieName", cookie.name + "=" + cookie.value); sendAsyncMessage("cookieOperation", data); } } }; addMessageListener("createObserver" , function(e) { Services.obs.addObserver(observer, "cookie-changed");
--- a/netwerk/test/mochitests/file_testloadflags_chromescript.js +++ b/netwerk/test/mochitests/file_testloadflags_chromescript.js @@ -78,17 +78,17 @@ addMessageListener("init", ({ domain }) info("we are going to remove these cookies"); let count = getCookieCount(cs); info(count + " cookies"); cs.removeAll(); cs.add(domain, "", "oh", "hai", false, false, true, Math.pow(2, 62), {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); is(cs.countCookiesFromHost(domain), 1, "number of cookies for domain " + domain); gObs = new obs(); sendAsyncMessage("init:return"); }); addMessageListener("getCookieCount", () => { let cs = Cc["@mozilla.org/cookiemanager;1"]
--- a/netwerk/test/unit/test_bug411952.js +++ b/netwerk/test/unit/test_bug411952.js @@ -1,16 +1,16 @@ function run_test() { try { var cm = Cc["@mozilla.org/cookiemanager;1"]. getService(Ci.nsICookieManager); Assert.notEqual(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, {}, Ci.nsICookie2.SAMESITE_NONE); + cm.add("example.com", "/", "C", "V", false, true, false, time, {}, Ci.nsICookie.SAMESITE_NONE); const now = Math.floor((new Date()).getTime() / 1000); var found = false; for (let cookie of cm.enumerator) { if (cookie.host == "example.com" && cookie.path == "/" && cookie.name == "C") { Assert.ok("creationTime" in cookie,
deleted file mode 100644 --- a/netwerk/test/unit/test_bug455598.js +++ /dev/null @@ -1,34 +0,0 @@ -/* 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/. */ - -function run_test() { - const time = (new Date("Jan 1, 2030")).getTime() / 1000; - var cookie = { - name: "foo", - value: "bar", - isDomain: true, - host: "example.com", - path: "/baz", - isSecure: false, - expires: time, - status: 0, - policy: 0, - isSession: false, - expiry: time, - isHttpOnly: true, - QueryInterface: function(iid) { - const validIIDs = [Ci.nsISupports, - Ci.nsICookie, - Ci.nsICookie2]; - for (var i = 0; i < validIIDs.length; ++i) - if (iid == validIIDs[i]) - return this; - throw Cr.NS_ERROR_NO_INTERFACE; - } - }; - var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); - Assert.ok(!cm.cookieExists(cookie.host, cookie.path, cookie.name, {})); - // if the above line does not crash, the test was successful - do_test_finished(); -}
--- a/netwerk/test/unit/test_bug526789.js +++ b/netwerk/test/unit/test_bug526789.js @@ -9,17 +9,17 @@ function run_test() { cm.removeAll(); // Allow all cookies. Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); // 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, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("baz.com"), 1); Assert.equal(cm.countCookiesFromHost("BAZ.com"), 1); Assert.equal(cm.countCookiesFromHost(".baz.com"), 1); Assert.equal(cm.countCookiesFromHost("baz.com."), 0); Assert.equal(cm.countCookiesFromHost(".baz.com."), 0); do_check_throws(function() { cm.countCookiesFromHost("baz.com.."); }, Cr.NS_ERROR_ILLEGAL_VALUE); @@ -31,53 +31,53 @@ function run_test() { }, Cr.NS_ERROR_ILLEGAL_VALUE); cm.remove("BAZ.com.", "foo", "/", false, {}); Assert.equal(cm.countCookiesFromHost("baz.com"), 1); cm.remove("baz.com", "foo", "/", false, {}); Assert.equal(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, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("baz.com"), 0); Assert.equal(cm.countCookiesFromHost("BAZ.com"), 0); Assert.equal(cm.countCookiesFromHost(".baz.com"), 0); Assert.equal(cm.countCookiesFromHost("baz.com."), 1); Assert.equal(cm.countCookiesFromHost(".baz.com."), 1); cm.remove("baz.com", "foo", "/", false, {}); Assert.equal(cm.countCookiesFromHost("baz.com."), 1); cm.remove("baz.com.", "foo", "/", false, {}); Assert.equal(cm.countCookiesFromHost("baz.com."), 0); // 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, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("192.168.0.1"), 1); Assert.equal(cm.countCookiesFromHost("192.168.0.1."), 0); do_check_throws(function() { cm.countCookiesFromHost(".192.168.0.1"); }, Cr.NS_ERROR_ILLEGAL_VALUE); do_check_throws(function() { cm.countCookiesFromHost(".192.168.0.1."); }, Cr.NS_ERROR_ILLEGAL_VALUE); cm.add("localhost", "/", "foo", "bar", false, false, true, expiry, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("localhost"), 1); Assert.equal(cm.countCookiesFromHost("localhost."), 0); do_check_throws(function() { cm.countCookiesFromHost(".localhost"); }, Cr.NS_ERROR_ILLEGAL_VALUE); do_check_throws(function() { cm.countCookiesFromHost(".localhost."); }, Cr.NS_ERROR_ILLEGAL_VALUE); cm.add("co.uk", "/", "foo", "bar", false, false, true, expiry, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("co.uk"), 1); Assert.equal(cm.countCookiesFromHost("co.uk."), 0); do_check_throws(function() { cm.countCookiesFromHost(".co.uk"); }, Cr.NS_ERROR_ILLEGAL_VALUE); do_check_throws(function() { cm.countCookiesFromHost(".co.uk."); }, Cr.NS_ERROR_ILLEGAL_VALUE); @@ -103,17 +103,17 @@ function run_test() { cm.getCookiesFromHost(".", {}); }, Cr.NS_ERROR_ILLEGAL_VALUE); do_check_throws(function() { cm.getCookiesFromHost("..", {}); }, Cr.NS_ERROR_ILLEGAL_VALUE); e = cm.getCookiesFromHost("baz.com", {}); Assert.ok(e.hasMoreElements()); - Assert.equal(e.getNext().QueryInterface(Ci.nsICookie2).name, "foo"); + Assert.equal(e.getNext().QueryInterface(Ci.nsICookie).name, "foo"); Assert.ok(!e.hasMoreElements()); e = cm.getCookiesFromHost("", {}); Assert.ok(!e.hasMoreElements()); do_check_throws(function() { cm.getCookiesFromHost(".", {}); }, Cr.NS_ERROR_ILLEGAL_VALUE); do_check_throws(function() { cm.getCookiesFromHost("..", {}); @@ -155,21 +155,21 @@ function run_test() { 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, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Assert.equal(getCookieCount(), 1); do_check_throws(function() { cm.add(".", "/", "foo3", "bar", false, false, true, expiry, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); }, Cr.NS_ERROR_ILLEGAL_VALUE); Assert.equal(getCookieCount(), 1); cm.remove("", "foo2", "/", false, {}); Assert.equal(getCookieCount(), 0); do_check_throws(function() { cm.remove(".", "foo3", "/", false, {}); }, Cr.NS_ERROR_ILLEGAL_VALUE); @@ -203,23 +203,23 @@ function testDomainCookie(uriString, dom var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); cm.removeAll(); var uri = NetUtil.newURI(uriString); cs.setCookieString(uri, null, "foo=bar; domain=" + domain, null); var e = cm.getCookiesFromHost(domain, {}); Assert.ok(e.hasMoreElements()); - Assert.equal(e.getNext().QueryInterface(Ci.nsICookie2).host, domain); + Assert.equal(e.getNext().QueryInterface(Ci.nsICookie).host, domain); cm.removeAll(); cs.setCookieString(uri, null, "foo=bar; domain=." + domain, null); e = cm.getCookiesFromHost(domain, {}); Assert.ok(e.hasMoreElements()); - Assert.equal(e.getNext().QueryInterface(Ci.nsICookie2).host, domain); + Assert.equal(e.getNext().QueryInterface(Ci.nsICookie).host, domain); cm.removeAll(); } function testTrailingDotCookie(uriString, domain) { var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); cm.removeAll();
--- a/netwerk/test/unit/test_bug650522.js +++ b/netwerk/test/unit/test_bug650522.js @@ -3,12 +3,12 @@ function run_test() { var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); var expiry = (Date.now() + 1000) * 1000; // 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, {}, Ci.nsICookie2.SAMESITE_NONE); + cm.add("e.mail.com", "/", "foo", "bar", false, false, true, expiry, {}, Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("e.mail.com"), 1); Assert.equal(cs.getCookieString(NetUtil.newURI("http://e.mail.com"), null), "foo=bar"); }
--- a/netwerk/test/unit/test_bug667087.js +++ b/netwerk/test/unit/test_bug667087.js @@ -3,12 +3,12 @@ function run_test() { var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); var expiry = (Date.now() + 1000) * 1000; // 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, {}, Ci.nsICookie2.SAMESITE_NONE); + cm.add("a", "/", "foo", "bar", false, false, true, expiry, {}, Ci.nsICookie.SAMESITE_NONE); Assert.equal(cm.countCookiesFromHost("a"), 1); Assert.equal(cs.getCookieString(NetUtil.newURI("http://a"), null), "foo=bar"); }
--- a/netwerk/test/unit/test_cookies_async_failure.js +++ b/netwerk/test/unit/test_cookies_async_failure.js @@ -154,17 +154,17 @@ function* run_test_1(generator) // Insert a row. db.insertCookie(cookie); db.close(); // 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, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); // Check that the cookie service accepted the new cookie. Assert.equal(Services.cookiemgr.countCookiesFromHost(cookie.host), 1); let isRebuildingDone = false; let rebuildingObserve = function (subject, topic, data) { isRebuildingDone = true; Services.obs.removeObserver(rebuildingObserve, "cookie-db-rebuilding"); @@ -207,17 +207,17 @@ function* run_test_1(generator) backupdb.close(); // Load the profile, and check that it contains the new cookie. do_load_profile(); Assert.equal(Services.cookiemgr.countCookiesFromHost("foo.com"), 1); let enumerator = Services.cookiemgr.getCookiesFromHost(cookie.host, {}); Assert.ok(enumerator.hasMoreElements()); - let dbcookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let dbcookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.equal(dbcookie.value, "hallo"); Assert.ok(!enumerator.hasMoreElements()); // Close the profile. do_close_profile(sub_generator); yield; // Clean up.
--- a/netwerk/test/unit/test_cookies_profile_close.js +++ b/netwerk/test/unit/test_cookies_profile_close.js @@ -27,17 +27,17 @@ function* do_run_test() { // Start the cookieservice. Services.cookies; // Set a cookie. let uri = NetUtil.newURI("http://foo.com"); Services.cookies.setCookieString(uri, null, "oh=hai; max-age=1000", null); let enumerator = Services.cookiemgr.enumerator; Assert.ok(enumerator.hasMoreElements()); - let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.ok(!enumerator.hasMoreElements()); // Fire 'profile-before-change'. do_close_profile(); // Check that the APIs behave appropriately. Assert.equal(Services.cookies.getCookieString(uri, null), null); Assert.equal(Services.cookies.getCookieStringFromHttp(uri, null, null), null); @@ -50,17 +50,17 @@ function* do_run_test() { }, Cr.NS_ERROR_NOT_AVAILABLE); do_check_throws(function() { Services.cookiemgr.enumerator; }, Cr.NS_ERROR_NOT_AVAILABLE); do_check_throws(function() { Services.cookiemgr.add("foo.com", "", "oh4", "hai", false, false, false, 0, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); }, Cr.NS_ERROR_NOT_AVAILABLE); do_check_throws(function() { Services.cookiemgr.remove("foo.com", "", "oh4", false, {}); }, Cr.NS_ERROR_NOT_AVAILABLE); do_check_throws(function() { let file = profile.clone();
--- a/netwerk/test/unit/test_domain_eviction.js +++ b/netwerk/test/unit/test_domain_eviction.js @@ -63,39 +63,39 @@ function* do_run_test() if (cookie.host == "horse.radish") do_throw("cookies not evicted by lastAccessed order"); } // 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.cookiemgr.add("captchart.com", "", "test100", "eviction", - false, false, false, shortExpiry, {}, Ci.nsICookie2.SAMESITE_NONE); + false, false, false, shortExpiry, {}, Ci.nsICookie.SAMESITE_NONE); do_timeout(2100, continue_test); yield; Assert.equal(countCookies("captchart.com", "captchart.com"), 50); Services.cookiemgr.add("captchart.com", "", "test200", "eviction", - false, false, false, futureExpiry, {}, Ci.nsICookie2.SAMESITE_NONE); + false, false, false, futureExpiry, {}, Ci.nsICookie.SAMESITE_NONE); Assert.equal(countCookies("captchart.com", "captchart.com"), 50); for (let cookie of Services.cookiemgr.getCookiesFromHost("captchart.com", {})) { Assert.ok(cookie.expiry == futureExpiry); } do_finish_generator_test(test_generator); } // set 'aNumber' cookies with host 'aHost', with distinct names. function setCookies(aHost, aNumber, aExpiry) { for (let i = 0; i < aNumber; ++i) Services.cookiemgr.add(aHost, "", "test" + i, "eviction", - false, false, false, aExpiry, {}, Ci.nsICookie2.SAMESITE_NONE); + false, false, false, aExpiry, {}, Ci.nsICookie.SAMESITE_NONE); } // count how many cookies are within domain 'aBaseDomain', using three // independent interface methods on nsICookieManager: // 1) 'enumerator', an enumerator of all cookies; // 2) 'countCookiesFromHost', which returns the number of cookies within the // base domain of 'aHost', // 3) 'getCookiesFromHost', which returns an enumerator of 2).
--- a/netwerk/test/unit/test_eviction.js +++ b/netwerk/test/unit/test_eviction.js @@ -194,17 +194,17 @@ function* do_run_test() function set_cookies(begin, end, expiry) { Assert.ok(begin != end); let beginTime; for (let i = begin; i < end; ++i) { let host = "eviction." + i + ".tests"; Services.cookiemgr.add(host, "", "test", "eviction", false, false, false, - expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + expiry, {}, Ci.nsICookie.SAMESITE_NONE); if (i == begin) beginTime = get_creationTime(i); } let endTime = get_creationTime(end - 1); Assert.ok(begin == end - 1 || endTime > beginTime); if (endTime - beginTime > gPurgeAge * 1000000) { @@ -216,17 +216,17 @@ function set_cookies(begin, end, expiry) return true; } function get_creationTime(i) { let host = "eviction." + i + ".tests"; let enumerator = Services.cookiemgr.getCookiesFromHost(host, {}); Assert.ok(enumerator.hasMoreElements()); - let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie); return cookie.creationTime; } // Test that 'aNumberToExpect' cookies remain after purging is complete, and // that the cookies that remain consist of the set expected given the number of // of older and newer cookies -- eviction should occur by order of lastAccessed // time, if both the limit on total cookies (maxNumber + 10%) and the purge age // + 10% are exceeded.
--- a/netwerk/test/unit/test_schema_2_migration.js +++ b/netwerk/test/unit/test_schema_2_migration.js @@ -97,17 +97,17 @@ function* do_run_test() { // 2) All expired, unique cookies exist. 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.cookiemgr.countCookiesFromHost("baz.com"), 1); let enumerator = Services.cookiemgr.getCookiesFromHost("baz.com", {}); - let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.equal(cookie.expiry, futureExpiry + 44); do_close_profile(test_generator); yield; // Open the database so we can execute some more schema 2 statements on it. schema2db = new CookieDatabaseConnection(do_get_cookie_file(profile), 2);
--- a/netwerk/test/unit/test_schema_3_migration.js +++ b/netwerk/test/unit/test_schema_3_migration.js @@ -97,17 +97,17 @@ function* do_run_test() { // 2) All expired, unique cookies exist. 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.cookiemgr.countCookiesFromHost("baz.com"), 1); let enumerator = Services.cookiemgr.getCookiesFromHost("baz.com", {}); - let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.equal(cookie.expiry, futureExpiry + 44); do_close_profile(test_generator); yield; // Open the database so we can execute some more schema 3 statements on it. schema3db = new CookieDatabaseConnection(do_get_cookie_file(profile), 3); @@ -125,14 +125,14 @@ function* do_run_test() { // Load the database. The cookies added immediately prior will have a NULL // creationTime column. do_load_profile(); // Test the expected set of cookies. Assert.equal(Services.cookiemgr.countCookiesFromHost("cat.com"), 20); enumerator = Services.cookiemgr.getCookiesFromHost("cat.com", {}); - cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); + cookie = enumerator.getNext().QueryInterface(Ci.nsICookie); Assert.equal(cookie.creationTime, 0); finish_test(); }
--- a/netwerk/test/unit/xpcshell.ini +++ b/netwerk/test/unit/xpcshell.ini @@ -123,17 +123,16 @@ requesttimeoutfactor = 2 [test_bug396389.js] [test_bug401564.js] [test_bug411952.js] [test_bug412945.js] [test_bug414122.js] [test_bug427957.js] [test_bug429347.js] [test_bug455311.js] -[test_bug455598.js] [test_bug468426.js] [test_bug468594.js] [test_bug470716.js] [test_bug477578.js] [test_bug479413.js] [test_bug479485.js] [test_bug482601.js] [test_bug482934.js]
--- a/netwerk/test/unit_ipc/test_cookie_header_stripped.js +++ b/netwerk/test/unit_ipc/test_cookie_header_stripped.js @@ -56,15 +56,15 @@ function run_test() { // manually. do_await_remote_message("second-check-cookie-count").then(() => { do_send_remote_message("second-check-cookie-count-done", Services.cookies.countCookiesFromHost(TEST_DOMAIN)); }); // Sets a cookie for the test domain do_await_remote_message("set-cookie").then(() => { const expiry = Date.now() + 24 * 60 * 60; - Services.cookies.add(TEST_DOMAIN, "/", "cookieName", "cookieValue", false, false, false, expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + Services.cookies.add(TEST_DOMAIN, "/", "cookieName", "cookieValue", false, false, false, expiry, {}, Ci.nsICookie.SAMESITE_NONE); do_send_remote_message("set-cookie-done"); }); // Run the actual test logic run_test_in_child("child_cookie_header.js"); }
--- a/security/manager/ssl/tests/unit/test_toolkit_securityreporter.js +++ b/security/manager/ssl/tests/unit/test_toolkit_securityreporter.js @@ -87,17 +87,17 @@ function run_test() { Services.prefs.setCharPref("security.ssl.errorReporting.url", `http://localhost:${port}/submit/sslreports`); // set strict-mode pinning enforcement so we can cause connection failures. Services.prefs.setIntPref("security.cert_pinning.enforcement_level", 2); // Add a cookie so that we can assert it's not sent along with the report. Services.cookies.add("localhost", "/", "foo", "bar", false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); registerCleanupFunction(() => { Services.cookies.removeAll(); }); // start a TLS server add_tls_server_setup("BadCertServer", "bad_certs");
--- a/testing/marionette/cookie.js +++ b/testing/marionette/cookie.js @@ -164,17 +164,17 @@ cookie.add = function(newCookie, {restri newCookie.path, newCookie.name, newCookie.value, newCookie.secure, newCookie.httpOnly, newCookie.session, newCookie.expiry, {} /* origin attributes */, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } catch (e) { throw new UnableToSetCookieError(e); } }; /** * Remove cookie from the cookie store. *
--- a/toolkit/components/cleardata/SiteDataTestUtils.jsm +++ b/toolkit/components/cleardata/SiteDataTestUtils.jsm @@ -78,17 +78,17 @@ var SiteDataTestUtils = { * @param {String} origin - the origin of the site to add test data for * @param {String} name [optional] - the cookie name * @param {String} value [optional] - the cookie value */ addToCookies(origin, name = "foo", value = "bar") { let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin); Services.cookies.add(principal.URI.host, principal.URI.pathQueryRef, name, value, false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); }, /** * Adds a new serviceworker with the specified path. Note that this * method will open a new tab at the domain of the SW path to that effect. * * @param {String} path - the path to the service worker to add. *
--- a/toolkit/components/cleardata/tests/unit/test_cookies.js +++ b/toolkit/components/cleardata/tests/unit/test_cookies.js @@ -6,34 +6,34 @@ */ "use strict"; add_task(async function test_all_cookies() { const expiry = Date.now() + 24 * 60 * 60; Services.cookies.add("example.net", "path", "name", "value", true /* secure */, true /* http only */, false /* session */, - expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + expiry, {}, Ci.nsICookie.SAMESITE_NONE); Assert.equal(Services.cookies.countCookiesFromHost("example.net"), 1); await new Promise(aResolve => { Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_COOKIES, value => { Assert.equal(value, 0); aResolve(); }); }); Assert.equal(Services.cookies.countCookiesFromHost("example.net"), 0); }); add_task(async function test_range_cookies() { const expiry = Date.now() + 24 * 60 * 60; Services.cookies.add("example.net", "path", "name", "value", true /* secure */, true /* http only */, false /* session */, - expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + expiry, {}, Ci.nsICookie.SAMESITE_NONE); Assert.equal(Services.cookies.countCookiesFromHost("example.net"), 1); // The cookie is out of time range here. let from = Date.now() + 60 * 60; await new Promise(aResolve => { Services.clearData.deleteDataInTimeRange(from * 1000, expiry * 2000, true /* user request */, Ci.nsIClearDataService.CLEAR_COOKIES, value => { Assert.equal(value, 0); @@ -55,17 +55,17 @@ add_task(async function test_range_cooki Assert.equal(Services.cookies.countCookiesFromHost("example.net"), 0); }); add_task(async function test_principal_cookies() { const expiry = Date.now() + 24 * 60 * 60; Services.cookies.add("example.net", "path", "name", "value", true /* secure */, true /* http only */, false /* session */, - expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + expiry, {}, Ci.nsICookie.SAMESITE_NONE); Assert.equal(Services.cookies.countCookiesFromHost("example.net"), 1); let uri = Services.io.newURI("http://example.com"); let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {}); await new Promise(aResolve => { Services.clearData.deleteDataFromPrincipal(principal, true /* user request */, Ci.nsIClearDataService.CLEAR_COOKIES, value => { Assert.equal(value, 0);
--- a/toolkit/components/contextualidentity/tests/unit/test_corruptedFile.js +++ b/toolkit/components/contextualidentity/tests/unit/test_corruptedFile.js @@ -26,17 +26,17 @@ function createCookie(userContextId) { COOKIE.path, COOKIE.name, COOKIE.value, COOKIE.isSecure, COOKIE.isHttpOnly, COOKIE.isSession, COOKIE.expiry, {userContextId}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); } function hasCookie(userContextId) { let found = false; for (let cookie of Services.cookies.getCookiesFromHost(BASE_URL, {userContextId})) { if (cookie.originAttributes.userContextId == userContextId) { found = true; break;
--- a/toolkit/components/extensions/MatchPattern.h +++ b/toolkit/components/extensions/MatchPattern.h @@ -15,17 +15,17 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/Likely.h" #include "mozilla/Maybe.h" #include "mozilla/RefCounted.h" #include "nsCOMPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsTArray.h" #include "nsAtom.h" -#include "nsICookie2.h" +#include "nsICookie.h" #include "nsISupports.h" #include "nsIURI.h" #include "nsWrapperCache.h" namespace mozilla { namespace extensions { using dom::MatchPatternOptions; @@ -152,26 +152,26 @@ class URLInfo final { mutable nsCString mCSpec; mutable Maybe<bool> mInheritsPrincipal; }; // Similar to URLInfo, but for cookies. class MOZ_STACK_CLASS CookieInfo final { public: - MOZ_IMPLICIT CookieInfo(nsICookie2* aCookie) : mCookie(aCookie) {} + MOZ_IMPLICIT CookieInfo(nsICookie* aCookie) : mCookie(aCookie) {} bool IsSecure() const; bool IsDomain() const; const nsCString& Host() const; const nsCString& RawHost() const; private: - nsCOMPtr<nsICookie2> mCookie; + nsCOMPtr<nsICookie> mCookie; mutable Maybe<bool> mIsSecure; mutable Maybe<bool> mIsDomain; mutable nsCString mHost; mutable nsCString mRawHost; };
--- a/toolkit/components/extensions/parent/ext-cookies.js +++ b/toolkit/components/extensions/parent/ext-cookies.js @@ -5,19 +5,19 @@ ChromeUtils.defineModuleGetter(this, "Se /* globals DEFAULT_STORE, PRIVATE_STORE */ var { ExtensionError, } = ExtensionUtils; const SAME_SITE_STATUSES = [ - "no_restriction", // Index 0 = Ci.nsICookie2.SAMESITE_NONE - "lax", // Index 1 = Ci.nsICookie2.SAMESITE_LAX - "strict", // Index 2 = Ci.nsICookie2.SAMESITE_STRICT + "no_restriction", // Index 0 = Ci.nsICookie.SAMESITE_NONE + "lax", // Index 1 = Ci.nsICookie.SAMESITE_LAX + "strict", // Index 2 = Ci.nsICookie.SAMESITE_STRICT ]; const isIPv4 = (host) => { let match = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(host); if (match) { return match[1] < 256 && match[2] < 256 && match[3] < 256 && match[4] < 256; } @@ -464,17 +464,17 @@ this.cookies = class extends ExtensionAP }, onChanged: new EventManager({ context, name: "cookies.onChanged", register: fire => { let observer = (subject, topic, data) => { let notify = (removed, cookie, cause) => { - cookie.QueryInterface(Ci.nsICookie2); + cookie.QueryInterface(Ci.nsICookie); if (extension.whiteListedHosts.matchesCookie(cookie)) { fire.async({removed, cookie: convertCookie({cookie, isPrivate: topic == "private-cookie-changed"}), cause}); } }; // We do our best effort here to map the incompatible states. switch (data) { @@ -486,17 +486,17 @@ this.cookies = class extends ExtensionAP break; case "changed": notify(true, subject, "overwrite"); notify(false, subject, "explicit"); break; case "batch-deleted": subject.QueryInterface(Ci.nsIArray); for (let i = 0; i < subject.length; i++) { - let cookie = subject.queryElementAt(i, Ci.nsICookie2); + let cookie = subject.queryElementAt(i, Ci.nsICookie); if (!cookie.isSession && cookie.expiry * 1000 <= Date.now()) { notify(true, cookie, "expired"); } else { notify(true, cookie, "evicted"); } } break; }
--- a/toolkit/components/extensions/test/mochitest/head_cookies.js +++ b/toolkit/components/extensions/test/mochitest/head_cookies.js @@ -93,25 +93,25 @@ async function testCookies(options) { let stepOne = loadChromeScript(() => { const {addMessageListener, sendAsyncMessage} = this; addMessageListener("options", options => { let domain = options.domain.replace(/^\.?/, "."); // This will be evicted after we add a fourth cookie. Services.cookies.add(domain, "/", "evicted", "bar", options.secure, false, false, options.expiry, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); // This will be modified by the background script. Services.cookies.add(domain, "/", "foo", "bar", options.secure, false, false, options.expiry, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); // This will be deleted by the background script. Services.cookies.add(domain, "/", "deleted", "bar", options.secure, false, false, options.expiry, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); sendAsyncMessage("done"); }); }); stepOne.sendAsyncMessage("options", options); await stepOne.promiseOneMessage("done"); stepOne.destroy(); await extension.startup(); @@ -119,19 +119,19 @@ async function testCookies(options) { await extension.awaitMessage("change-cookies"); let stepTwo = loadChromeScript(() => { const {addMessageListener, sendAsyncMessage} = this; addMessageListener("options", options => { let domain = options.domain.replace(/^\.?/, "."); Services.cookies.add(domain, "/", "x", "y", options.secure, false, false, - options.expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + options.expiry, {}, Ci.nsICookie.SAMESITE_NONE); Services.cookies.add(domain, "/", "x", "z", options.secure, false, false, - options.expiry, {}, Ci.nsICookie2.SAMESITE_NONE); + options.expiry, {}, Ci.nsICookie.SAMESITE_NONE); Services.cookies.remove(domain, "x", "/", false, {}); sendAsyncMessage("done"); }); }); stepTwo.sendAsyncMessage("options", options); await stepTwo.promiseOneMessage("done"); stepTwo.destroy();
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html @@ -40,28 +40,28 @@ add_task(async function test_cookies_exp manifest: { "permissions": ["http://example.com/", "cookies"], }, background, }); let chromeScript = loadChromeScript(() => { const {sendAsyncMessage} = this; - Services.cookies.add(".example.com", "/", "first", "one", false, false, false, Date.now() / 1000 + 1, {}, Ci.nsICookie2.SAMESITE_NONE); + Services.cookies.add(".example.com", "/", "first", "one", false, false, false, Date.now() / 1000 + 1, {}, Ci.nsICookie.SAMESITE_NONE); sendAsyncMessage("done"); }); await chromeScript.promiseOneMessage("done"); chromeScript.destroy(); await extension.startup(); await extension.awaitMessage("change-cookies"); chromeScript = loadChromeScript(() => { const {sendAsyncMessage} = this; - Services.cookies.add(".example.com", "/", "first", "one-again", false, false, false, Date.now() / 1000 + 10, {}, Ci.nsICookie2.SAMESITE_NONE); + Services.cookies.add(".example.com", "/", "first", "one-again", false, false, false, Date.now() / 1000 + 10, {}, Ci.nsICookie.SAMESITE_NONE); sendAsyncMessage("done"); }); await chromeScript.promiseOneMessage("done"); chromeScript.destroy(); await extension.awaitFinish("cookie-expiry"); await extension.unload(); });
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_incognito.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_incognito.html @@ -86,20 +86,20 @@ add_task(async function test_cookies_inc await extension.startup(); await extension.awaitMessage("set-cookies"); let chromeScript = SpecialPowers.loadChromeScript(() => { const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); Services.cookies.add("example.org", "/", "public", `foo${Math.random()}`, false, false, false, Number.MAX_SAFE_INTEGER, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); Services.cookies.add("example.org", "/", "private", `foo${Math.random()}`, false, false, false, Number.MAX_SAFE_INTEGER, {privateBrowsingId: 1}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); }); extension.sendMessage("test-cookie-store"); await extension.awaitFinish("cookies"); await extension.unload(); privateExtension.sendMessage("close"); await privateExtension.awaitMessage("done"); await privateExtension.unload();
--- a/toolkit/forgetaboutsite/test/browser/browser_cookieDomain.js +++ b/toolkit/forgetaboutsite/test/browser/browser_cookieDomain.js @@ -17,17 +17,17 @@ add_task(async _ => { // Let's clean up all the data. await new Promise(resolve => { Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve); }); // A cookie domain Services.cookies.add(".example.com", "/test", "foo", "bar", false, false, false, Date.now() + 24000 * 60 * 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); // Cleaning up. await ForgetAboutSite.removeDataFromDomain("example.com"); // All good. ok(!checkCookie("example.com", {}), "No cookies"); // Clean up.
--- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js +++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js @@ -35,17 +35,17 @@ const PREFERENCE_NAME = "test-pref"; /** * Add a cookie to the cookie service. * * @param aDomain */ function add_cookie(aDomain) { check_cookie_exists(aDomain, false); Services.cookies.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false, - COOKIE_EXPIRY, {}, Ci.nsICookie2.SAMESITE_NONE); + COOKIE_EXPIRY, {}, Ci.nsICookie.SAMESITE_NONE); check_cookie_exists(aDomain, true); } /** * Checks to ensure that a cookie exists or not for a domain. * * @param aDomain * The domain to check for the cookie.
--- a/toolkit/mozapps/extensions/test/browser/browser_html_discover_view.js +++ b/toolkit/mozapps/extensions/test/browser/browser_html_discover_view.js @@ -619,17 +619,17 @@ add_task(async function discopane_cache_ is(apiHandler.requestCount, 3, "discovery API should be requested again"); }); add_task(async function discopane_no_cookies() { let requestPromise = new Promise(resolve => { amoServer.registerPathHandler("/discoapi", resolve); }); Services.cookies.add(AMO_TEST_HOST, "/", "name", "value", false, false, - false, Date.now() / 1000 + 600, {}, Ci.nsICookie2.SAMESITE_NONE); + false, Date.now() / 1000 + 600, {}, Ci.nsICookie.SAMESITE_NONE); let win = await loadInitialView("discover"); let request = await requestPromise; ok(!request.hasHeader("Cookie"), "discovery API should not receive cookies"); await closeView(win); }); // Telemetry for interaction that have not been covered by other tests yet. // - "Find more addons" button.
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_langpacks.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_langpacks.js @@ -97,15 +97,15 @@ add_task(async function test_cookies() { lastRequest = request; response.write(JSON.stringify({results: []})); }); const COOKIE = "test"; let expiration = Date.now() / 1000 + 60 * 60; Services.cookies.add("example.com", "/", COOKIE, "testing", false, false, false, expiration, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); await AddonRepository.getAvailableLangpacks(); notEqual(lastRequest, null, "Received langpack request"); equal(lastRequest.hasHeader("Cookie"), false, "Langpack request has no cookies"); });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_cookies.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_cookies.js @@ -49,17 +49,17 @@ add_task(async function test_cookies() { let xpiFetches = []; makeHandler("/update.xpi", xpiFetches, ""); const COOKIE = "test"; // cookies.add() takes a time in seconds let expiration = Date.now() / 1000 + 60 * 60; Services.cookies.add("example.com", "/", COOKIE, "testing", false, false, false, expiration, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); await promiseStartupManager(); let addon = await promiseInstallWebExtension({ manifest: { version: "1.0", applications: { gecko: {
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js @@ -4,17 +4,17 @@ // This verifies bug 462739 function test() { Harness.installEndedCallback = install_ended; Harness.installsCompletedCallback = finish_test; Harness.setup(); Services.cookies.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false, false, true, (Date.now() / 1000) + 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); var pm = Services.perms; pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); var triggers = encodeURIComponent(JSON.stringify({ "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "amosigned.xpi", })); gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js @@ -4,17 +4,17 @@ // This verifies bug 462739 function test() { Harness.installEndedCallback = install_ended; Harness.installsCompletedCallback = finish_test; Harness.setup(); Services.cookies.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false, false, true, (Date.now() / 1000) + 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); var pm = Services.perms; pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); Services.prefs.setIntPref("network.cookie.cookieBehavior", 1); var triggers = encodeURIComponent(JSON.stringify({ "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "amosigned.xpi",
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js @@ -5,17 +5,17 @@ // This verifies bug 462739 function test() { Harness.downloadFailedCallback = download_failed; Harness.installsCompletedCallback = finish_test; Harness.setup(); Services.cookies.add("example.org", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false, false, true, (Date.now() / 1000) + 60, {}, - Ci.nsICookie2.SAMESITE_NONE); + Ci.nsICookie.SAMESITE_NONE); var pm = Services.perms; pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); Services.prefs.setIntPref("network.cookie.cookieBehavior", 1); var triggers = encodeURIComponent(JSON.stringify({ "Cookie check": TESTROOT2 + "cookieRedirect.sjs?" + TESTROOT + "amosigned.xpi",