1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-06 19:02:30 +01: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? // Cosmetic filter?
if ( v.startsWith('##') ) { if ( v.startsWith('##') ) {
callback(hostname + v); callback(hostname + v, true);
return; return;
} }
@ -1188,8 +1188,8 @@ const onDialogClicked = function(ev) {
// We have to exit from preview mode: this guarantees matching elements // We have to exit from preview mode: this guarantees matching elements
// will be found for the candidate filter. // will be found for the candidate filter.
filterToDOMInterface.preview(false); filterToDOMInterface.preview(false);
userFilterFromCandidate(filter => { userFilterFromCandidate((filter = undefined, isCosmetic = false) => {
if ( !filter ) { return; } if ( filter === undefined ) { return; }
vAPI.messaging.send( vAPI.messaging.send(
'elementPicker', 'elementPicker',
{ {
@ -1197,7 +1197,8 @@ const onDialogClicked = function(ev) {
autoComment: true, autoComment: true,
filters: filter, filters: filter,
origin: window.location.origin, origin: window.location.origin,
pageDomain: window.location.hostname pageDomain: window.location.hostname,
killCache: isCosmetic === false,
} }
); );
filterToDOMInterface.preview(rawFilterFromTextarea(), true); filterToDOMInterface.preview(rawFilterFromTextarea(), true);

View File

@ -468,6 +468,12 @@
this.redirectEngine.freeze(); this.redirectEngine.freeze();
this.staticExtFilteringEngine.freeze(); this.staticExtFilteringEngine.freeze();
this.selfieManager.destroy(); 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 => { const onLoaded = details => {