Bug 1182347 - Remove nsIPrincipal::cookieJar. r=sicking

This commit is contained in:
Bobby Holley 2015-07-09 12:19:20 -07:00
parent f775f2a3bb
commit 2671257b2d
9 changed files with 2 additions and 95 deletions

View File

@ -145,12 +145,6 @@ OriginAttributes::PopulateFromOrigin(const nsACString& aOrigin,
return PopulateFromSuffix(Substring(origin, pos));
}
void
OriginAttributes::CookieJar(nsACString& aStr)
{
mozilla::GetJarPrefix(mAppId, mInBrowser, aStr);
}
BasePrincipal::BasePrincipal()
{}
@ -259,7 +253,7 @@ BasePrincipal::GetJarPrefix(nsACString& aJarPrefix)
{
MOZ_ASSERT(AppId() != nsIScriptSecurityManager::UNKNOWN_APP_ID);
mOriginAttributes.CookieJar(aJarPrefix);
mozilla::GetJarPrefix(mOriginAttributes.mAppId, mOriginAttributes.mInBrowser, aJarPrefix);
return NS_OK;
}
@ -279,13 +273,6 @@ BasePrincipal::GetOriginSuffix(nsACString& aOriginAttributes)
return NS_OK;
}
NS_IMETHODIMP
BasePrincipal::GetCookieJar(nsACString& aCookieJar)
{
mOriginAttributes.CookieJar(aCookieJar);
return NS_OK;
}
NS_IMETHODIMP
BasePrincipal::GetAppStatus(uint16_t* aAppStatus)
{

View File

@ -48,8 +48,6 @@ public:
void CreateSuffix(nsACString& aStr) const;
bool PopulateFromSuffix(const nsACString& aStr);
void CookieJar(nsACString& aStr);
// Populates the attributes from a string like
// |uri!key1=value1&key2=value2| and returns the uri without the suffix.
bool PopulateFromOrigin(const nsACString& aOrigin,
@ -117,7 +115,6 @@ public:
NS_IMETHOD GetJarPrefix(nsACString& aJarPrefix) final;
NS_IMETHOD GetOriginAttributes(JSContext* aCx, JS::MutableHandle<JS::Value> aVal) final;
NS_IMETHOD GetOriginSuffix(nsACString& aOriginSuffix) final;
NS_IMETHOD GetCookieJar(nsACString& aCookieJar) final;
NS_IMETHOD GetAppStatus(uint16_t* aAppStatus) final;
NS_IMETHOD GetAppId(uint32_t* aAppStatus) final;
NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement) final;

View File

@ -20,7 +20,7 @@ interface nsIContentSecurityPolicy;
[ptr] native JSPrincipals(JSPrincipals);
[ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);
[scriptable, builtinclass, uuid(49c2faf0-b6de-4640-8d0f-e0217baa8627)]
[scriptable, builtinclass, uuid(7a9aa074-7565-4567-af2f-9e3704c7af9e)]
interface nsIPrincipal : nsISerializable
{
/**
@ -204,30 +204,6 @@ interface nsIPrincipal : nsISerializable
*/
readonly attribute AUTF8String originSuffix;
/**
* Opaque string token representing the "cookie jar" associated with this
* principal. Cookie jars are intended to be a tag associated with persistent
* data (like cookies, localStorage data, etc) such that all data associated
* with a given cookie jar can be quickly located and (for example) deleted.
* Code from many origins may share a given cookie jar, so callers still need
* to consult .origin (or equivalent) to compartmentalize data - the cookie
* jar should _only_ be used as a tag in the manner described above.
*
* If two principals are in different cookie jars, they must be cross-origin.
* As such, the information making up the cookie jar token must be contained
* in the originAttributes (i.e. cookieJar must be a function of / derivable
* from originAttributes). Long term, the intention is for the cookie jar
* identifier to simply be an origin attribute. But we don't have that
* attribute yet, and we also need to concatenate the appId and inBrowser
* attributes until those go away.
*
* This getter is designed to hide these details from consumers so that they
* don't need to be updated when we swap out the implementation. For that
* reason, callers should treat the string as opaque and not rely on the
* current format.
*/
readonly attribute ACString cookieJar;
/**
* The base domain of the codebase URI to which this principal pertains
* (generally the document URI), handling null principals and

View File

@ -20,9 +20,6 @@ function checkCrossOrigin(a, b) {
do_check_false(a.subsumesConsideringDomain(b));
do_check_false(b.subsumes(a));
do_check_false(b.subsumesConsideringDomain(a));
do_check_eq(a.cookieJar === b.cookieJar,
a.originAttributes.appId == b.originAttributes.appId &&
a.originAttributes.inBrowser == b.originAttributes.inBrowser);
}
function checkOriginAttributes(prin, attrs, suffix) {

View File

@ -10,15 +10,6 @@
namespace mozilla {
namespace dom {
/* static */ void
ChromeUtils::OriginAttributesToCookieJar(GlobalObject& aGlobal,
const OriginAttributesDictionary& aAttrs,
nsCString& aCookieJar)
{
OriginAttributes attrs(aAttrs);
attrs.CookieJar(aCookieJar);
}
/* static */ void
ChromeUtils::OriginAttributesToSuffix(dom::GlobalObject& aGlobal,
const dom::OriginAttributesDictionary& aAttrs,

View File

@ -40,11 +40,6 @@ public:
class ChromeUtils : public ThreadSafeChromeUtils
{
public:
static void
OriginAttributesToCookieJar(dom::GlobalObject& aGlobal,
const dom::OriginAttributesDictionary& aAttrs,
nsCString& aCookieJar);
static void
OriginAttributesToSuffix(dom::GlobalObject& aGlobal,
const dom::OriginAttributesDictionary& aAttrs,

View File

@ -10,15 +10,6 @@
*/
[ChromeOnly, Exposed=(Window,System)]
interface ChromeUtils : ThreadSafeChromeUtils {
/**
* A helper that converts OriginAttributesDictionary to cookie jar opaque
* identfier.
*
* @param originAttrs The originAttributes from the caller.
*/
static ByteString
originAttributesToCookieJar(optional OriginAttributesDictionary originAttrs);
/**
* A helper that converts OriginAttributesDictionary to a opaque suffix string.
*

View File

@ -1,26 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Services.jsm");
var ssm = Services.scriptSecurityManager;
function run_test() {
const appId = 12;
var browserAttrs = {appId: appId, inBrowser: true};
// ChromeUtils.originAttributesToCookieJar should return the same value with
// the cookieJar of the principal created from the same origin attribute.
var cookieJar_1 = ChromeUtils.originAttributesToCookieJar(browserAttrs);
var dummy = Services.io.newURI("http://example.com", null, null);
var cookieJar_2 = ssm.createCodebasePrincipal(dummy, browserAttrs).cookieJar;
do_check_eq(cookieJar_1, cookieJar_2);
// App and mozbrowser shouldn't have the same cookieJar identifier.
var appAttrs = {appId: appId, inBrowser: false};
var cookieJar_3 = ChromeUtils.originAttributesToCookieJar(appAttrs);
do_check_neq(cookieJar_1, cookieJar_3);
// If the attribute is null the cookieJar identifier should be empty.
var cookieJar_4 = ChromeUtils.originAttributesToCookieJar();
do_check_eq(cookieJar_4, "");
}

View File

@ -83,7 +83,6 @@ support-files =
[test_eval-03.js]
[test_eval-04.js]
[test_eval-05.js]
[test_originAttributesToCookieJar.js]
[test_promises_actor_attach.js]
[test_promises_actor_exist.js]
[test_promises_actor_list_promises.js]