@@ -1799,3 +1799,97 @@ function testHandleCallback_nullUser_emailAuthOnly_acUnavailable() {
17991799 } ) ;
18001800}
18011801
1802+
1803+ function testHandleCallback_operationNotSupported_multiProviders ( ) {
1804+ // Test when callback handler is triggered with multiple providers and
1805+ // the operation is not supported in this environment.
1806+ asyncTestCase . waitForSignals ( 1 ) ;
1807+ // Set mutliple providers.
1808+ app . setConfig ( {
1809+ 'signInOptions' : [
1810+ firebase . auth . EmailAuthProvider . PROVIDER_ID ,
1811+ firebase . auth . GoogleAuthProvider . PROVIDER_ID
1812+ ]
1813+ } ) ;
1814+ // Callback rendered.
1815+ firebaseui . auth . widget . handler . handleCallback ( app , container ) ;
1816+ assertCallbackPage ( ) ;
1817+ // Attempting to get redirect result. Reject with an operation not supported
1818+ // error.
1819+ testAuth . assertGetRedirectResult ( [ ] , null , operationNotSupportedError ) ;
1820+ testAuth . process ( ) . then ( function ( ) {
1821+ // Any pending credential should be cleared from storage.
1822+ assertFalse ( firebaseui . auth . storage . hasPendingEmailCredential (
1823+ app . getAppId ( ) ) ) ;
1824+ // Redirect to the provider's sign-in page.
1825+ assertProviderSignInPage ( ) ;
1826+ // Show error in info bar.
1827+ assertInfoBarMessage (
1828+ firebaseui . auth . widget . handler . common . getErrorMessage (
1829+ operationNotSupportedError ) ) ;
1830+ asyncTestCase . signal ( ) ;
1831+ } ) ;
1832+ }
1833+
1834+
1835+ function testHandleCallback_operationNotSupported_passwordOnly_acDisabled ( ) {
1836+ // Test when callback handler is triggered with only a password provider and
1837+ // the operation is not supported in this environment.
1838+ asyncTestCase . waitForSignals ( 1 ) ;
1839+ // Set password only provider.
1840+ // Test with accountchooser.com disabled.
1841+ app . setConfig ( {
1842+ 'credentialHelper' : firebaseui . auth . CredentialHelper . NONE ,
1843+ 'signInOptions' : [ firebase . auth . EmailAuthProvider . PROVIDER_ID ]
1844+ } ) ;
1845+ // Callback rendered.
1846+ firebaseui . auth . widget . handler . handleCallback ( app , container ) ;
1847+ assertCallbackPage ( ) ;
1848+ // Attempting to get redirect result. Reject with an operation not supported
1849+ // error.
1850+ testAuth . assertGetRedirectResult ( [ ] , null , operationNotSupportedError ) ;
1851+ testAuth . process ( ) . then ( function ( ) {
1852+ // No message should be displayed.
1853+ assertNoInfoBarMessage ( ) ;
1854+ // Redirect to the sign-in page with no error message.
1855+ assertSignInPage ( ) ;
1856+ assertFalse ( firebaseui . auth . storage . hasPendingEmailCredential (
1857+ app . getAppId ( ) ) ) ;
1858+ asyncTestCase . signal ( ) ;
1859+ } ) ;
1860+ }
1861+
1862+
1863+ function testHandleCallback_operationNotSupported_passwordOnly_acEnabled ( ) {
1864+ // Test when callback handler is triggered with only a password provider and
1865+ // the operation is not supported in this environment.
1866+ asyncTestCase . waitForSignals ( 1 ) ;
1867+ // Set password only provider.
1868+ // Test with accountchooser.com enabled.
1869+ app . setConfig ( {
1870+ 'credentialHelper' : firebaseui . auth . CredentialHelper . ACCOUNT_CHOOSER_COM ,
1871+ 'signInOptions' : [ firebase . auth . EmailAuthProvider . PROVIDER_ID ]
1872+ } ) ;
1873+ // Simulate empty response from accountchooser.com click.
1874+ testAc . setSkipSelect ( true ) ;
1875+ // Callback rendered.
1876+ firebaseui . auth . widget . handler . handleCallback ( app , container ) ;
1877+ assertCallbackPage ( ) ;
1878+ // Attempting to get redirect result. Reject with an operation not supported
1879+ // error.
1880+ testAuth . assertGetRedirectResult ( [ ] , null , operationNotSupportedError ) ;
1881+ testAuth . process ( ) . then ( function ( ) {
1882+ // Try select should be called.
1883+ testAc . assertTrySelectAccount (
1884+ firebaseui . auth . storage . getRememberedAccounts ( app . getAppId ( ) ) ,
1885+ 'http://localhost/firebaseui-widget?mode=select' ) ;
1886+ // Redirect to the sign-in page with no error message.
1887+ assertSignInPage ( ) ;
1888+ assertFalse ( firebaseui . auth . storage . hasPendingEmailCredential (
1889+ app . getAppId ( ) ) ) ;
1890+ // No message should be displayed.
1891+ assertNoInfoBarMessage ( ) ;
1892+ asyncTestCase . signal ( ) ;
1893+ } ) ;
1894+ }
1895+
0 commit comments