From 87feb47b51202cb8464eab91597b706965a224f3 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 19 Feb 2019 12:30:37 -0500 Subject: [PATCH] Support disabling `suspendTabsUntilReady` in Firefox The value of `suspendTabsUntilReady` was disregarded in Firefox and uBO defaulted to always defer tab loading until it was ready. This commit allows to disable the deferring of tab loading in Firefox. The new valid values for `suspendTabsUntilReady` are: - `unset`: leave it to the platform to pick the optimal behavior (default) - `no`: do no suspend tab loading at launch time - `yes`: suspend tab loading at launch time --- src/js/background.js | 7 ++++++- src/js/storage.js | 6 ++++++ src/js/traffic.js | 6 ++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index 0e8e5e807..abf774532 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -53,7 +53,7 @@ const µBlock = (function() { // jshint ignore:line requestJournalProcessPeriod: 1000, selfieAfter: 11, strictBlockingBypassDuration: 120, - suspendTabsUntilReady: false, + suspendTabsUntilReady: 'unset', userResourcesLocation: 'unset' }; @@ -104,6 +104,11 @@ const µBlock = (function() { // jshint ignore:line if ( out.hasOwnProperty(k) ) { out[k] = o[k]; } } self.log.verbosity = out.consoleLogLevel; + if ( typeof out.suspendTabsUntilReady === 'boolean' ) { + out.suspendTabsUntilReady = out.suspendTabsUntilReady + ? 'yes' + : 'unset'; + } } } catch(ex) { diff --git a/src/js/storage.js b/src/js/storage.js index 71b5c0c09..a536f90eb 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -110,6 +110,12 @@ this.hiddenSettings[key] = hs[key]; } } + if ( typeof this.hiddenSettings.suspendTabsUntilReady === 'boolean' ) { + this.hiddenSettings.suspendTabsUntilReady = + this.hiddenSettings.suspendTabsUntilReady + ? 'yes' + : 'unset'; + } } if ( vAPI.localStorage.getItem('immediateHiddenSettings') === null ) { this.saveImmediateHiddenSettings(); diff --git a/src/js/traffic.js b/src/js/traffic.js index 372e5bd7a..0ddd3dfc9 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -1002,8 +1002,10 @@ return { if ( vAPI.net.onBeforeReady instanceof Object && ( - vAPI.net.onBeforeReady.experimental !== true || - µBlock.hiddenSettings.suspendTabsUntilReady + vAPI.net.onBeforeReady.experimental !== true && + µBlock.hiddenSettings.suspendTabsUntilReady !== 'no' || + vAPI.net.onBeforeReady.experimental && + µBlock.hiddenSettings.suspendTabsUntilReady === 'yes' ) ) { vAPI.net.onBeforeReady.start();