Skip to content

Commit

Permalink
Properly sequence database setups between symbol store tests.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mstange committed Sep 19, 2018
1 parent cf15171 commit 5498749
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/profile-logic/symbol-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions src/test/unit/symbol-store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ describe('SymbolStore', function() {
});

afterEach(async function() {
if (symbolStore) {
await symbolStore.closeDb().catch(() => {});
}
await deleteDatabase();
});

Expand Down Expand Up @@ -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) => {}
Expand Down

0 comments on commit 5498749

Please sign in to comment.