Back out 1726498035c1 (bug 1258299) for xpcshell failures in test_rtcIdentityProvider.js
authorPhil Ringnalda <philringnalda@gmail.com>
Wed, 23 Mar 2016 19:25:39 -0700
changeset 290201 c7192c4eecd0657907c4a40ac88db34298b6cc10
parent 290200 ba45f257a090f833f8bc512cbcff74cd382b14f8
child 290202 1406eb7b3a5ddb2caa26bbc73c3dca78080f4483
push id18353
push usercbook@mozilla.com
push dateThu, 24 Mar 2016 15:20:25 +0000
treeherderfx-team@40ae8489939e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1258299
milestone48.0a1
backs out1726498035c1ddfab4a0492f433f6b236c87098f
Back out 1726498035c1 (bug 1258299) for xpcshell failures in test_rtcIdentityProvider.js CLOSED TREE
dom/media/IdpSandbox.jsm
dom/media/tests/mochitest/identity/idp.js
dom/media/webrtc/RTCIdentityProviderRegistrar.cpp
dom/media/webrtc/RTCIdentityProviderRegistrar.h
dom/webidl/RTCIdentityProvider.webidl
--- a/dom/media/IdpSandbox.jsm
+++ b/dom/media/IdpSandbox.jsm
@@ -226,17 +226,17 @@ IdpSandbox.prototype = {
       // as being IdP errors by the IdP and we drop line numbers as a result.
       if (e.name === 'IdpError' || e.name === 'IdpLoginError') {
         throw e;
       }
       this._logError(e);
       throw new Error('Error in IdP, check console for details');
     }
 
-    if (!registrar.hasIdp) {
+    if (!registrar.idp) {
       throw new Error('IdP failed to call rtcIdentityProvider.register()');
     }
     return registrar;
   },
 
   // Capture all the details from the error and log them to the console.  This
   // can't rethrow anything else because that could leak information about the
   // internal workings of the IdP across origins.
--- a/dom/media/tests/mochitest/identity/idp.js
+++ b/dom/media/tests/mochitest/identity/idp.js
@@ -96,15 +96,11 @@
           identity: assertion.username,
           contents: assertion.contents
         });
     }
   };
 
   if (!instructions.some(is('not_ready'))) {
     dump('registering idp.js' + global.location.hash + '\n');
-    var idp = new IDPJS();
-    global.rtcIdentityProvider.register({
-      generateAssertion: idp.generateAssertion.bind(idp),
-      validateAssertion: idp.validateAssertion.bind(idp)
-    });
+    global.rtcIdentityProvider.register(new IDPJS());
   }
 }(this));
