Skip to content

Commit 90419ce

Browse files
committed
Formatting
1 parent 825ee57 commit 90419ce

File tree

6 files changed

+59
-28
lines changed

6 files changed

+59
-28
lines changed

packages-exp/auth-exp/src/model/popup_redirect.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export interface PopupRedirectResolver extends externs.PopupRedirectResolver {
8787
authType: AuthEventType,
8888
eventId?: string
8989
): Promise<never>;
90-
_isIframeWebStorageSupported(auth: AuthCore, cb: (support: boolean) => unknown): void;
90+
_isIframeWebStorageSupported(
91+
auth: AuthCore,
92+
cb: (support: boolean) => unknown
93+
): void;
9194
_redirectPersistence: externs.Persistence;
9295
}

packages-exp/auth-exp/src/platform_browser/popup_redirect.test.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('src/platform_browser/popup_redirect', () => {
7070
_message: string,
7171
cb: (event: GapiAuthEvent) => Promise<void>
7272
) => (onIframeMessage = cb),
73-
send: iframeSendStub,
73+
send: iframeSendStub
7474
})
7575
} as unknown) as gapi.iframes.Context)
7676
);
@@ -273,9 +273,15 @@ describe('src/platform_browser/popup_redirect', () => {
273273
});
274274

275275
function setIframeResponse(value: unknown): void {
276-
iframeSendStub.callsFake((_message: string, _event: unknown, callback: (response: unknown) => void) => {
277-
callback(value);
278-
});
276+
iframeSendStub.callsFake(
277+
(
278+
_message: string,
279+
_event: unknown,
280+
callback: (response: unknown) => void
281+
) => {
282+
callback(value);
283+
}
284+
);
279285
}
280286

