@@ -959,6 +959,66 @@ function testHandleEmailLinkSignInCallback_expiredActionCodeError() {
959959}
960960
961961
962+ function testHandleEmailLinkSignInCallback_oldLinkClicked ( ) {
963+ // Test when old email link is clicked, code expired error should be
964+ // displayed. In this case, the email is stored with new session ID which is
965+ // different from the session ID in the old link.
966+ var expectedError = { 'code' : 'auth/expired-action-code' } ;
967+ var email = passwordAccount . getEmail ( ) ;
968+ var link = generateSignInLink ( 'OLD_SESSIONID' , null , null , true ) ;
969+ setupEmailLinkSignIn ( 'NEW_SESSIONID' , email ) ;
970+
971+ firebaseui . auth . widget . handler . handleEmailLinkSignInCallback (
972+ app , container , link ) ;
973+ assertBlankPage ( ) ;
974+
975+ // Simulate expired error code.
976+ var waitForCheckActionCode = testAuth . assertCheckActionCode (
977+ [ 'ACTION_CODE' ] ,
978+ null ,
979+ expectedError ) ;
980+ return waitForCheckActionCode . then ( function ( ) {
981+ delayForBusyIndicatorAndAssertIndicatorShown ( ) ;
982+ return testAuth . process ( ) ;
983+ } ) . then ( function ( ) {
984+ assertBusyIndicatorHidden ( ) ;
985+ // Provider sign-in page should be rendered with error in info bar.
986+ assertProviderSignInPage ( ) ;
987+ assertInfoBarMessage (
988+ firebaseui . auth . widget . handler . common . getErrorMessage ( expectedError ) ) ;
989+ } ) ;
990+ }
991+
992+
993+ function testHandleEmailLinkSignInCallback_sessionMismatch ( ) {
994+ var email = passwordAccount . getEmail ( ) ;
995+ var link = generateSignInLink ( 'NEW_SESSIONID' , null , null , true ) ;
996+ setupEmailLinkSignIn ( 'OLD_SESSIONID' , email ) ;
997+
998+ firebaseui . auth . widget . handler . handleEmailLinkSignInCallback (
999+ app , container , link ) ;
1000+ assertBlankPage ( ) ;
1001+
1002+ var waitForCheckActionCode = testAuth . assertCheckActionCode (
1003+ [ 'ACTION_CODE' ] ,
1004+ function ( ) {
1005+ return {
1006+ 'operation' : 'EMAIL_SIGNIN'
1007+ } ;
1008+ } ) ;
1009+ return waitForCheckActionCode . then ( function ( ) {
1010+ delayForBusyIndicatorAndAssertIndicatorShown ( ) ;
1011+ return testAuth . process ( ) ;
1012+ } ) . then ( function ( ) {
1013+ assertBusyIndicatorHidden ( ) ;
1014+ assertDifferentDeviceErrorPage ( ) ;
1015+ // Clicking dismiss button should redirect to the first page.
1016+ clickSecondaryLink ( ) ;
1017+ assertProviderSignInPage ( ) ;
1018+ } ) ;
1019+ }
1020+
1021+
9621022function testHandleEmailLinkSignInCallback_signInError ( ) {
9631023 var email = passwordAccount . getEmail ( ) ;
9641024 var link = generateSignInLink ( 'SESSIONID' ) ;
0 commit comments