ensure BG is initialized in onBackgroundReady()
This commit is contained in:
parent
f603d9b61f
commit
7443a4cb89
|
@ -296,17 +296,16 @@ function sessionStorageHash(name) {
|
||||||
|
|
||||||
|
|
||||||
function onBackgroundReady() {
|
function onBackgroundReady() {
|
||||||
return BG ? Promise.resolve() : new Promise(ping);
|
return BG && BG.getStyles ? Promise.resolve() : new Promise(function ping(resolve) {
|
||||||
function ping(resolve) {
|
|
||||||
chrome.runtime.sendMessage({method: 'healthCheck'}, health => {
|
chrome.runtime.sendMessage({method: 'healthCheck'}, health => {
|
||||||
if (health !== undefined) {
|
if (health !== undefined) {
|
||||||
BG = chrome.extension.getBackgroundPage();
|
BG = chrome.extension.getBackgroundPage();
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
ping(resolve);
|
setTimeout(ping, 0, resolve);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user