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