Bug 1182347 - Remove nsIPrincipal::cookieJar. r=sicking
authorBobby Holley <bobbyholley@gmail.com>
Thu, 09 Jul 2015 12:19:20 -0700
changeset 286261 a2995b5458faa88c498e5044183db7ae8102aa4f
parent 286260 ea814efe34e923ea3db566919d78324e729df3df
child 286262 37f196c61129d19afaed43685785d20fa0b74baf
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1182347
milestone42.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
Bug 1182347 - Remove nsIPrincipal::cookieJar. r=sicking
caps/BasePrincipal.cpp
caps/BasePrincipal.h
caps/nsIPrincipal.idl
caps/tests/unit/test_origin.js
dom/base/ChromeUtils.cpp
dom/base/ChromeUtils.h
dom/webidl/ChromeUtils.webidl
toolkit/devtools/server/tests/unit/test_originAttributesToCookieJar.js
toolkit/devtools/server/tests/unit/xpcshell.ini
--- a/caps/BasePrincipal.cpp
+++ b/caps/BasePrincipal.cpp
@@ -140,22 +140,16 @@ OriginAttributes::PopulateFromOrigin(con
     aOriginNoSuffix = origin;
     return true;
   }
 
   aOriginNoSuffix = Substring(origin, 0, pos);
   return PopulateFromSuffix(Substring(origin, pos));
 }
 
-void
-OriginAttributes::CookieJar(nsACString& aStr)
-{
-  mozilla::GetJarPrefix(mAppId, mInBrowser, aStr);
-}
-
 BasePrincipal::BasePrincipal()
 {}
 
 BasePrincipal::~BasePrincipal()
 {}
 
 NS_IMETHODIMP
 BasePrincipal::GetOrigin(nsACString& aOrigin)
