Bug 1407720 - Merge nsICookieManager and nsICookieManager2 r=nwgh

MozReview-Commit-ID: HuzeeB43YZZ

--HG--
extra : rebase_source : 3924170ce50126dbbae7c97cae601b69d0ab95af
This commit is contained in:
Valentin Gosu 2017-10-31 13:02:28 +01:00
Родитель 3991654c37
Коммит 1bd153659e
33 изменённых файлов: 203 добавлений и 225 удалений

Просмотреть файл

@ -334,7 +334,7 @@ function viewCertHelper(parent, cert) {
*/
function hostHasCookies(uri) {
var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
return cookieManager.countCookiesFromHost(uri.asciiHost) > 0;
}

Просмотреть файл

@ -156,7 +156,7 @@ var pktApi = (function() {
*/
function getCookiesFromPocket() {
var cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
var pocketCookies = cookieManager.getCookiesFromHost(pocketSiteHost, {});
var cookies = {};
while (pocketCookies.hasMoreElements()) {

Просмотреть файл

@ -9,7 +9,7 @@
* If we want these commands to run on remote devices/connections, they need to
* run on the server (runAt=server). Unfortunately, cookie commands not only
* need to run on the server, they also need to access to the parent process to
* retrieve and manipulate cookies via nsICookieManager2.
* retrieve and manipulate cookies via nsICookieManager.
* However, server-running commands have no way of accessing the parent process
* for now.
*
@ -25,7 +25,7 @@ const l10n = require("gcli/l10n");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "cookieMgr", function () {
return Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
return Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
});
/**

Просмотреть файл

@ -9,7 +9,7 @@
#include "mozIThirdPartyUtil.h"
#include "nsICookie2.h"
#include "nsIServiceManager.h"
#include "nsICookieManager2.h"
#include "nsICookieManager.h"
#include "nsNetUtil.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProtocolHandler.h"
@ -213,7 +213,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
// If it's third party, check whether cookies are already set
if (isThirdParty) {
nsresult rv;
nsCOMPtr<nsICookieManager2> cookieManager = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv);
nsCOMPtr<nsICookieManager> cookieManager = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
*aResult = false;
break;

Просмотреть файл

@ -1,7 +1,7 @@
let { classes: Cc, utils: Cu, interfaces: Ci } = Components;
let cs = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager2);
.getService(Ci.nsICookieManager);
addMessageListener("getCookieCountAndClear", () => {
let count = 0;

Просмотреть файл

@ -78,7 +78,7 @@ function getCookieCount(cs) {
addMessageListener("init", ({ domain }) => {
let cs = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager2);
.getService(Ci.nsICookieManager);
info("we are going to remove these cookies");
@ -106,7 +106,7 @@ addMessageListener("shutdown", () => {
gObs.remove();
let cs = Cc["@mozilla.org/cookiemanager;1"]
.getService(Ci.nsICookieManager2);
.getService(Ci.nsICookieManager);
cs.removeAll();
sendAsyncMessage("shutdown:return");
});

Просмотреть файл

@ -15,7 +15,7 @@ XPCOMUtils.defineLazyServiceGetter(Services, "cookies",
"nsICookieService");
XPCOMUtils.defineLazyServiceGetter(Services, "cookiemgr",
"@mozilla.org/cookiemanager;1",
"nsICookieManager2");
"nsICookieManager");
XPCOMUtils.defineLazyServiceGetter(Services, "etld",
"@mozilla.org/network/effective-tld-service;1",

Просмотреть файл

@ -3,7 +3,7 @@
function run_test() {
var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
var expiry = (Date.now() + 1000) * 1000;
cm.removeAll();
@ -184,7 +184,7 @@ function run_test() {
function getCookieCount() {
var count = 0;
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
var enumerator = cm.enumerator;
while (enumerator.hasMoreElements()) {
if (!(enumerator.getNext() instanceof Ci.nsICookie2))
@ -196,7 +196,7 @@ function getCookieCount() {
function testDomainCookie(uriString, domain) {
var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
cm.removeAll();
@ -216,7 +216,7 @@ function testDomainCookie(uriString, domain) {
function testTrailingDotCookie(uriString, domain) {
var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
cm.removeAll();

Просмотреть файл

@ -5,7 +5,7 @@ Components.utils.import("resource://gre/modules/NetUtil.jsm");
function run_test() {
var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
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

Просмотреть файл

@ -5,7 +5,7 @@ Components.utils.import("resource://gre/modules/NetUtil.jsm");
function run_test() {
var cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
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

Просмотреть файл

@ -96,7 +96,7 @@ setCookies(aHost, aNumber, aExpiry)
}
// count how many cookies are within domain 'aBaseDomain', using three
// independent interface methods on nsICookieManager2:
// 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',

Просмотреть файл

@ -902,7 +902,7 @@
* netwerk/cookie classes
*/
// service implementing nsICookieManager and nsICookieManager2.
// service implementing nsICookieManager
#define NS_COOKIEMANAGER_CONTRACTID \
"@mozilla.org/cookiemanager;1"
#define NS_COOKIEMANAGER_CID \

Просмотреть файл

@ -20,7 +20,7 @@ namespace net {
* Provides IPDL methods for setting and getting cookies. These are stored on
* and managed by the parent; the child process goes through the parent for
* all cookie operations. Lower-level programmatic operations (i.e. those
* provided by the nsICookieManager and nsICookieManager2 interfaces) are not
* provided by the nsICookieManager interface) are not
* currently implemented and requesting these interfaces in the child will fail.
*
* @see nsICookieService

Просмотреть файл

@ -12,7 +12,6 @@ XPIDL_SOURCES += [
'nsICookie.idl',
'nsICookie2.idl',
'nsICookieManager.idl',
'nsICookieManager2.idl',
'nsICookiePermission.idl',
'nsICookieService.idl',
]

Просмотреть файл

@ -499,7 +499,7 @@ public:
MOZ_ASSERT(XRE_IsParentProcess());
nsCOMPtr<nsICookieManager2> cookieManager
nsCOMPtr<nsICookieManager> cookieManager
= do_GetService(NS_COOKIEMANAGER_CONTRACTID);
MOZ_ASSERT(cookieManager);
@ -593,7 +593,6 @@ nsCookieService::AppClearDataObserverInit()
NS_IMPL_ISUPPORTS(nsCookieService,
nsICookieService,
nsICookieManager,
nsICookieManager2,
nsIObserver,
nsISupportsWeakReference,
nsIMemoryReporter)
@ -2546,7 +2545,7 @@ nsCookieService::Add(const nsACString &aHost,
aOriginAttributes,
aCx,
aArgc,
u"nsICookieManager2.add()",
u"nsICookieManager.add()",
u"2");
NS_ENSURE_SUCCESS(rv, rv);
@ -4532,7 +4531,7 @@ nsCookieService::PurgeCookies(int64_t aCurrentTimeInUsec)
}
// find whether a given cookie has been previously set. this is provided by the
// nsICookieManager2 interface.
// nsICookieManager interface.
NS_IMETHODIMP
nsCookieService::CookieExists(nsICookie2* aCookie,
JS::HandleValue aOriginAttributes,
@ -4550,7 +4549,7 @@ nsCookieService::CookieExists(nsICookie2* aCookie,
aOriginAttributes,
aCx,
aArgc,
u"nsICookieManager2.cookieExists()",
u"nsICookieManager.cookieExists()",
u"2");
NS_ENSURE_SUCCESS(rv, rv);
@ -4704,7 +4703,7 @@ nsCookieService::TelemetryForEvictingStaleCookie(nsCookie *aEvicted,
}
// count the number of cookies stored by a particular host. this is provided by the
// nsICookieManager2 interface.
// nsICookieManager interface.
NS_IMETHODIMP
nsCookieService::CountCookiesFromHost(const nsACString &aHost,
uint32_t *aCountFromHost)
@ -4734,7 +4733,7 @@ nsCookieService::CountCookiesFromHost(const nsACString &aHost,
}
// get an enumerator of cookies stored by a particular host. this is provided by the
// nsICookieManager2 interface.
// nsICookieManager interface.
NS_IMETHODIMP
nsCookieService::GetCookiesFromHost(const nsACString &aHost,
JS::HandleValue aOriginAttributes,
@ -4765,7 +4764,7 @@ nsCookieService::GetCookiesFromHost(const nsACString &aHost,
aOriginAttributes,
aCx,
aArgc,
u"nsICookieManager2.getCookiesFromHost()",
u"nsICookieManager.getCookiesFromHost()",
u"2");
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -8,7 +8,6 @@
#include "nsICookieService.h"
#include "nsICookieManager.h"
#include "nsICookieManager2.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
@ -235,7 +234,7 @@ struct nsCookieAttributes
};
class nsCookieService final : public nsICookieService
, public nsICookieManager2
, public nsICookieManager
, public nsIObserver
, public nsSupportsWeakReference
, public nsIMemoryReporter
@ -248,7 +247,6 @@ class nsCookieService final : public nsICookieService
NS_DECL_NSIOBSERVER
NS_DECL_NSICOOKIESERVICE
NS_DECL_NSICOOKIEMANAGER
NS_DECL_NSICOOKIEMANAGER2
NS_DECL_NSIMEMORYREPORTER
nsCookieService();

Просмотреть файл

@ -14,6 +14,8 @@ class OriginAttributes;
[ptr] native OriginAttributesPtr(mozilla::OriginAttributes);
interface nsISimpleEnumerator;
interface nsICookie2;
interface nsIFile;
[scriptable, function, uuid(20709db8-8dad-4e45-b33e-6e7c761dfc5d)]
interface nsIPrivateModeCallback : nsISupports
@ -40,7 +42,7 @@ interface nsICookieManager : nsISupports
* The objects enumerated over are of type nsICookie
* This enumerator should only be used for non-private browsing cookies.
* To retrieve an enumerator for private browsing cookies, use
* getCookiesWithOriginAttributes from nsICookieManager2.
* getCookiesWithOriginAttributes.
*/
readonly attribute nsISimpleEnumerator enumerator;
@ -58,7 +60,7 @@ interface nsICookieManager : nsISupports
* directly from the desired nsICookie object.
*
* @param aHost The host or domain for which the cookie was set. @see
* nsICookieManager2::add for a description of acceptable host
* nsICookieManager::add for a description of acceptable host
* strings. If the target cookie is a domain cookie, a leading
* dot must be present.
* @param aName The name specified in the cookie
@ -83,4 +85,157 @@ interface nsICookieManager : nsISupports
in AUTF8String aPath,
in boolean aBlocked,
in OriginAttributesPtr aOriginAttributes);
/**
* Add a cookie. nsICookieService is the normal way to do this. This
* method is something of a backdoor.
*
* @param aHost
* the host or domain for which the cookie is set. presence of a
* leading dot indicates a domain cookie; otherwise, the cookie
* is treated as a non-domain cookie (see RFC2109). The host string
* will be normalized to ASCII or ACE; any trailing dot will be
* stripped. To be a domain cookie, the host must have at least two
* subdomain parts (e.g. '.foo.com', not '.com'), otherwise an
* exception will be thrown. An empty string is acceptable
* (e.g. file:// URI's).
* @param aPath
* path within the domain for which the cookie is valid
* @param aName
* cookie name
* @param aValue
* cookie data
* @param aIsSecure
* true if the cookie should only be sent over a secure connection.
* @param aIsHttpOnly
* true if the cookie should only be sent to, and can only be
* modified by, an http connection.
* @param aIsSession
* true if the cookie should exist for the current session only.
* see aExpiry.
* @param aExpiry
* expiration date, in seconds since midnight (00:00:00), January 1,
* 1970 UTC. note that expiry time will also be honored for session cookies;
* in this way, the more restrictive of the two will take effect.
* @param aOriginAttributes
* the originAttributes of this cookie. This attribute is optional to
* avoid breaking add-ons.
* @param aSameSite
* the SameSite attribute. This attribute is optional to avoid breaking
* addons
*/
[implicit_jscontext, optional_argc]
void add(in AUTF8String aHost,
in AUTF8String aPath,
in ACString aName,
in ACString aValue,
in boolean aIsSecure,
in boolean aIsHttpOnly,
in boolean aIsSession,
in int64_t aExpiry,
[optional] in jsval aOriginAttributes,
[optional] in int32_t aSameSite);
[notxpcom]
nsresult addNative(in AUTF8String aHost,
in AUTF8String aPath,
in ACString aName,
in ACString aValue,
in boolean aIsSecure,
in boolean aIsHttpOnly,
in boolean aIsSession,
in int64_t aExpiry,
in OriginAttributesPtr aOriginAttributes,
in int32_t aSameSite);
/**
* Find whether a given cookie already exists.
*
* @param aCookie
* the cookie to look for
* @param aOriginAttributes
* nsICookie2 contains an originAttributes but if nsICookie2 is
* implemented in JS, we can't retrieve its originAttributes because
* the getter is marked [implicit_jscontext]. This optional parameter
* is a workaround.
*
* @return true if a cookie was found which matches the host, path, and name
* fields of aCookie
*/
[implicit_jscontext, optional_argc]
boolean cookieExists(in nsICookie2 aCookie,
[optional] in jsval aOriginAttributes);
[notxpcom]
nsresult cookieExistsNative(in nsICookie2 aCookie,
in OriginAttributesPtr aOriginAttributes,
out boolean aExists);
/**
* Count how many cookies exist within the base domain of 'aHost'.
* Thus, for a host "weather.yahoo.com", the base domain would be "yahoo.com",
* and any host or domain cookies for "yahoo.com" and its subdomains would be
* counted.
*
* @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.
*
* @return the number of cookies found.
*/
unsigned long countCookiesFromHost(in AUTF8String aHost);
/**
* Returns an enumerator of cookies that exist within the base domain of
* 'aHost'. Thus, for a host "weather.yahoo.com", the base domain would be
* "yahoo.com", and any host or domain cookies for "yahoo.com" and its
* subdomains would be returned.
*
* @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. This attribute is optional to avoid
* breaking add-ons.
*
* @return an nsISimpleEnumerator of nsICookie2 objects.
*
* @see countCookiesFromHost
*/
[implicit_jscontext, optional_argc]
nsISimpleEnumerator getCookiesFromHost(in AUTF8String aHost,
[optional] in jsval aOriginAttributes);
/**
* Import an old-style cookie file. Imported cookies will be added to the
* existing database. If the database contains any cookies the same as those
* being imported (i.e. domain, name, and path match), they will be replaced.
*
* @param aCookieFile the file to import, usually cookies.txt
*/
void importCookies(in nsIFile aCookieFile);
/**
* Returns an enumerator of all cookies whose origin attributes matches aPattern
*
* @param aPattern origin attribute pattern in JSON format
*
* @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. This attribute is optional. It will search
* all hosts if this attribute is not given.
*/
nsISimpleEnumerator getCookiesWithOriginAttributes(in DOMString aPattern,
[optional] in AUTF8String aHost);
/**
* Remove all the cookies whose origin attributes matches aPattern
*
* @param aPattern origin attribute pattern in JSON format
*/
void removeCookiesWithOriginAttributes(in DOMString aPattern,
[optional] in AUTF8String aHost);
};

Просмотреть файл

@ -1,170 +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 "nsICookieManager.idl"
interface nsICookie2;
interface nsIFile;
/**
* Additions to the frozen nsICookieManager
*/
[scriptable, uuid(daf0caa7-b431-4b4d-ba51-08c179bb9dfe)]
interface nsICookieManager2 : nsICookieManager
{
/**
* Add a cookie. nsICookieService is the normal way to do this. This
* method is something of a backdoor.
*
* @param aHost
* the host or domain for which the cookie is set. presence of a
* leading dot indicates a domain cookie; otherwise, the cookie
* is treated as a non-domain cookie (see RFC2109). The host string
* will be normalized to ASCII or ACE; any trailing dot will be
* stripped. To be a domain cookie, the host must have at least two
* subdomain parts (e.g. '.foo.com', not '.com'), otherwise an
* exception will be thrown. An empty string is acceptable
* (e.g. file:// URI's).
* @param aPath
* path within the domain for which the cookie is valid
* @param aName
* cookie name
* @param aValue
* cookie data
* @param aIsSecure
* true if the cookie should only be sent over a secure connection.
* @param aIsHttpOnly
* true if the cookie should only be sent to, and can only be
* modified by, an http connection.
* @param aIsSession
* true if the cookie should exist for the current session only.
* see aExpiry.
* @param aExpiry
* expiration date, in seconds since midnight (00:00:00), January 1,
* 1970 UTC. note that expiry time will also be honored for session cookies;
* in this way, the more restrictive of the two will take effect.
* @param aOriginAttributes
* the originAttributes of this cookie. This attribute is optional to
* avoid breaking add-ons.
* @param aSameSite
* the SameSite attribute. This attribute is optional to avoid breaking
* addons
*/
[implicit_jscontext, optional_argc]
void add(in AUTF8String aHost,
in AUTF8String aPath,
in ACString aName,
in ACString aValue,
in boolean aIsSecure,
in boolean aIsHttpOnly,
in boolean aIsSession,
in int64_t aExpiry,
[optional] in jsval aOriginAttributes,
[optional] in int32_t aSameSite);
[notxpcom]
nsresult addNative(in AUTF8String aHost,
in AUTF8String aPath,
in ACString aName,
in ACString aValue,
in boolean aIsSecure,
in boolean aIsHttpOnly,
in boolean aIsSession,
in int64_t aExpiry,
in OriginAttributesPtr aOriginAttributes,
in int32_t aSameSite);
/**
* Find whether a given cookie already exists.
*
* @param aCookie
* the cookie to look for
* @param aOriginAttributes
* nsICookie2 contains an originAttributes but if nsICookie2 is
* implemented in JS, we can't retrieve its originAttributes because
* the getter is marked [implicit_jscontext]. This optional parameter
* is a workaround.
*
* @return true if a cookie was found which matches the host, path, and name
* fields of aCookie
*/
[implicit_jscontext, optional_argc]
boolean cookieExists(in nsICookie2 aCookie,
[optional] in jsval aOriginAttributes);
[notxpcom]
nsresult cookieExistsNative(in nsICookie2 aCookie,
in OriginAttributesPtr aOriginAttributes,
out boolean aExists);
/**
* Count how many cookies exist within the base domain of 'aHost'.
* Thus, for a host "weather.yahoo.com", the base domain would be "yahoo.com",
* and any host or domain cookies for "yahoo.com" and its subdomains would be
* counted.
*
* @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.
*
* @return the number of cookies found.
*/
unsigned long countCookiesFromHost(in AUTF8String aHost);
/**
* Returns an enumerator of cookies that exist within the base domain of
* 'aHost'. Thus, for a host "weather.yahoo.com", the base domain would be
* "yahoo.com", and any host or domain cookies for "yahoo.com" and its
* subdomains would be returned.
*
* @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. This attribute is optional to avoid
* breaking add-ons.
*
* @return an nsISimpleEnumerator of nsICookie2 objects.
*
* @see countCookiesFromHost
*/
[implicit_jscontext, optional_argc]
nsISimpleEnumerator getCookiesFromHost(in AUTF8String aHost,
[optional] in jsval aOriginAttributes);
/**
* Import an old-style cookie file. Imported cookies will be added to the
* existing database. If the database contains any cookies the same as those
* being imported (i.e. domain, name, and path match), they will be replaced.
*
* @param aCookieFile the file to import, usually cookies.txt
*/
void importCookies(in nsIFile aCookieFile);
/**
* Returns an enumerator of all cookies whose origin attributes matches aPattern
*
* @param aPattern origin attribute pattern in JSON format
*
* @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. This attribute is optional. It will search
* all hosts if this attribute is not given.
*/
nsISimpleEnumerator getCookiesWithOriginAttributes(in DOMString aPattern,
[optional] in AUTF8String aHost);
/**
* Remove all the cookies whose origin attributes matches aPattern
*
* @param aPattern origin attribute pattern in JSON format
*/
void removeCookiesWithOriginAttributes(in DOMString aPattern,
[optional] in AUTF8String aHost);
};

Просмотреть файл

@ -10,7 +10,7 @@ const COOKIE_NAMES = ["cookie0", "cookie1", "cookie2"];
const TEST_URL =
"http://example.com/browser/netwerk/cookie/test/browser/file_empty.html";
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
// opens `uri' in a new tab with the provided userContextId and focuses it.
// returns the newly opened tab

Просмотреть файл

@ -1,6 +1,6 @@
/*
* Bug 1267910 - Add test cases for the backward compatiability and originAttributes
* of nsICookieManager2.
* of nsICookieManager.
*/
var {utils: Cu, interfaces: Ci, classes: Cc} = Components;

Просмотреть файл

@ -6,7 +6,7 @@ const BASE_HOSTNAMES = ["example.org", "example.co.uk"];
const SUBDOMAINS = ["", "pub.", "www.", "other."];
const cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
const cm = cs.QueryInterface(Ci.nsICookieManager2);
const cm = cs.QueryInterface(Ci.nsICookieManager);
function run_test() {
var tests = [];

Просмотреть файл

@ -8,7 +8,6 @@
#include "nsIServiceManager.h"
#include "nsICookieService.h"
#include "nsICookieManager.h"
#include "nsICookieManager2.h"
#include "nsICookie2.h"
#include <stdio.h>
#include "plstr.h"
@ -610,11 +609,11 @@ TEST(TestCookie,TestCookieMain)
GetACookieNoHttp(cookieService, "http://www.security.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_CONTAIN, "test=non-security2"));
// *** nsICookieManager{2} interface tests
// *** nsICookieManager interface tests
nsCOMPtr<nsICookieManager> cookieMgr = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv0);
ASSERT_TRUE(NS_SUCCEEDED(rv0));
nsCOMPtr<nsICookieManager2> cookieMgr2 = do_QueryInterface(cookieMgr);
nsCOMPtr<nsICookieManager> cookieMgr2 = cookieMgr;
ASSERT_TRUE(cookieMgr2);
mozilla::OriginAttributes attrs;

Просмотреть файл

@ -1,7 +1,7 @@
function run_test() {
try {
var cm = Cc["@mozilla.org/cookiemanager;1"].
getService(Ci.nsICookieManager2);
getService(Ci.nsICookieManager);
do_check_neq(cm, null, "Retrieving the cookie manager failed");
const time = (new Date("Jan 1, 2030")).getTime() / 1000;

Просмотреть файл

@ -28,7 +28,7 @@ function run_test() {
}
};
var cm = Components.classes["@mozilla.org/cookiemanager;1"].
getService(Components.interfaces.nsICookieManager2);
getService(Components.interfaces.nsICookieManager);
do_check_false(cm.cookieExists(cookie));
// if the above line does not crash, the test was successful
do_test_finished();

Просмотреть файл

@ -52,7 +52,7 @@ add_test(function testAsyncCancel() {
startChannelRequest(baseUrl, CL_EXPECT_FAILURE, (request, data, context) => {
do_check_true(!!!data, "no response");
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
do_check_eq(cm.countCookiesFromHost("localhost"), 0, "no cookies set");
do_execute_soon(run_next_test);

Просмотреть файл

@ -71,7 +71,7 @@ this.ForgetAboutSite = {
// Need to maximize the number of cookies cleaned here
promises.push((async function() {
let cm = Cc["@mozilla.org/cookiemanager;1"].
getService(Ci.nsICookieManager2);
getService(Ci.nsICookieManager);
let enumerator = cm.getCookiesWithOriginAttributes(JSON.stringify({}), aDomain);
while (enumerator.hasMoreElements()) {
let cookie = enumerator.getNext().QueryInterface(Ci.nsICookie);

Просмотреть файл

@ -74,7 +74,7 @@ function promiseIsURIVisited(aURI) {
*/
function add_cookie(aDomain) {
check_cookie_exists(aDomain, false);
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
cm.add(aDomain, COOKIE_PATH, COOKIE_NAME, "", false, false, false,
COOKIE_EXPIRY, {});
check_cookie_exists(aDomain, true);
@ -89,7 +89,7 @@ function add_cookie(aDomain) {
* True if the cookie should exist, false otherwise.
*/
function check_cookie_exists(aDomain, aExists) {
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
let cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
let cookie = {
host: aDomain,
name: COOKIE_NAME,

Просмотреть файл

@ -77,7 +77,7 @@ var initTable = {
cache2: ["@mozilla.org/netwerk/cache-storage-service;1", "nsICacheStorageService"],
cpmm: ["@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender"],
console: ["@mozilla.org/consoleservice;1", "nsIConsoleService"],
cookies: ["@mozilla.org/cookiemanager;1", "nsICookieManager2"],
cookies: ["@mozilla.org/cookiemanager;1", "nsICookieManager"],
downloads: ["@mozilla.org/download-manager;1", "nsIDownloadManager"],
droppedLinkHandler: ["@mozilla.org/content/dropped-link-handler;1", "nsIDroppedLinkHandler"],
els: ["@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"],

Просмотреть файл

@ -33,7 +33,7 @@ function run_test() {
checkService("cache2", Ci.nsICacheStorageService);
checkService("clipboard", Ci.nsIClipboard);
checkService("console", Ci.nsIConsoleService);
checkService("cookies", Ci.nsICookieManager2);
checkService("cookies", Ci.nsICookieManager);
checkService("dirsvc", Ci.nsIDirectoryService);
checkService("dirsvc", Ci.nsIProperties);
checkService("DOMRequest", Ci.nsIDOMRequestService);

Просмотреть файл

@ -8,7 +8,7 @@ function test() {
Harness.setup();
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
false, true, (Date.now() / 1000) + 60, {});
@ -30,7 +30,7 @@ function finish_test(count) {
is(count, 1, "1 Add-on should have been successfully installed");
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false, {});
Services.perms.remove(makeURI("http://example.com"), "install");

Просмотреть файл

@ -8,7 +8,7 @@ function test() {
Harness.setup();
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
false, true, (Date.now() / 1000) + 60, {});
@ -32,7 +32,7 @@ function finish_test(count) {
is(count, 1, "1 Add-on should have been successfully installed");
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false, {});
Services.prefs.clearUserPref("network.cookie.cookieBehavior");

Просмотреть файл

@ -9,7 +9,7 @@ function test() {
Harness.setup();
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
cm.add("example.org", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
false, true, (Date.now() / 1000) + 60, {});
@ -32,7 +32,7 @@ function download_failed(install) {
function finish_test(count) {
is(count, 0, "No add-ons should have been installed");
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
.getService(Components.interfaces.nsICookieManager);
cm.remove("example.org", "xpinstall", "/browser/" + RELATIVE_DIR, false, {});
Services.prefs.clearUserPref("network.cookie.cookieBehavior");

Просмотреть файл

@ -33,8 +33,6 @@ var servicesASTParser = {
"nsIIOService": "io",
"nsIIOService2": "io",
"nsISpeculativeConnect": "io",
// Bug 1407720 - Services lists nsICookieManager2, but that inherits directly
// from nsICookieManager, so we have to list it separately.
"nsICookieManager": "cookies"
},