ensure BG is initialized in onBackgroundReady()

This commit is contained in:
tophf 2017-06-18 15:20:11 +03:00
parent f603d9b61f
commit 7443a4cb89

View File

@ -296,17 +296,16 @@ function sessionStorageHash(name) {
function onBackgroundReady() {
return BG ? Promise.resolve() : new Promise(ping);
function ping(resolve) {
return BG && BG.getStyles ? Promise.resolve() : new Promise(function ping(resolve) {
chrome.runtime.sendMessage({method: 'healthCheck'}, health => {
if (health !== undefined) {
BG = chrome.extension.getBackgroundPage();
resolve();
} else {
ping(resolve);
setTimeout(ping, 0, resolve);
}
});
}
});
}