From 54987495affe28b023ba4563cf757328b67485a8 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 21 Aug 2018 18:24:40 -0400 Subject: [PATCH] Properly sequence database setups between symbol store tests. Without this, it's possible that we'll have two database creations triggered right after one another without sequencing. For example, if you have a subtest that creates a SymbolStore but only looks up invalid symbol tables, then the database is never consulted, and nothing will block on the database creation being completed. --- src/profile-logic/symbol-store.js | 4 ++++ src/test/unit/symbol-store.test.js | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/profile-logic/symbol-store.js b/src/profile-logic/symbol-store.js index 4ca60b04d0..153c06c261 100644 --- a/src/profile-logic/symbol-store.js +++ b/src/profile-logic/symbol-store.js @@ -85,6 +85,10 @@ export class SymbolStore { this._db = new SymbolStoreDB(`${dbNamePrefix}-symbol-tables`); } + async closeDb() { + await this._db.close(); + } + // Store a symbol table in the database. This is only used for symbol tables // and not for partial symbol results. Symbol tables are generated by the // geckoProfiler WebExtension API, so these are symbol tables we get from the diff --git a/src/test/unit/symbol-store.test.js b/src/test/unit/symbol-store.test.js index 01eaf97d4d..d1090a4d1d 100644 --- a/src/test/unit/symbol-store.test.js +++ b/src/test/unit/symbol-store.test.js @@ -40,6 +40,9 @@ describe('SymbolStore', function() { }); afterEach(async function() { + if (symbolStore) { + await symbolStore.closeDb().catch(() => {}); + } await deleteDatabase(); }); @@ -137,12 +140,10 @@ describe('SymbolStore', function() { // Using another symbol store simulates a page reload // Due to https://github.com/dumbmatter/fakeIndexedDB/issues/22 we need to // take care to sequence the DB open requests. - const symbolStore2 = new SymbolStore( - 'perf-html-async-storage', - symbolProvider - ); + await symbolStore.closeDb().catch(() => {}); + symbolStore = new SymbolStore('perf-html-async-storage', symbolProvider); - await symbolStore2.getSymbols( + await symbolStore.getSymbols( [{ lib: lib, addresses: new Set([0x1]) }], (_request, _results) => {}, (_request, _error) => {}