File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
packages-exp/auth-exp/src/platform_browser Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,26 @@ describe('src/platform_browser/popup_redirect', () => {
247
247
} ) ;
248
248
} ) ;
249
249
250
+ it ( 'errors with invalid event if null event' , async ( ) => {
251
+ const manager = ( await resolver . _initialize ( auth ) ) as AuthEventManager ;
252
+ sinon . stub ( manager , 'onEvent' ) . returns ( true ) ;
253
+
254
+ expect ( ( ) =>
255
+ onIframeMessage ( {
256
+ type : 'authEvent' ,
257
+ authEvent : ( null as unknown ) as AuthEvent
258
+ } )
259
+ ) . to . throw ( FirebaseError , 'auth/invalid-auth-event' ) ;
260
+ } ) ;
261
+
262
+ it ( 'errors with invalid event if everything is null' , async ( ) => {
263
+ const manager = ( await resolver . _initialize ( auth ) ) as AuthEventManager ;
264
+ sinon . stub ( manager , 'onEvent' ) . returns ( true ) ;
265
+ expect ( ( ) =>
266
+ onIframeMessage ( ( null as unknown ) as GapiAuthEvent )
267
+ ) . to . throw ( FirebaseError , 'auth/invalid-auth-event' ) ;
268
+ } ) ;
269
+
250
270
it ( 'returns error to the iframe if the event was not handled' , async ( ) => {
251
271
const manager = ( await resolver . _initialize ( auth ) ) as AuthEventManager ;
252
272
sinon . stub ( manager , 'onEvent' ) . returns ( false ) ;
Original file line number Diff line number Diff line change @@ -111,9 +111,13 @@ class BrowserPopupRedirectResolver implements PopupRedirectResolver {
111
111
const manager = new AuthEventManager ( auth . name ) ;
112
112
iframe . register < GapiAuthEvent > (
113
113
'authEvent' ,
114
- ( { authEvent } : GapiAuthEvent ) => {
114
+ ( iframeEvent : GapiAuthEvent | null ) => {
115
+ assert ( iframeEvent ?. authEvent , AuthErrorCode . INVALID_AUTH_EVENT , {
116
+ appName : auth . name
117
+ } ) ;
115
118
// TODO: Consider splitting redirect and popup events earlier on
116
- const handled = manager . onEvent ( authEvent ) ;
119
+
120
+ const handled = manager . onEvent ( iframeEvent . authEvent ) ;
117
121
return { status : handled ? GapiOutcome . ACK : GapiOutcome . ERROR } ;
118
122
} ,
119
123
gapi . iframes . CROSS_ORIGIN_IFRAMES_FILTER
You can’t perform that action at this time.
0 commit comments