@@ -254,17 +248,17 @@ BasePrincipal::GetIsNullPrincipal(bool* 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 BasePrincipal::GetJarPrefix(nsACString& aJarPrefix)
 {
   MOZ_ASSERT(AppId() != nsIScriptSecurityManager::UNKNOWN_APP_ID);
 
-  mOriginAttributes.CookieJar(aJarPrefix);
+  mozilla::GetJarPrefix(mOriginAttributes.mAppId, mOriginAttributes.mInBrowser, aJarPrefix);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 BasePrincipal::GetOriginAttributes(JSContext* aCx, JS::MutableHandle<JS::Value> aVal)
 {
   if (NS_WARN_IF(!ToJSValue(aCx, mOriginAttributes, aVal))) {
     return NS_ERROR_FAILURE;
@@ -275,23 +269,16 @@ BasePrincipal::GetOriginAttributes(JSCon
 NS_IMETHODIMP
 BasePrincipal::GetOriginSuffix(nsACString& aOriginAttributes)
 {
   mOriginAttributes.CreateSuffix(aOriginAttributes);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-BasePrincipal::GetCookieJar(nsACString& aCookieJar)
-{
-  mOriginAttributes.CookieJar(aCookieJar);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 BasePrincipal::GetAppStatus(uint16_t* aAppStatus)
 {
   if (AppId() == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
     NS_WARNING("Asking for app status on a principal with an unknown app id");
     *aAppStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
     return NS_OK;
   }
 
--- a/caps/BasePrincipal.h
+++ b/caps/BasePrincipal.h
@@ -43,18 +43,16 @@ public:
   }
 
   // Serializes/Deserializes non-default values into the suffix format, i.e.
   // |!key1=value1&key2=value2|. If there are no non-default attributes, this
   // returns an empty string.
   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,
                           nsACString& aOriginNoSuffix);
 };
 
 class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary
 {
@@ -112,17 +110,16 @@ public:
   NS_IMETHOD SubsumesConsideringDomain(nsIPrincipal* other, bool* _retval) final;
   NS_IMETHOD GetCsp(nsIContentSecurityPolicy** aCsp) override;
   NS_IMETHOD SetCsp(nsIContentSecurityPolicy* aCsp) override;
   NS_IMETHOD GetCspJSON(nsAString& outCSPinJSON) override;
   NS_IMETHOD GetIsNullPrincipal(bool* aIsNullPrincipal) override;
   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;
   NS_IMETHOD GetUnknownAppId(bool* aUnknownAppId) final;
 
   virtual bool IsOnCSSUnprefixingWhitelist() override { return false; }
 
   virtual bool IsCodebasePrincipal() const { return false; };
--- a/caps/nsIPrincipal.idl
+++ b/caps/nsIPrincipal.idl
@@ -15,17 +15,17 @@ struct JSPrincipals;
 
 interface nsIURI;
 interface nsIContentSecurityPolicy;
 
 [ptr] native JSContext(JSContext);
 [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
 {
     /**
      * Returns whether the other principal is equivalent to this principal.
      * Principals are considered equal if they are the same principal, or
      * they have the same origin.
      */
     boolean equals(in nsIPrincipal other);
@@ -200,40 +200,16 @@ interface nsIPrincipal : nsISerializable
      * special requirements must inspect and compare .originSuffix manually.
      *
      * originsuffix are intended to be a replacement for jarPrefix, which will
      * eventually be removed.
      */
     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
      * non-hierarchical schemes correctly.
      */
     readonly attribute ACString baseDomain;
 
     const short APP_STATUS_NOT_INSTALLED = 0;
     const short APP_STATUS_INSTALLED     = 1;
--- a/caps/tests/unit/test_origin.js
+++ b/caps/tests/unit/test_origin.js
@@ -15,19 +15,16 @@ function checkThrows(f) {
 
 function checkCrossOrigin(a, b) {
   do_check_false(a.equals(b));
   do_check_false(a.equalsConsideringDomain(b));
   do_check_false(a.subsumes(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) {
   attrs = attrs || {};
   do_check_eq(prin.originAttributes.appId, attrs.appId || 0);
   do_check_eq(prin.originAttributes.inBrowser, attrs.inBrowser || false);
   do_check_eq(prin.originSuffix, suffix || '');
   if (!prin.isNullPrincipal && !prin.origin.startsWith('[')) {
--- a/dom/base/ChromeUtils.cpp
+++ b/dom/base/ChromeUtils.cpp
@@ -6,25 +6,16 @@
 #include "ChromeUtils.h"
 
 #include "mozilla/BasePrincipal.h"
 
 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,
                                       nsCString& aSuffix)
 
 {
   OriginAttributes attrs(aAttrs);
   attrs.CreateSuffix(aSuffix);
 }
--- a/dom/base/ChromeUtils.h
+++ b/dom/base/ChromeUtils.h
@@ -36,21 +36,16 @@ public:
                                                                    const nsAString& filePath,
                                                                    ErrorResult& rv);
 };
 
 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,
                            nsCString& aSuffix);
 
   static bool
   OriginAttributesMatchPattern(dom::GlobalObject& aGlobal,
                                const dom::OriginAttributesDictionary& aAttrs,
                                const dom::OriginAttributesPatternDictionary& aPattern);
--- a/dom/webidl/ChromeUtils.webidl
+++ b/dom/webidl/ChromeUtils.webidl
@@ -6,25 +6,16 @@
 
 /**
  * A collection of static utility methods that are only exposed to Chrome. This
  * interface is not exposed in workers, while ThreadSafeChromeUtils is.
  */
 [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.
    *
    * @param originAttrs       The originAttributes from the caller.
    */
   static ByteString
   originAttributesToSuffix(optional OriginAttributesDictionary originAttrs);
 
   /**
deleted file mode 100644
--- 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, "");
-}
--- a/toolkit/devtools/server/tests/unit/xpcshell.ini
+++ b/toolkit/devtools/server/tests/unit/xpcshell.ini
@@ -78,17 +78,16 @@ support-files =
 [test_frameclient-02.js]
 [test_nativewrappers.js]
 [test_nodelistactor.js]
 [test_eval-01.js]
 [test_eval-02.js]
 [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]
 [test_promises_actor_onnewpromise.js]
 [test_promises_actor_onpromisesettled.js]
 [test_promises_client_getdependentpromises.js]
 [test_promises_object_creationtimestamp.js]
 [test_promises_object_timetosettle-01.js]