prevent race condition in getStyles before dbExec.initialized
fixes #184
This commit is contained in:
parent
df80a84469
commit
a8796b0bd2
|
@ -23,7 +23,8 @@ var cachedStyles = {
|
|||
urlDomains: new Map(), // getDomain() results for 100 last checked urls
|
||||
needTransitionPatch: new Map(), // FF bug workaround
|
||||
mutex: {
|
||||
inProgress: false, // while getStyles() is reading IndexedDB all subsequent calls
|
||||
inProgress: true, // while getStyles() is reading IndexedDB all subsequent calls
|
||||
// (initially 'true' to prevent rogue getStyles before dbExec.initialized)
|
||||
onDone: [], // to getStyles() are queued and resolved when the first one finishes
|
||||
},
|
||||
};
|
||||
|
@ -92,6 +93,7 @@ dbExec.initialized = false;
|
|||
// (FF may block localStorage depending on its privacy options)
|
||||
do {
|
||||
const done = () => {
|
||||
cachedStyles.mutex.inProgress = false;
|
||||
getStyles().then(() => {
|
||||
dbExec.initialized = true;
|
||||
window.dispatchEvent(new Event('storageReady'));
|
||||
|
|
Loading…
Reference in New Issue
Block a user