Backed out changeset 78ef803f4f11 (bug 1170097)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 08 Jun 2015 09:35:24 +0200
changeset 278415 e9285dba7ba6d9603cb6ce40af40e81eebe76303
parent 278414 debeff91668f48aec5ef441a3c43beb6776b3421
child 278416 89af4c72fce54f395fe425c6497cc66708eb215a
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1170097
milestone41.0a1
backs out78ef803f4f11e58365f16bbf88198fecf1b82fb0
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
Backed out changeset 78ef803f4f11 (bug 1170097)
caps/BasePrincipal.cpp
caps/BasePrincipal.h
dom/webidl/ChromeUtils.webidl
toolkit/devtools/server/ChromeUtils.cpp
toolkit/devtools/server/ChromeUtils.h
toolkit/devtools/server/tests/unit/test_originAttributesToCookieJar.js
toolkit/devtools/server/tests/unit/xpcshell.ini
--- a/caps/BasePrincipal.cpp
+++ b/caps/BasePrincipal.cpp
@@ -33,22 +33,16 @@ OriginAttributes::CreateSuffix(nsACStrin
   }
 
   if (mInBrowser) {
     aStr.Append(attrCount++ ? "&inBrowser=1" : "!inBrowser=1");
   }
 }
 
 void
-OriginAttributes::CookieJar(nsACString& aStr)
-{
-  mozilla::GetJarPrefix(mAppId, mInBrowser, aStr);
-}
-
-void
 OriginAttributes::Serialize(nsIObjectOutputStream* aStream) const
 {
   aStream->Write32(mAppId);
   aStream->WriteBoolean(mInBrowser);
 }
 
 nsresult
 OriginAttributes::Deserialize(nsIObjectInputStream* aStream)
@@ -165,17 +159,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(AppId(), IsInBrowserElement(), 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;
@@ -188,18 +182,20 @@ BasePrincipal::GetOriginSuffix(nsACStrin
 {
   mOriginAttributes.CreateSuffix(aOriginAttributes);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 BasePrincipal::GetCookieJar(nsACString& aCookieJar)
 {
-  mOriginAttributes.CookieJar(aCookieJar);
-  return NS_OK;
+  // We just forward to .jarPrefix for now, which is a nice compact
+  // stringification of the (appId, inBrowser) tuple. This will eventaully be
+  // swapped out for an origin attribute - see the comment in nsIPrincipal.idl.
+  return GetJarPrefix(aCookieJar);
 }
 
 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;
--- a/caps/BasePrincipal.h
+++ b/caps/BasePrincipal.h
@@ -22,36 +22,32 @@ class OriginAttributes : public dom::Ori
 {
 public:
   OriginAttributes() {}
   OriginAttributes(uint32_t aAppId, bool aInBrowser)
   {
     mAppId = aAppId;
     mInBrowser = aInBrowser;
   }
-  OriginAttributes(const OriginAttributesDictionary& aOther)
-    : OriginAttributesDictionary(aOther) {}
 
   bool operator==(const OriginAttributes& aOther) const
   {
     return mAppId == aOther.mAppId &&
            mInBrowser == aOther.mInBrowser;
   }
   bool operator!=(const OriginAttributes& aOther) const
   {
     return !(*this == aOther);
   }
 
   // Serializes 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;
 
-  void CookieJar(nsACString& aStr);
-
   void Serialize(nsIObjectOutputStream* aStream) const;
   nsresult Deserialize(nsIObjectInputStream* aStream);
 };
 
 /*
  * Base class from which all nsIPrincipal implementations inherit. Use this for
  * default implementations and other commonalities between principal
  * implementations.
--- a/dom/webidl/ChromeUtils.webidl
+++ b/dom/webidl/ChromeUtils.webidl
@@ -23,25 +23,16 @@ interface ChromeUtils {
 
   /**
    * Deserialize a core dump into a HeapSnapshot.
    *
    * @param filePath          The file path to read the core dump from.
    */
   [Throws, NewObject]
   static HeapSnapshot readHeapSnapshot(DOMString filePath);
-
-  /**
-   * A helper that converts OriginAttributesDictionary to cookie jar opaque
-   * identfier.
-   *
-   * @param originAttrs       The originAttributes from the caller.
-   */
-  static ByteString
-  originAttributesToCookieJar(optional OriginAttributesDictionary originAttrs);
 };
 
 /**
  * A JS object whose properties specify what portion of the heap graph to
  * write. The recognized properties are:
  *
  * * globals: [ global, ... ]
  *   Dump only nodes that either:
--- a/toolkit/devtools/server/ChromeUtils.cpp
+++ b/toolkit/devtools/server/ChromeUtils.cpp
@@ -6,17 +6,16 @@
 #include "ChromeUtils.h"
 
 #include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/io/gzip_stream.h>
 
 #include "mozilla/devtools/HeapSnapshot.h"
 #include "mozilla/devtools/ZeroCopyNSIOutputStream.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/BasePrincipal.h"
 #include "mozilla/UniquePtr.h"
 
 #include "nsCRTGlue.h"
 #include "nsIOutputStream.h"
 #include "nsNetUtil.h"
 #include "prerror.h"
 #include "prio.h"
 #include "prtypes.h"
@@ -424,19 +423,10 @@ ChromeUtils::ReadHeapSnapshot(GlobalObje
       return nullptr;
     }
     bytesRead += bytesReadThisTime;
   }
 
   return HeapSnapshot::Create(cx, global, buffer.get(), size, rv);
 }
 
-/* static */ void
-ChromeUtils::OriginAttributesToCookieJar(GlobalObject& aGlobal,
-                                         const OriginAttributesDictionary& aAttrs,
-                                         nsCString& aCookieJar)
-{
-  OriginAttributes attrs(aAttrs);
-  attrs.CookieJar(aCookieJar);
-}
-
 } // namespace devtools
 } // namespace mozilla
--- a/toolkit/devtools/server/ChromeUtils.h
+++ b/toolkit/devtools/server/ChromeUtils.h
@@ -68,19 +68,14 @@ public:
                                const nsAString& filePath,
                                const dom::HeapSnapshotBoundaries& boundaries,
                                ErrorResult& rv);
 
   static already_AddRefed<HeapSnapshot> ReadHeapSnapshot(dom::GlobalObject& global,
                                                          JSContext* cx,
                                                          const nsAString& filePath,
                                                          ErrorResult& rv);
-
-  static void
-  OriginAttributesToCookieJar(dom::GlobalObject& aGlobal,
-                              const dom::OriginAttributesDictionary& aAttrs,
-                              nsCString& aCookieJar);
 };
 
 } // namespace devtools
 } // namespace mozilla
 
 #endif // mozilla_devtools_ChromeUtils__
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
@@ -80,17 +80,16 @@ support-files =
 [test_eval-03.js]
 [test_eval-04.js]
 [test_eval-05.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_originAttributesToCookieJar.js]
 [test_protocol_abort.js]
 [test_protocol_async.js]
 [test_protocol_children.js]
 [test_protocol_formtype.js]
 [test_protocol_longstring.js]
 [test_protocol_simple.js]
 [test_protocol_unregister.js]
 [test_breakpoint-01.js]