Skip to content

Commit

Permalink
[Auth] Fix Firefox Indexed DB workaround issue for v9. Update test to…
Browse files Browse the repository at this point in the history
… workaround same issue in v8 (#5062)

* Fix indexed DB persistence bug in Firefox (v9 only

* Formatting

* Update packages-exp/auth-exp/test/integration/webdriver/util/test_runner.ts

Co-authored-by: Yuchen Shi <[email protected]>

* Update packages-exp/auth-exp/test/integration/webdriver/util/test_runner.ts

Co-authored-by: Yuchen Shi <[email protected]>

Co-authored-by: Yuchen Shi <[email protected]>
  • Loading branch information
sam-gc and yuchenshi authored Jun 23, 2021
1 parent a5c2974 commit d9dc89f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
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

0 comments on commit d9dc89f

Please sign in to comment.