--- a/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp
+++ b/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp
@@ -1,38 +1,36 @@
 /* -*- 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 "RTCIdentityProviderRegistrar.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/dom/RTCIdentityProviderBinding.h"
 #include "nsCycleCollectionParticipant.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RTCIdentityProviderRegistrar)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(RTCIdentityProviderRegistrar)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(RTCIdentityProviderRegistrar)
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(RTCIdentityProviderRegistrar,
-                                      mGlobal,
-                                      mGenerateAssertionCallback,
-                                      mValidateAssertionCallback)
+                                      mGlobal, mIdp)
 
 RTCIdentityProviderRegistrar::RTCIdentityProviderRegistrar(
     nsIGlobalObject* aGlobal)
     : mGlobal(aGlobal)
-    , mGenerateAssertionCallback(nullptr)
-    , mValidateAssertionCallback(nullptr)
+    , mIdp(nullptr)
 {
   MOZ_COUNT_CTOR(RTCIdentityProviderRegistrar);
 }
 
 RTCIdentityProviderRegistrar::~RTCIdentityProviderRegistrar()
 {
   MOZ_COUNT_DTOR(RTCIdentityProviderRegistrar);
 }
@@ -45,46 +43,46 @@ RTCIdentityProviderRegistrar::GetParentO
 
 JSObject*
 RTCIdentityProviderRegistrar::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return RTCIdentityProviderRegistrarBinding::Wrap(aCx, this, aGivenProto);
 }
 
 void
-RTCIdentityProviderRegistrar::Register(const RTCIdentityProvider& aIdp)
+RTCIdentityProviderRegistrar::Register(RTCIdentityProvider& aIdp)
 {
-  mGenerateAssertionCallback = aIdp.mGenerateAssertion;
-  mValidateAssertionCallback = aIdp.mValidateAssertion;
+  mIdp = &aIdp;
 }
 
-bool
-RTCIdentityProviderRegistrar::HasIdp() const
+already_AddRefed<RTCIdentityProvider>
+RTCIdentityProviderRegistrar::GetIdp()
 {
-  return mGenerateAssertionCallback && mValidateAssertionCallback;
+  RefPtr<RTCIdentityProvider> idp = mIdp;
+  return idp.forget();
 }
 
 already_AddRefed<Promise>
 RTCIdentityProviderRegistrar::GenerateAssertion(
   const nsAString& aContents, const nsAString& aOrigin,
   const Optional<nsAString>& aUsernameHint, ErrorResult& aRv)
 {
-  if (!mGenerateAssertionCallback) {
+  if (!mIdp) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED);
     return nullptr;
   }
-  return mGenerateAssertionCallback->Call(aContents, aOrigin, aUsernameHint, aRv);
+  return mIdp->GenerateAssertion(aContents, aOrigin, aUsernameHint, aRv);
 }
 already_AddRefed<Promise>
 RTCIdentityProviderRegistrar::ValidateAssertion(
   const nsAString& aAssertion, const nsAString& aOrigin, ErrorResult& aRv)
 {
-  if (!mValidateAssertionCallback) {
+  if (!mIdp) {
     aRv.Throw(NS_ERROR_NOT_INITIALIZED);
     return nullptr;
   }
-  return mValidateAssertionCallback->Call(aAssertion, aOrigin, aRv);
+  return mIdp->ValidateAssertion(aAssertion, aOrigin, aRv);
 }
 
 
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/webrtc/RTCIdentityProviderRegistrar.h
+++ b/dom/media/webrtc/RTCIdentityProviderRegistrar.h
@@ -9,51 +9,49 @@
 #include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"
 #include "nsIGlobalObject.h"
 #include "nsWrapperCache.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/dom/RTCIdentityProviderBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-struct RTCIdentityProvider;
+class RTCIdentityProvider;
 
 class RTCIdentityProviderRegistrar final : public nsISupports,
                                            public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(RTCIdentityProviderRegistrar)
 
   explicit RTCIdentityProviderRegistrar(nsIGlobalObject* aGlobal);
 
   // As required
   nsIGlobalObject* GetParentObject() const;
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
-  // setter and checker
-  void Register(const RTCIdentityProvider& aIdp);
-  bool HasIdp() const;
+  // setter and getter
+  void Register(RTCIdentityProvider& aIdp);
+  already_AddRefed<RTCIdentityProvider> GetIdp();
 
   already_AddRefed<Promise>
   GenerateAssertion(const nsAString& aContents, const nsAString& aOrigin,
                     const Optional<nsAString>& aUsernameHint, ErrorResult& aRv);
   already_AddRefed<Promise>
   ValidateAssertion(const nsAString& assertion, const nsAString& origin,
                     ErrorResult& aRv);
 
 private:
   ~RTCIdentityProviderRegistrar();
 
   nsCOMPtr<nsIGlobalObject> mGlobal;
-  RefPtr<GenerateAssertionCallback> mGenerateAssertionCallback;
-  RefPtr<ValidateAssertionCallback> mValidateAssertionCallback;
+  RefPtr<RTCIdentityProvider> mIdp;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* RTCIDENTITYPROVIDER_H_ */
--- a/dom/webidl/RTCIdentityProvider.webidl
+++ b/dom/webidl/RTCIdentityProvider.webidl
@@ -5,19 +5,19 @@
  *
  * http://w3c.github.io/webrtc-pc/ (with https://github.com/w3c/webrtc-pc/pull/178)
  */
 
 [NoInterfaceObject]
 interface RTCIdentityProviderRegistrar {
   void register(RTCIdentityProvider idp);
 
-  /* If an IdP was passed to register() to chrome code. */
+  /* The IdP that was passed to register() to chrome code, if any. */
   [ChromeOnly]
-  readonly attribute boolean hasIdp;
+  readonly attribute RTCIdentityProvider? idp;
   /* The following two chrome-only functions forward to the corresponding
    * function on the registered IdP.  This is necessary because the
    * JS-implemented WebIDL can't see these functions on `idp` above, chrome JS
    * gets an Xray onto the content code that suppresses functions, see
    * https://developer.mozilla.org/en-US/docs/Xray_vision#Xrays_for_JavaScript_objects
    */
   /* Forward to idp.generateAssertion() */
   [ChromeOnly, Throws]
@@ -25,27 +25,24 @@ interface RTCIdentityProviderRegistrar {
   generateAssertion(DOMString contents, DOMString origin,
                     optional DOMString usernameHint);
   /* Forward to idp.validateAssertion() */
   [ChromeOnly, Throws]
   Promise<RTCIdentityValidationResult>
   validateAssertion(DOMString assertion, DOMString origin);
 };
 
-dictionary RTCIdentityProvider {
-  required GenerateAssertionCallback generateAssertion;
-  required ValidateAssertionCallback validateAssertion;
+callback interface RTCIdentityProvider {
+  Promise<RTCIdentityAssertionResult>
+  generateAssertion(DOMString contents, DOMString origin,
+                    optional DOMString usernameHint);
+  Promise<RTCIdentityValidationResult>
+  validateAssertion(DOMString assertion, DOMString origin);
 };
 
-callback GenerateAssertionCallback =
-  Promise<RTCIdentityAssertionResult>
-    (DOMString contents, DOMString origin, optional DOMString usernameHint);
-callback ValidateAssertionCallback =
-  Promise<RTCIdentityValidationResult> (DOMString assertion, DOMString origin);
-
 dictionary RTCIdentityAssertionResult {
   required RTCIdentityProviderDetails idp;
   required DOMString assertion;
 };
 
 dictionary RTCIdentityProviderDetails {
   required DOMString domain;
   DOMString protocol = "default";