ensure getBackgroundPage is fully loaded

This commit is contained in:
tophf 2017-07-29 08:15:10 +03:00
parent 3ddf812635
commit 860443b909

View File

@ -46,7 +46,12 @@ URLS.supported = new RegExp(
); );
let BG = chrome.extension.getBackgroundPage(); let BG = chrome.extension.getBackgroundPage();
if (BG && !BG.getStyles) {
// own page like editor/manage is being loaded on browser startup
// before the background page has been fully initialized;
// it'll be resolved in onBackgroundReady() instead
BG = null;
}
if (!BG || BG !== window) { if (!BG || BG !== window) {
document.documentElement.classList.toggle('firefox', FIREFOX); document.documentElement.classList.toggle('firefox', FIREFOX);
document.documentElement.classList.toggle('opera', OPERA); document.documentElement.classList.toggle('opera', OPERA);
@ -57,6 +62,7 @@ if (!BG || BG !== window) {
} }
} }
function notifyAllTabs(msg) { function notifyAllTabs(msg) {
const originalMessage = msg; const originalMessage = msg;
if (msg.method === 'styleUpdated' || msg.method === 'styleAdded') { if (msg.method === 'styleUpdated' || msg.method === 'styleAdded') {