diff --git a/src/js/background.js b/src/js/background.js index 31fc9ddf6b75b..578d8a65c8642 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -270,6 +270,10 @@ const µBlock = { // jshint ignore:line uiAccentStylesheet: '', }; +µBlock.isReadyPromise = new Promise(resolve => { + µBlock.isReadyResolve = resolve; +}); + µBlock.domainFromHostname = domainFromHostname; µBlock.hostnameFromURI = hostnameFromURI; diff --git a/src/js/messaging.js b/src/js/messaging.js index eef19693f5bd7..64098c9eb8545 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -1565,7 +1565,9 @@ const onMessage = function(request, sender, callback) { }); case 'getLists': - return getLists(callback); + return µb.isReadyPromise.then(( ) => { + getLists(callback); + }); case 'getLocalData': return getLocalData().then(localData => { diff --git a/src/js/start.js b/src/js/start.js index 5b4f0c2494305..bc38f2b926cf2 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -63,13 +63,6 @@ import { /******************************************************************************/ -// Load all: executed once. - -(async ( ) => { -// >>>>> start of private scope - -/******************************************************************************/ - vAPI.app.onShutdown = ( ) => { staticFilteringReverseLookup.shutdown(); io.updateStop(); @@ -312,10 +305,10 @@ const onHiddenSettingsReady = async ( ) => { } // Maybe override default cache storage - const cacheBackend = await cacheStorage.select( + µb.supportStats.cacheBackend = await cacheStorage.select( µb.hiddenSettings.cacheStorageAPI ); - ubolog(`Backend storage for cache will be ${cacheBackend}`); + ubolog(`Backend storage for cache will be ${µb.supportStats.cacheBackend}`); }; /******************************************************************************/ @@ -379,6 +372,9 @@ const createDefaultProps = ( ) => { /******************************************************************************/ +(async ( ) => { +// >>>>> start of async/await scope + try { ubolog(`Start sequence of loading storage-based data ${Date.now()-vAPI.T0} ms after launch`); @@ -506,5 +502,7 @@ if ( selfieIsValid ) { } ubolog(`All ready ${µb.supportStats.allReadyAfter} after launch`); -// <<<<< end of private scope +µb.isReadyResolve(); + +// <<<<< end of async/await scope })();