ensure BG is initialized in onBackgroundReady()
This commit is contained in:
		
							parent
							
								
									f603d9b61f
								
							
						
					
					
						commit
						7443a4cb89
					
				| 
						 | 
				
			
			@ -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);
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user