Back out 1726498035c1 (bug 1258299) for xpcshell failures in test_rtcIdentityProvider.js

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2016-03-23 19:25:39 -07:00
parent 12e6e3f600
commit fd64e52ef9
5 changed files with 28 additions and 39 deletions

View File

@ -231,7 +231,7 @@ IdpSandbox.prototype = {
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;

View File

@ -101,10 +101,6 @@
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));

View File

@ -5,6 +5,7 @@
#include "RTCIdentityProviderRegistrar.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/RTCIdentityProviderBinding.h"
#include "nsCycleCollectionParticipant.h"
namespace mozilla {
@ -19,15 +20,12 @@ 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);
}
@ -50,16 +48,16 @@ RTCIdentityProviderRegistrar::WrapObject(JSContext* aCx, JS::Handle<JSObject*> a
}
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>
@ -67,21 +65,21 @@ 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);
}

View File

@ -14,12 +14,11 @@
#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
@ -34,9 +33,9 @@ public:
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,
@ -49,8 +48,7 @@ private:
~RTCIdentityProviderRegistrar();
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<GenerateAssertionCallback> mGenerateAssertionCallback;
RefPtr<ValidateAssertionCallback> mValidateAssertionCallback;
RefPtr<RTCIdentityProvider> mIdp;
};
} // namespace dom

View File

@ -10,9 +10,9 @@
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
@ -30,16 +30,13 @@ interface RTCIdentityProviderRegistrar {
validateAssertion(DOMString assertion, DOMString origin);
};
dictionary RTCIdentityProvider {
required GenerateAssertionCallback generateAssertion;
required ValidateAssertionCallback validateAssertion;
};
callback GenerateAssertionCallback =
callback interface RTCIdentityProvider {
Promise<RTCIdentityAssertionResult>
(DOMString contents, DOMString origin, optional DOMString usernameHint);
callback ValidateAssertionCallback =
Promise<RTCIdentityValidationResult> (DOMString assertion, DOMString origin);
generateAssertion(DOMString contents, DOMString origin,
optional DOMString usernameHint);
Promise<RTCIdentityValidationResult>
validateAssertion(DOMString assertion, DOMString origin);
};
dictionary RTCIdentityAssertionResult {
required RTCIdentityProviderDetails idp;