281287
it('calls the iframe send method with the correct parameters', () => {
@@ -284,21 +290,21 @@ describe('src/platform_browser/popup_redirect', () => {
284290
const args = iframeSendStub.getCalls()[0].args;
285291
expect(args[0]).to.eq('webStorageSupport');
286292
expect(args[1]).to.eql({
287-
type: 'webStorageSupport',
293+
type: 'webStorageSupport'
288294
});
289295
expect(args[3]).to.eq(gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
290296
});
291297

292298
it('passes through true value from the response to the callback', done => {
293-
setIframeResponse([{webStorageSupport: true}]);
299+
setIframeResponse([{ webStorageSupport: true }]);
294300
resolver._isIframeWebStorageSupported(auth, supported => {
295301
expect(supported).to.be.true;
296302
done();
297303
});
298304
});
299305

300306
it('passes through false value from the response to callback', done => {
301-
setIframeResponse([{webStorageSupport: false}]);
307+
setIframeResponse([{ webStorageSupport: false }]);
302308
resolver._isIframeWebStorageSupported(auth, supported => {
303309
expect(supported).to.be.false;
304310
done();
@@ -307,7 +313,9 @@ describe('src/platform_browser/popup_redirect', () => {
307313

308314
it('throws an error if the response is malformed', () => {
309315
setIframeResponse({});
310-
expect(() => resolver._isIframeWebStorageSupported(auth, () => {})).to.throw(FirebaseError, 'auth/internal-error');
316+
expect(() =>
317+
resolver._isIframeWebStorageSupported(auth, () => {})
318+
).to.throw(FirebaseError, 'auth/internal-error');
311319
});
312320
});
313321
});

packages-exp/auth-exp/src/platform_browser/popup_redirect.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,26 @@ class BrowserPopupRedirectResolver implements PopupRedirectResolver {
135135
return manager;
136136
}
137137

138-
_isIframeWebStorageSupported(auth: Auth, cb: (supported: boolean) => unknown): void {
138+
_isIframeWebStorageSupported(
139+
auth: Auth,
140+
cb: (supported: boolean) => unknown
141+
): void {
139142
const iframe = this.iframes[auth._key()];
140-
iframe.send<gapi.iframes.Message, WebStorageSupportMessage>(WEB_STORAGE_SUPPORT_KEY, {type: WEB_STORAGE_SUPPORT_KEY}, result => {
141-
const isSupported = result?.[0]?.[WEB_STORAGE_SUPPORT_KEY];
142-
if (isSupported !== undefined) {
143-
cb(!!isSupported);
144-
}
145-
146-
fail(AuthErrorCode.INTERNAL_ERROR, {
147-
appName: auth.name
148-
});
149-
}, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
143+
iframe.send<gapi.iframes.Message, WebStorageSupportMessage>(
144+
WEB_STORAGE_SUPPORT_KEY,
145+
{ type: WEB_STORAGE_SUPPORT_KEY },
146+
result => {
147+
const isSupported = result?.[0]?.[WEB_STORAGE_SUPPORT_KEY];
148+
if (isSupported !== undefined) {
149+
cb(!!isSupported);
150+
}
151+
152+
fail(AuthErrorCode.INTERNAL_ERROR, {
153+
appName: auth.name
154+
});
155+
},
156+
gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER
157+
);
150158
}
151159

152160
private originValidation(auth: Auth): Promise<void> {

packages-exp/auth-exp/src/platform_browser/strategies/popup.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ describe('src/core/strategies/popup', () => {
200200

201201
it('errors if webstorage support comes back negative', async () => {
202202
resolver = makeMockPopupRedirectResolver(eventManager, authPopup, false);
203-
await expect(signInWithPopup(auth, provider, resolver)).to.be.rejectedWith(FirebaseError, 'auth/web-storage-unsupported');
203+
await expect(
204+
signInWithPopup(auth, provider, resolver)
205+
).to.be.rejectedWith(FirebaseError, 'auth/web-storage-unsupported');
204206
});
205207

206208
it('passes any errors from idp task', async () => {
@@ -354,7 +356,10 @@ describe('src/core/strategies/popup', () => {
354356

355357
it('errors if webstorage support comes back negative', async () => {
356358
resolver = makeMockPopupRedirectResolver(eventManager, authPopup, false);
357-
await expect(linkWithPopup(user, provider, resolver)).to.be.rejectedWith(FirebaseError, 'auth/web-storage-unsupported');
359+
await expect(linkWithPopup(user, provider, resolver)).to.be.rejectedWith(
360+
FirebaseError,
361+
'auth/web-storage-unsupported'
362+
);
358363
});
359364

360365
it('passes any errors from idp task', async () => {
@@ -486,7 +491,9 @@ describe('src/core/strategies/popup', () => {
486491

487492
it('errors if webstorage support comes back negative', async () => {
488493
resolver = makeMockPopupRedirectResolver(eventManager, authPopup, false);
489-
await expect(reauthenticateWithPopup(user, provider, resolver)).to.be.rejectedWith(FirebaseError, 'auth/web-storage-unsupported');
494+
await expect(
495+
reauthenticateWithPopup(user, provider, resolver)
496+
).to.be.rejectedWith(FirebaseError, 'auth/web-storage-unsupported');
490497
});
491498

492499
it('does error if the poll timeout and event timeout trip', async () => {

packages-exp/auth-exp/src/platform_browser/strategies/popup.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ class PopupOperation extends AbstractPopupRedirectOperation {
155155
// the popup closed by user poll will reject into the void.
156156
this.resolver._isIframeWebStorageSupported(this.auth, isSupported => {
157157
if (!isSupported) {
158-
this.reject(AUTH_ERROR_FACTORY.create(AuthErrorCode.WEB_STORAGE_UNSUPPORTED, {
159-
appName: this.auth.name
160-
}));
158+
this.reject(
159+
AUTH_ERROR_FACTORY.create(AuthErrorCode.WEB_STORAGE_UNSUPPORTED, {
160+
appName: this.auth.name
161+
})
162+
);
161163
}
162164
});
163165

packages-exp/auth-exp/test/helpers/mock_popup_redirect_resolver.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { EventManager } from '../../src/model/popup_redirect';
2828
export function makeMockPopupRedirectResolver(
2929
eventManager?: EventManager,
3030
authPopup?: AuthPopup,
31-
webStorageSupported = true,
31+
webStorageSupported = true
3232
): PopupRedirectResolver {
3333
return class implements PopupRedirectResolver {
3434
async _initialize(): Promise<EventManager> {
@@ -41,7 +41,10 @@ export function makeMockPopupRedirectResolver(
4141

4242
async _openRedirect(): Promise<void> {}
4343

44-
_isIframeWebStorageSupported(_auth: unknown, cb: (result: boolean)=>void ): void {
44+
_isIframeWebStorageSupported(
45+
_auth: unknown,
46+
cb: (result: boolean) => void
47+
): void {
4548
cb(webStorageSupported);
4649
}
4750

0 commit comments

Comments
 (0)