Add ability to suspend network request handler at will

This works only for platforms supporting the return of
Promise by network listeners, i.e. only Firefox at this
point.

When filter lists are reloaded[1], there is a small
time window in which some network requests which should
have normally been blocked are not being blocked
because the static network filtering engine may not
have yet loaded all the filters in memory

This is now addressed by suspending the network request
handler when filter lists are reloaded -- again, this
works only on supported platforms.

[1] Examples: when a filter list update session
    completes; when user filters change, when
    adding/removing filter lists.
This commit is contained in:
Raymond Hill 2019-06-30 10:09:27 -04:00
parent c1bdc123f2
commit 1dfdc40e09
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
7 changed files with 275 additions and 508 deletions

View File

@ -1049,9 +1049,9 @@ vAPI.messaging.broadcast = function(message) {
// https://github.com/gorhill/uBlock/issues/3497 // https://github.com/gorhill/uBlock/issues/3497
// Prevent web pages from interfering with uBO's element picker // Prevent web pages from interfering with uBO's element picker
// https://github.com/uBlockOrigin/uBlock-issues/issues/550 // https://github.com/uBlockOrigin/uBlock-issues/issues/550
// A specific secret can be used for at most one second. // Support using a new secret for every network request.
vAPI.warSecret = (function() { vAPI.warSecret = (( ) => {
const generateSecret = ( ) => { const generateSecret = ( ) => {
return Math.floor(Math.random() * 982451653 + 982451653).toString(36) + return Math.floor(Math.random() * 982451653 + 982451653).toString(36) +
Math.floor(Math.random() * 982451653 + 982451653).toString(36); Math.floor(Math.random() * 982451653 + 982451653).toString(36);
@ -1072,7 +1072,7 @@ vAPI.warSecret = (function() {
secrets.splice(pos, 1); secrets.splice(pos, 1);
}; };
chrome.webRequest.onBeforeRequest.addListener( browser.webRequest.onBeforeRequest.addListener(
guard, guard,
{ {
urls: [ root + 'web_accessible_resources/*' ] urls: [ root + 'web_accessible_resources/*' ]
@ -1095,59 +1095,106 @@ vAPI.warSecret = (function() {
}; };
})(); })();
vAPI.net = { /******************************************************************************/
listenerMap: new WeakMap(),
// legacy Chromium understands only these network request types. vAPI.Net = class {
validTypes: (function() { constructor() {
let types = new Set([ this.validTypes = new Set();
'main_frame', {
'sub_frame', const wrrt = browser.webRequest.ResourceType;
'stylesheet', for ( const typeKey in wrrt ) {
'script',
'image',
'object',
'xmlhttprequest',
'other'
]);
let wrrt = browser.webRequest.ResourceType;
if ( wrrt instanceof Object ) {
for ( let typeKey in wrrt ) {
if ( wrrt.hasOwnProperty(typeKey) ) { if ( wrrt.hasOwnProperty(typeKey) ) {
types.add(wrrt[typeKey]); this.validTypes.add(wrrt[typeKey]);
} }
} }
} }
this.suspendableListener = undefined;
this.listenerMap = new WeakMap();
this.suspendDepth = 0;
browser.webRequest.onBeforeRequest.addListener(
details => {
this.normalizeDetails(details);
if ( this.suspendDepth === 0 ) {
if ( this.suspendableListener === undefined ) { return; }
return this.suspendableListener(details);
}
if ( details.tabId < 0 ) { return; }
return this.suspendOneRequest(details);
},
this.denormalizeFilters({ urls: [ 'http://*/*', 'https://*/*' ] }),
[ 'blocking' ]
);
}
normalizeDetails(/* details */) {
}
denormalizeFilters(filters) {
const urls = filters.urls || [ '<all_urls>' ];
let types = filters.types;
if ( Array.isArray(types) ) {
types = this.denormalizeTypes(types);
}
if (
(this.validTypes.has('websocket')) &&
(types === undefined || types.indexOf('websocket') !== -1) &&
(urls.indexOf('<all_urls>') === -1)
) {
if ( urls.indexOf('ws://*/*') === -1 ) {
urls.push('ws://*/*');
}
if ( urls.indexOf('wss://*/*') === -1 ) {
urls.push('wss://*/*');
}
}
return { types, urls };
}
denormalizeTypes(types) {
return types; return types;
})(),
denormalizeFilters: null,
normalizeDetails: null,
addListener: function(which, clientListener, filters, options) {
if ( typeof this.denormalizeFilters === 'function' ) {
filters = this.denormalizeFilters(filters);
} }
let actualListener; addListener(which, clientListener, filters, options) {
if ( typeof this.normalizeDetails === 'function' ) { const actualFilters = this.denormalizeFilters(filters);
actualListener = function(details) { const actualListener = this.makeNewListenerProxy(clientListener);
vAPI.net.normalizeDetails(details); browser.webRequest[which].addListener(
actualListener,
actualFilters,
options
);
}
setSuspendableListener(listener) {
this.suspendableListener = listener;
}
removeListener(which, clientListener) {
const actualListener = this.listenerMap.get(clientListener);
if ( actualListener === undefined ) { return; }
this.listenerMap.delete(clientListener);
browser.webRequest[which].removeListener(actualListener);
}
makeNewListenerProxy(clientListener) {
const actualListener = details => {
this.normalizeDetails(details);
return clientListener(details); return clientListener(details);
}; };
this.listenerMap.set(clientListener, actualListener); this.listenerMap.set(clientListener, actualListener);
return actualListener;
} }
browser.webRequest[which].addListener( suspendOneRequest() {
actualListener || clientListener, }
filters, unsuspendAllRequests() {
options }
); suspend(force = false) {
}, if ( this.canSuspend() || force ) {
removeListener: function(which, clientListener) { this.suspendDepth += 1;
let actualListener = this.listenerMap.get(clientListener); }
if ( actualListener !== undefined ) { }
this.listenerMap.delete(clientListener); unsuspend() {
if ( this.suspendDepth === 0 ) { return; }
this.suspendDepth -= 1;
if ( this.suspendDepth !== 0 ) { return; }
this.unsuspendAllRequests(this.suspendableListener);
}
canSuspend() {
return false;
} }
browser.webRequest[which].removeListener(
actualListener || clientListener
);
},
}; };
/******************************************************************************/ /******************************************************************************/

View File

@ -25,9 +25,9 @@
/******************************************************************************/ /******************************************************************************/
(function() { (( ) => {
// https://github.com/uBlockOrigin/uBlock-issues/issues/407 // https://github.com/uBlockOrigin/uBlock-issues/issues/407
if ( vAPI.webextFlavor.soup.has('firefox') ) { return; } if ( vAPI.webextFlavor.soup.has('chromium') === false ) { return; }
const extToTypeMap = new Map([ const extToTypeMap = new Map([
['eot','font'],['otf','font'],['svg','font'],['ttf','font'],['woff','font'],['woff2','font'], ['eot','font'],['otf','font'],['svg','font'],['ttf','font'],['woff','font'],['woff2','font'],
@ -35,33 +35,7 @@
['gif','image'],['ico','image'],['jpeg','image'],['jpg','image'],['png','image'],['webp','image'] ['gif','image'],['ico','image'],['jpeg','image'],['jpg','image'],['png','image'],['webp','image']
]); ]);
// https://www.reddit.com/r/uBlockOrigin/comments/9vcrk3/bug_in_ubo_1173_betas_when_saving_files_hosted_on/ const headerValue = (headers, name) => {
// Some types can be mapped from 'other', thus include 'other' if and
// only if the caller is interested in at least one of those types.
const denormalizeTypes = function(aa) {
if ( aa.length === 0 ) {
return Array.from(vAPI.net.validTypes);
}
const out = new Set();
let i = aa.length;
while ( i-- ) {
const type = aa[i];
if ( vAPI.net.validTypes.has(type) ) {
out.add(type);
}
}
if ( out.has('other') === false ) {
for ( const type of extToTypeMap.values() ) {
if ( out.has(type) ) {
out.add('other');
break;
}
}
}
return Array.from(out);
};
const headerValue = function(headers, name) {
let i = headers.length; let i = headers.length;
while ( i-- ) { while ( i-- ) {
if ( headers[i].name.toLowerCase() === name ) { if ( headers[i].name.toLowerCase() === name ) {
@ -73,7 +47,14 @@
const parsedURL = new URL('https://www.example.org/'); const parsedURL = new URL('https://www.example.org/');
vAPI.net.normalizeDetails = function(details) { // Extend base class to normalize as per platform.
vAPI.Net = class extends vAPI.Net {
constructor() {
super();
this.suspendedTabIds = new Set();
}
normalizeDetails(details) {
// Chromium 63+ supports the `initiator` property, which contains // Chromium 63+ supports the `initiator` property, which contains
// the URL of the origin from which the network request was made. // the URL of the origin from which the network request was made.
if ( if (
@ -126,71 +107,40 @@
return; return;
} }
} }
};
vAPI.net.denormalizeFilters = function(filters) {
const urls = filters.urls || [ '<all_urls>' ];
let types = filters.types;
if ( Array.isArray(types) ) {
types = denormalizeTypes(types);
} }
if ( // https://www.reddit.com/r/uBlockOrigin/comments/9vcrk3/
(vAPI.net.validTypes.has('websocket')) && // Some types can be mapped from 'other', thus include 'other' if and
(types === undefined || types.indexOf('websocket') !== -1) && // only if the caller is interested in at least one of those types.
(urls.indexOf('<all_urls>') === -1) denormalizeTypes(types) {
) { if ( types.length === 0 ) {
if ( urls.indexOf('ws://*/*') === -1 ) { return Array.from(this.validTypes);
urls.push('ws://*/*');
} }
if ( urls.indexOf('wss://*/*') === -1 ) { const out = new Set();
urls.push('wss://*/*'); for ( const type of types ) {
if ( this.validTypes.has(type) ) {
out.add(type);
} }
} }
return { types, urls }; if ( out.has('other') === false ) {
}; for ( const type of extToTypeMap.values() ) {
})(); if ( out.has(type) ) {
out.add('other');
/******************************************************************************/ break;
}
// https://github.com/gorhill/uBlock/issues/2067 }
// Experimental: Block everything until uBO is fully ready. }
return Array.from(out);
vAPI.net.onBeforeReady = vAPI.net.onBeforeReady || (function() { }
// https://github.com/uBlockOrigin/uBlock-issues/issues/407 suspendOneRequest(details) {
if ( vAPI.webextFlavor.soup.has('firefox') ) { return; } this.suspendedTabIds.add(details.tabId);
let pendings;
const handler = function(details) {
if ( pendings === undefined ) { return; }
if ( details.tabId < 0 ) { return; }
pendings.add(details.tabId);
return { cancel: true }; return { cancel: true };
}; }
unsuspendAllRequests() {
return { for ( const tabId of this.suspendedTabIds ) {
experimental: true,
start: function() {
pendings = new Set();
browser.webRequest.onBeforeRequest.addListener(
handler,
{ urls: [ 'http://*/*', 'https://*/*' ] },
[ 'blocking' ]
);
},
// https://github.com/gorhill/uBlock/issues/2067
// Force-reload tabs for which network requests were blocked
// during launch. This can happen only if tabs were "suspended".
stop: function() {
if ( pendings === undefined ) { return; }
browser.webRequest.onBeforeRequest.removeListener(handler);
for ( const tabId of pendings ) {
vAPI.tabs.reload(tabId); vAPI.tabs.reload(tabId);
} }
pendings = undefined; this.suspendedTabIds.clear();
}, }
}; };
})(); })();
@ -200,7 +150,10 @@ vAPI.net.onBeforeReady = vAPI.net.onBeforeReady || (function() {
// Use `X-DNS-Prefetch-Control` to workaround Chromium's disregard of the // Use `X-DNS-Prefetch-Control` to workaround Chromium's disregard of the
// setting "Predict network actions to improve page load performance". // setting "Predict network actions to improve page load performance".
vAPI.prefetching = (function() { vAPI.prefetching = (( ) => {
// https://github.com/uBlockOrigin/uBlock-issues/issues/407
if ( vAPI.webextFlavor.soup.has('chromium') === false ) { return; }
let listening = false; let listening = false;
const onHeadersReceived = function(details) { const onHeadersReceived = function(details) {

View File

@ -25,14 +25,14 @@
/******************************************************************************/ /******************************************************************************/
(function() { (( ) => {
// https://github.com/uBlockOrigin/uBlock-issues/issues/407 // https://github.com/uBlockOrigin/uBlock-issues/issues/407
if ( vAPI.webextFlavor.soup.has('firefox') === false ) { return; } if ( vAPI.webextFlavor.soup.has('firefox') === false ) { return; }
// https://github.com/gorhill/uBlock/issues/2950 // https://github.com/gorhill/uBlock/issues/2950
// Firefox 56 does not normalize URLs to ASCII, uBO must do this itself. // Firefox 56 does not normalize URLs to ASCII, uBO must do this itself.
// https://bugzilla.mozilla.org/show_bug.cgi?id=945240 // https://bugzilla.mozilla.org/show_bug.cgi?id=945240
const evalMustPunycode = function() { const evalMustPunycode = ( ) => {
return vAPI.webextFlavor.soup.has('firefox') && return vAPI.webextFlavor.soup.has('firefox') &&
vAPI.webextFlavor.major < 57; vAPI.webextFlavor.major < 57;
}; };
@ -45,32 +45,23 @@
mustPunycode = evalMustPunycode(); mustPunycode = evalMustPunycode();
}, { once: true }); }, { once: true });
const denormalizeTypes = function(aa) {
if ( aa.length === 0 ) {
return Array.from(vAPI.net.validTypes);
}
const out = new Set();
let i = aa.length;
while ( i-- ) {
let type = aa[i];
if ( vAPI.net.validTypes.has(type) ) {
out.add(type);
}
if ( type === 'image' && vAPI.net.validTypes.has('imageset') ) {
out.add('imageset');
}
if ( type === 'sub_frame' ) {
out.add('object');
}
}
return Array.from(out);
};
const punycode = self.punycode; const punycode = self.punycode;
const reAsciiHostname = /^https?:\/\/[0-9a-z_.:@-]+[/?#]/; const reAsciiHostname = /^https?:\/\/[0-9a-z_.:@-]+[/?#]/;
const parsedURL = new URL('about:blank'); const parsedURL = new URL('about:blank');
vAPI.net.normalizeDetails = function(details) { // Related issues:
// - https://github.com/gorhill/uBlock/issues/1327
// - https://github.com/uBlockOrigin/uBlock-issues/issues/128
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1503721
// Extend base class to normalize as per platform.
vAPI.Net = class extends vAPI.Net {
constructor() {
super();
this.pendingRequests = [];
}
normalizeDetails(details) {
if ( mustPunycode && !reAsciiHostname.test(details.url) ) { if ( mustPunycode && !reAsciiHostname.test(details.url) ) {
parsedURL.href = details.url; parsedURL.href = details.url;
details.url = details.url.replace( details.url = details.url.replace(
@ -107,80 +98,47 @@
} }
} }
} }
};
vAPI.net.denormalizeFilters = function(filters) {
const urls = filters.urls || [ '<all_urls>' ];
let types = filters.types;
if ( Array.isArray(types) ) {
types = denormalizeTypes(types);
} }
if ( denormalizeTypes(types) {
(vAPI.net.validTypes.has('websocket')) && if ( types.length === 0 ) {
(types === undefined || types.indexOf('websocket') !== -1) && return Array.from(this.validTypes);
(urls.indexOf('<all_urls>') === -1)
) {
if ( urls.indexOf('ws://*/*') === -1 ) {
urls.push('ws://*/*');
} }
if ( urls.indexOf('wss://*/*') === -1 ) { const out = new Set();
urls.push('wss://*/*'); for ( const type of types ) {
if ( this.validTypes.has(type) ) {
out.add(type);
}
if ( type === 'image' && this.validTypes.has('imageset') ) {
out.add('imageset');
}
if ( type === 'sub_frame' ) {
out.add('object');
} }
} }
return { types, urls }; return Array.from(out);
}; }
})(); suspendOneRequest(details) {
/******************************************************************************/
// Related issues:
// - https://github.com/gorhill/uBlock/issues/1327
// - https://github.com/uBlockOrigin/uBlock-issues/issues/128
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1503721
vAPI.net.onBeforeReady = vAPI.net.onBeforeReady || (function() {
// https://github.com/uBlockOrigin/uBlock-issues/issues/407
if ( vAPI.webextFlavor.soup.has('firefox') === false ) { return; }
let pendingSet;
const handler = function(details) {
if ( pendingSet === undefined ) { return; }
if ( details.tabId < 0 ) { return; }
const pending = { const pending = {
details: Object.assign({}, details), details: Object.assign({}, details),
resolve: undefined, resolve: undefined,
promise: undefined promise: undefined
}; };
pending.promise = new Promise(function(resolve) { pending.promise = new Promise(function(resolve) {
pending.resolve = resolve; pending.resolve = resolve;
}); });
this.pendingRequests.push(pending);
pendingSet.push(pending);
return pending.promise; return pending.promise;
}; }
unsuspendAllRequests(resolver) {
return { const pendingRequests = this.pendingRequests;
start: function() { this.pendingRequests = [];
pendingSet = []; for ( const entry of pendingRequests ) {
browser.webRequest.onBeforeRequest.addListener(
handler,
{ urls: [ 'http://*/*', 'https://*/*' ] },
[ 'blocking' ]
);
},
stop: function(resolver) {
if ( pendingSet === undefined ) { return; }
const resolvingSet = pendingSet; // not sure if re-entrance
pendingSet = undefined; // can occur...
for ( const entry of resolvingSet ) {
vAPI.net.normalizeDetails(entry.details);
entry.resolve(resolver(entry.details)); entry.resolve(resolver(entry.details));
} }
}, }
canSuspend() {
return true;
}
}; };
})(); })();

View File

@ -1,184 +0,0 @@
/*******************************************************************************
uBlock Origin - a browser extension to block requests.
Copyright (C) 2017-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
Home: https://github.com/gorhill/uBlock
*/
// For background page
'use strict';
/******************************************************************************/
(function() {
// https://github.com/gorhill/uBlock/issues/2950
// Firefox 56 does not normalize URLs to ASCII, uBO must do this itself.
// https://bugzilla.mozilla.org/show_bug.cgi?id=945240
const evalMustPunycode = function() {
return vAPI.webextFlavor.soup.has('firefox') &&
vAPI.webextFlavor.major < 57;
};
let mustPunycode = evalMustPunycode();
// The real actual webextFlavor value may not be set in stone, so listen
// for possible future changes.
window.addEventListener('webextFlavor', ( ) => {
mustPunycode = evalMustPunycode();
}, { once: true });
const denormalizeTypes = function(aa) {
if ( aa.length === 0 ) {
return Array.from(vAPI.net.validTypes);
}
const out = new Set();
let i = aa.length;
while ( i-- ) {
let type = aa[i];
if ( vAPI.net.validTypes.has(type) ) {
out.add(type);
}
if ( type === 'image' && vAPI.net.validTypes.has('imageset') ) {
out.add('imageset');
}
if ( type === 'sub_frame' ) {
out.add('object');
}
}
return Array.from(out);
};
const punycode = self.punycode;
const reAsciiHostname = /^https?:\/\/[0-9a-z_.:@-]+[/?#]/;
const parsedURL = new URL('about:blank');
vAPI.net.normalizeDetails = function(details) {
if ( mustPunycode && !reAsciiHostname.test(details.url) ) {
parsedURL.href = details.url;
details.url = details.url.replace(
parsedURL.hostname,
punycode.toASCII(parsedURL.hostname)
);
}
const type = details.type;
// https://github.com/gorhill/uBlock/issues/1493
// Chromium 49+/WebExtensions support a new request type: `ping`,
// which is fired as a result of using `navigator.sendBeacon`.
if ( type === 'ping' ) {
details.type = 'beacon';
return;
}
if ( type === 'imageset' ) {
details.type = 'image';
return;
}
// https://github.com/uBlockOrigin/uBlock-issues/issues/345
// Re-categorize an embedded object as a `sub_frame` if its
// content type is that of a HTML document.
if ( type === 'object' && Array.isArray(details.responseHeaders) ) {
for ( const header of details.responseHeaders ) {
if ( header.name.toLowerCase() === 'content-type' ) {
if ( header.value.startsWith('text/html') ) {
details.type = 'sub_frame';
}
break;
}
}
}
};
vAPI.net.denormalizeFilters = function(filters) {
let urls = filters.urls || [ '<all_urls>' ];
if ( urls.indexOf('https://*/*') !== -1 ) {
urls = [ '<all_urls>' ];
}
let types = filters.types;
if ( Array.isArray(types) ) {
types = denormalizeTypes(types);
}
if (
(vAPI.net.validTypes.has('websocket')) &&
(types === undefined || types.indexOf('websocket') !== -1) &&
(urls.indexOf('<all_urls>') === -1)
) {
if ( urls.indexOf('ws://*/*') === -1 ) {
urls.push('ws://*/*');
}
if ( urls.indexOf('wss://*/*') === -1 ) {
urls.push('wss://*/*');
}
}
return { types, urls };
};
})();
/******************************************************************************/
// Related issues:
// - https://github.com/gorhill/uBlock/issues/1327
// - https://github.com/uBlockOrigin/uBlock-issues/issues/128
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1503721
vAPI.net.onBeforeReady = (function() {
let pendings;
const handler = function(details) {
if ( pendings === undefined ) { return; }
if ( details.tabId < 0 ) { return; }
const pending = {
details: Object.assign({}, details),
resolve: undefined,
promise: undefined
};
pending.promise = new Promise(function(resolve) {
pending.resolve = resolve;
});
pendings.push(pending);
return pending.promise;
};
return {
start: function() {
pendings = [];
browser.webRequest.onBeforeRequest.addListener(
handler,
{ urls: [ 'http://*/*', 'https://*/*' ] },
[ 'blocking' ]
);
},
stop: function(resolver) {
if ( pendings === undefined ) { return; }
for ( const pending of pendings ) {
vAPI.net.normalizeDetails(pending.details);
pending.resolve(resolver(pending.details));
}
pendings = undefined;
},
};
})();
/******************************************************************************/

View File

@ -660,6 +660,8 @@
this.staticNetFilteringEngine.freeze(); this.staticNetFilteringEngine.freeze();
this.staticExtFilteringEngine.freeze(); this.staticExtFilteringEngine.freeze();
this.redirectEngine.freeze(); this.redirectEngine.freeze();
vAPI.net.unsuspend();
vAPI.storage.set({ 'availableFilterLists': this.availableFilterLists }); vAPI.storage.set({ 'availableFilterLists': this.availableFilterLists });
vAPI.messaging.broadcast({ vAPI.messaging.broadcast({
@ -702,8 +704,7 @@
}; };
const onFilterListsReady = lists => { const onFilterListsReady = lists => {
this.availableFilterLists = lists; vAPI.net.suspend();
this.redirectEngine.reset(); this.redirectEngine.reset();
this.staticExtFilteringEngine.reset(); this.staticExtFilteringEngine.reset();
this.staticNetFilteringEngine.reset(); this.staticNetFilteringEngine.reset();

View File

@ -25,7 +25,7 @@
// Start isolation from global scope // Start isolation from global scope
µBlock.webRequest = (function() { µBlock.webRequest = (( ) => {
/******************************************************************************/ /******************************************************************************/
@ -1028,26 +1028,20 @@ const strictBlockBypasser = {
/******************************************************************************/ /******************************************************************************/
return { return {
start: (function() { start: (( ) => {
vAPI.net = new vAPI.Net();
if ( if (
vAPI.net.onBeforeReady instanceof Object && vAPI.net.canSuspend() &&
(
vAPI.net.onBeforeReady.experimental !== true &&
µBlock.hiddenSettings.suspendTabsUntilReady !== 'no' || µBlock.hiddenSettings.suspendTabsUntilReady !== 'no' ||
vAPI.net.onBeforeReady.experimental && vAPI.net.canSuspend() !== true &&
µBlock.hiddenSettings.suspendTabsUntilReady === 'yes' µBlock.hiddenSettings.suspendTabsUntilReady === 'yes'
)
) { ) {
vAPI.net.onBeforeReady.start(); vAPI.net.suspend(true);
} }
return function() { return function() {
vAPI.net.addListener( vAPI.net.setSuspendableListener(onBeforeRequest);
'onBeforeRequest',
onBeforeRequest,
{ urls: [ 'http://*/*', 'https://*/*' ] },
[ 'blocking' ]
);
vAPI.net.addListener( vAPI.net.addListener(
'onHeadersReceived', 'onHeadersReceived',
onHeadersReceived, onHeadersReceived,
@ -1074,9 +1068,7 @@ return {
[ 'blocking', 'requestBody' ] [ 'blocking', 'requestBody' ]
); );
} }
if ( vAPI.net.onBeforeReady instanceof Object ) { vAPI.net.unsuspend();
vAPI.net.onBeforeReady.stop(onBeforeRequest);
}
}; };
})(), })(),

View File

@ -25,7 +25,7 @@ cp platform/chromium/*.json $DES/
cp LICENSE.txt $DES/ cp LICENSE.txt $DES/
cp platform/thunderbird/manifest.json $DES/ cp platform/thunderbird/manifest.json $DES/
cp platform/thunderbird/vapi-webrequest.js $DES/js/ cp platform/firefox/vapi-webrequest.js $DES/js/
cp platform/firefox/vapi-usercss.js $DES/js/ cp platform/firefox/vapi-usercss.js $DES/js/
echo "*** uBlock0.thunderbird: concatenating content scripts" echo "*** uBlock0.thunderbird: concatenating content scripts"