From 2671257b2db98aaedd338a6d5fca6e4e6f89793f Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 9 Jul 2015 12:19:20 -0700 Subject: [PATCH] Bug 1182347 - Remove nsIPrincipal::cookieJar. r=sicking --- caps/BasePrincipal.cpp | 15 +---------- caps/BasePrincipal.h | 3 --- caps/nsIPrincipal.idl | 26 +------------------ caps/tests/unit/test_origin.js | 3 --- dom/base/ChromeUtils.cpp | 9 ------- dom/base/ChromeUtils.h | 5 ---- dom/webidl/ChromeUtils.webidl | 9 ------- .../unit/test_originAttributesToCookieJar.js | 26 ------------------- .../devtools/server/tests/unit/xpcshell.ini | 1 - 9 files changed, 2 insertions(+), 95 deletions(-) delete mode 100644 toolkit/devtools/server/tests/unit/test_originAttributesToCookieJar.js diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index 3cf84fa2691..f37359bfc10 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -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) { diff --git a/caps/BasePrincipal.h b/caps/BasePrincipal.h index 02ba61dbe71..6dd34fb812c 100644 --- a/caps/BasePrincipal.h +++ b/caps/BasePrincipal.h @@ -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 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; diff --git a/caps/nsIPrincipal.idl b/caps/nsIPrincipal.idl index fdc05856eba..da3fcd28647 100644 --- a/caps/nsIPrincipal.idl +++ b/caps/nsIPrincipal.idl @@ -20,7 +20,7 @@ interface nsIContentSecurityPolicy; [ptr] native JSPrincipals(JSPrincipals); [ptr] native PrincipalArray(nsTArray >); -[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 diff --git a/caps/tests/unit/test_origin.js b/caps/tests/unit/test_origin.js index ef462719e7c..a2858f1c0b0 100644 --- a/caps/tests/unit/test_origin.js +++ b/caps/tests/unit/test_origin.js @@ -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) { diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index 1f8fa1a8eb2..7333264fafa 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -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, diff --git a/dom/base/ChromeUtils.h b/dom/base/ChromeUtils.h index 8410e4fbddf..580bfe6553a 100644 --- a/dom/base/ChromeUtils.h +++ b/dom/base/ChromeUtils.h @@ -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, diff --git a/dom/webidl/ChromeUtils.webidl b/dom/webidl/ChromeUtils.webidl index d4a216545ce..e2de66be012 100644 --- a/dom/webidl/ChromeUtils.webidl +++ b/dom/webidl/ChromeUtils.webidl @@ -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. * diff --git a/toolkit/devtools/server/tests/unit/test_originAttributesToCookieJar.js b/toolkit/devtools/server/tests/unit/test_originAttributesToCookieJar.js deleted file mode 100644 index e4605707590..00000000000 --- a/toolkit/devtools/server/tests/unit/test_originAttributesToCookieJar.js +++ /dev/null @@ -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, ""); -} diff --git a/toolkit/devtools/server/tests/unit/xpcshell.ini b/toolkit/devtools/server/tests/unit/xpcshell.ini index 07690cdf449..b28677cbee3 100644 --- a/toolkit/devtools/server/tests/unit/xpcshell.ini +++ b/toolkit/devtools/server/tests/unit/xpcshell.ini @@ -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]