Skip to content

[Auth] Fix Firefox Indexed DB workaround issue for v9. Update test to workaround same issue in v8 #5062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ export function _openDatabase(): Promise<IDBDatabase> {
// https://github.com/firebase/firebase-js-sdk/issues/634

if (!db.objectStoreNames.contains(DB_OBJECTSTORE_NAME)) {
// Need to close the database or else you get a `blocked` event
db.close();
await _deleteDatabase();
return _openDatabase();
resolve(await _openDatabase());
} else {
resolve(db);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function testPersistedUser() {
};
}

browserDescribe('WebDriver persistence test', driver => {
browserDescribe('WebDriver persistence test', (driver, browser) => {
const fullPersistenceKey = `firebase:authUser:${API_KEY}:[DEFAULT]`;
context('default persistence hierarchy (indexedDB > localStorage)', () => {
it('stores user in indexedDB by default', async () => {
Expand Down Expand Up @@ -381,6 +381,12 @@ browserDescribe('WebDriver persistence test', driver => {
});

it('stays logged in when switching from legacy SDK and then back (no indexedDB support)', async () => {
// Skip this test if running in Firefox. The Legacy SDK incorrectly
// implements the db delete + reopen workaround for Firefox.
if (browser === 'firefox') {
return;
}

await driver.webDriver.navigate().refresh();
// Simulate browsers that do not support indexedDB.
await driver.webDriver.executeScript('delete window.indexedDB');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { AuthDriver } from './auth_driver';
*/

interface TempSuite {
generator: (driver: AuthDriver) => void;
generator: (driver: AuthDriver, browser: string) => void;
title: string;
}

Expand All @@ -45,7 +45,7 @@ const SUITES: TempSuite[] = [];
/** Main entry point for all WebDriver tests */
export function browserDescribe(
title: string,
generator: (driver: AuthDriver) => void
generator: (driver: AuthDriver, browser: string) => void
): void {
SUITES.push({
title,
Expand Down Expand Up @@ -75,7 +75,7 @@ setTimeout(() => {
});

for (const { title, generator } of SUITES) {
describe(title, () => generator(DRIVER));
describe(title, () => generator(DRIVER, browser));
}
});
}
Expand Down