@@ -44,15 +44,9 @@ import { _castAuth } from './auth_impl';
4444export function connectAuthEmulator (
4545 auth : Auth ,
4646 url : string ,
47- options ? : { disableWarnings : boolean }
47+ options : { disableWarnings : boolean } = { disableWarnings : false }
4848) : void {
4949 const authInternal = _castAuth ( auth ) ;
50- _assert (
51- authInternal . _canInitEmulator ,
52- authInternal ,
53- AuthErrorCode . EMULATOR_CONFIG_FAILED
54- ) ;
55-
5650 _assert (
5751 / ^ h t t p s ? : \/ \/ / . test ( url ) ,
5852 authInternal ,
@@ -66,15 +60,29 @@ export function connectAuthEmulator(
6660 const portStr = port === null ? '' : `:${ port } ` ;
6761
6862 // Always replace path with "/" (even if input url had no path at all, or had a different one).
69- authInternal . config . emulator = { url : `${ protocol } //${ host } ${ portStr } /` } ;
70- authInternal . settings . appVerificationDisabledForTesting = true ;
71- authInternal . emulatorConfig = Object . freeze ( {
63+ const emulator = { url : `${ protocol } //${ host } ${ portStr } /` } ;
64+ const emulatorConfig = Object . freeze ( {
7265 host,
7366 port,
7467 protocol : protocol . replace ( ':' , '' ) ,
7568 options : Object . freeze ( { disableWarnings } )
7669 } ) ;
7770
71+ if ( ! authInternal . _canInitEmulator ) {
72+ _assert (
73+ JSON . stringify ( emulator ) ===
74+ JSON . stringify ( authInternal . config . emulator ) &&
75+ JSON . stringify ( emulatorConfig ) ===
76+ JSON . stringify ( authInternal . emulatorConfig ) ,
77+ authInternal ,
78+ AuthErrorCode . EMULATOR_CONFIG_FAILED
79+ ) ;
80+ }
81+
82+ authInternal . config . emulator = emulator ;
83+ authInternal . emulatorConfig = emulatorConfig ;
84+ authInternal . settings . appVerificationDisabledForTesting = true ;
85+
7886 if ( ! disableWarnings ) {
7987 emitEmulatorWarning ( ) ;
8088 }
0 commit comments