@@ -50,6 +50,7 @@ function setUp() {
5050 } ) ;
5151 firebase . auth = {
5252 GoogleAuthProvider : { PROVIDER_ID : 'google.com' } ,
53+ FacebookAuthProvider : { PROVIDER_ID : 'facebook.com' } ,
5354 EmailAuthProvider : {
5455 EMAIL_LINK_SIGN_IN_METHOD : 'emailLink' ,
5556 EMAIL_PASSWORD_SIGN_IN_METHOD : 'password' ,
@@ -107,6 +108,64 @@ function testGetRequiredWidgetUrl() {
107108}
108109
109110
111+ function testFederatedProviderShouldImmediatelyRedirect ( ) {
112+ // Returns true when immediateFederatedRedirect is set, there is
113+ // only one federated provider and the signInFlow is set to redirect.
114+ config . setConfig ( {
115+ 'immediateFederatedRedirect' : true ,
116+ 'signInOptions' : [ firebase . auth . GoogleAuthProvider . PROVIDER_ID ] ,
117+ 'signInFlow' : firebaseui . auth . widget . Config . SignInFlow . REDIRECT
118+ } ) ;
119+ assertTrue ( config . federatedProviderShouldImmediatelyRedirect ( ) ) ;
120+
121+ // Returns false if the immediateFederatedRedirect option is false.
122+ config . setConfig ( {
123+ 'immediateFederatedRedirect' : false ,
124+ 'signInOptions' : [ firebase . auth . GoogleAuthProvider . PROVIDER_ID ] ,
125+ 'signInFlow' : firebaseui . auth . widget . Config . SignInFlow . REDIRECT
126+ } ) ;
127+ assertFalse ( config . federatedProviderShouldImmediatelyRedirect ( ) ) ;
128+
129+ // Returns false if the provider is not a federated provider.
130+ config . setConfig ( {
131+ 'immediateFederatedRedirect' : true ,
132+ 'signInOptions' : [ firebase . auth . EmailAuthProvider . PROVIDER_ID ] ,
133+ 'signInFlow' : firebaseui . auth . widget . Config . SignInFlow . REDIRECT
134+ } ) ;
135+ assertFalse ( config . federatedProviderShouldImmediatelyRedirect ( ) ) ;
136+
137+ // Returns false if there is more than one federated provider.
138+ config . setConfig ( {
139+ 'immediateFederatedRedirect' : true ,
140+ 'signInOptions' : [
141+ firebase . auth . GoogleAuthProvider . PROVIDER_ID ,
142+ firebase . auth . FacebookAuthProvider . PROVIDER_ID
143+ ] ,
144+ 'signInFlow' : firebaseui . auth . widget . Config . SignInFlow . REDIRECT
145+ } ) ;
146+ assertFalse ( config . federatedProviderShouldImmediatelyRedirect ( ) ) ;
147+
148+ // Returns false if there is more than one provider of any kind.
149+ config . setConfig ( {
150+ 'immediateFederatedRedirect' : true ,
151+ 'signInOptions' : [
152+ firebase . auth . GoogleAuthProvider . PROVIDER_ID ,
153+ firebase . auth . EmailAuthProvider . PROVIDER_ID
154+ ] ,
155+ 'signInFlow' : firebaseui . auth . widget . Config . SignInFlow . REDIRECT
156+ } ) ;
157+ assertFalse ( config . federatedProviderShouldImmediatelyRedirect ( ) ) ;
158+
159+ // Returns false if signInFlow is using a popup.
160+ config . setConfig ( {
161+ 'immediateFederatedRedirect' : true ,
162+ 'signInOptions' : [ firebase . auth . GoogleAuthProvider . PROVIDER_ID ] ,
163+ 'signInFlow' : firebaseui . auth . widget . Config . SignInFlow . POPUP
164+ } ) ;
165+ assertFalse ( config . federatedProviderShouldImmediatelyRedirect ( ) ) ;
166+ }
167+
168+
110169function testGetSignInFlow ( ) {
111170 // Confirm default value for sign-in flow
112171 assertEquals (
0 commit comments