1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-14 23:12:28 +02:00

Invalidate browser's memory cache after using element picker

Related reports:
- https://www.reddit.com/r/uBlockOrigin/comments/cj7g7m/
- https://www.reddit.com/r/uBlockOrigin/comments/cnq0bi/

The browser cache will be invalidated only when creating
static network filter through the element picker.

As per @gwarser's arguments in favor of implementing
usage of webRequest.handlerBehaviorChanged():
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/handlerBehaviorChanged
This commit is contained in:
Raymond Hill 2019-08-09 09:31:20 -04:00
parent aa701484e7
commit 5e1f4d7906
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 11 additions and 4 deletions

View File

@ -1040,7 +1040,7 @@ const userFilterFromCandidate = function(callback) {
// Cosmetic filter?
if ( v.startsWith('##') ) {
callback(hostname + v);
callback(hostname + v, true);
return;
}
@ -1188,8 +1188,8 @@ const onDialogClicked = function(ev) {
// We have to exit from preview mode: this guarantees matching elements
// will be found for the candidate filter.
filterToDOMInterface.preview(false);
userFilterFromCandidate(filter => {
if ( !filter ) { return; }
userFilterFromCandidate((filter = undefined, isCosmetic = false) => {
if ( filter === undefined ) { return; }
vAPI.messaging.send(
'elementPicker',
{
@ -1197,7 +1197,8 @@ const onDialogClicked = function(ev) {
autoComment: true,
filters: filter,
origin: window.location.origin,
pageDomain: window.location.hostname
pageDomain: window.location.hostname,
killCache: isCosmetic === false,
}
);
filterToDOMInterface.preview(rawFilterFromTextarea(), true);

View File

@ -468,6 +468,12 @@
this.redirectEngine.freeze();
this.staticExtFilteringEngine.freeze();
this.selfieManager.destroy();
// https://www.reddit.com/r/uBlockOrigin/comments/cj7g7m/
// https://www.reddit.com/r/uBlockOrigin/comments/cnq0bi/
if ( options.killCache ) {
browser.webRequest.handlerBehaviorChanged();
}
};
const onLoaded = details => {