Fix generichide not being evaluated for local context

Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/5704
This commit is contained in:
Raymond Hill 2019-06-03 06:37:39 -04:00
parent 27911e918c
commit 2eb9b726a5
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 25 additions and 38 deletions

View file

@ -547,12 +547,29 @@ var onMessage = function(request, sender, callback) {
) {
break;
}
const noCosmeticFiltering = pageStore.noCosmeticFiltering === true;
response = {
collapseBlocked: µb.userSettings.collapseBlocked,
noCosmeticFiltering: pageStore.noCosmeticFiltering === true,
noGenericCosmeticFiltering:
pageStore.noGenericCosmeticFiltering === true
noCosmeticFiltering,
noGenericCosmeticFiltering: noCosmeticFiltering,
};
// https://github.com/uBlockOrigin/uAssets/issues/5704
// `generichide` must be evaluated in the frame context.
if ( noCosmeticFiltering === false ) {
const genericHide =
µb.staticNetFilteringEngine.matchStringGenericHide(request.url);
response.noGenericCosmeticFiltering = genericHide === 2;
if ( genericHide !== 0 && µb.logger.enabled ) {
µBlock.filteringContext
.duplicate()
.fromTabId(tabId)
.setURL(request.url)
.setRealm('network')
.setType('generichide')
.setFilter(µb.staticNetFilteringEngine.toLogData())
.toLogger();
}
}
request.tabId = tabId;
request.frameId = frameId;
request.hostname = µb.URI.hostnameFromURI(request.url);
@ -572,14 +589,11 @@ var onMessage = function(request, sender, callback) {
break;
case 'retrieveGenericCosmeticSelectors':
if ( pageStore && pageStore.getGenericCosmeticFilteringSwitch() ) {
request.tabId = tabId;
request.frameId = frameId;
response = {
result: µb.cosmeticFilteringEngine
.retrieveGenericSelectors(request)
};
}
request.tabId = tabId;
request.frameId = frameId;
response = {
result: µb.cosmeticFilteringEngine.retrieveGenericSelectors(request)
};
break;
default:

View file

@ -310,28 +310,6 @@ PageStore.prototype.init = function(tabId, context) {
.toLogger();
}
// Support `generichide` filter option.
this.noGenericCosmeticFiltering = masterSwitch !== true;
if ( this.noGenericCosmeticFiltering !== true ) {
this.noGenericCosmeticFiltering = this.noCosmeticFiltering;
if ( this.noGenericCosmeticFiltering !== true ) {
let result = µb.staticNetFilteringEngine.matchStringGenericHide(
tabContext.normalURL
);
this.noGenericCosmeticFiltering = result === 2;
if (
result !== 0 &&
µb.logger.enabled &&
context === 'tabCommitted'
) {
fctxt.setRealm('network')
.setType('generichide')
.setFilter(µb.staticNetFilteringEngine.toLogData())
.toLogger();
}
}
}
return this;
};
@ -429,11 +407,6 @@ PageStore.prototype.getSpecificCosmeticFilteringSwitch = function() {
return this.noCosmeticFiltering !== true;
};
PageStore.prototype.getGenericCosmeticFilteringSwitch = function() {
return this.noGenericCosmeticFiltering !== true &&
this.noCosmeticFiltering !== true;
};
PageStore.prototype.toggleNetFilteringSwitch = function(url, scope, state) {
µb.toggleNetFilteringSwitch(url, scope, state);
this.netFilteringCache.empty();