better/safer fix for #587

This commit is contained in:
gorhill 2015-01-23 15:02:47 -05:00
parent 448931248d
commit f718e8e1f2
2 changed files with 7 additions and 2 deletions

View File

@ -148,7 +148,7 @@ var filteringHandler = function(details) {
// If no filters were found, maybe the script was injected before uBlock's // If no filters were found, maybe the script was injected before uBlock's
// process was fully initialized. When this happens, pages won't be // process was fully initialized. When this happens, pages won't be
// cleaned right after browser launch. // cleaned right after browser launch.
vAPI.contentscriptStartInjected = details && details.cosmeticHide.length !== 0; vAPI.contentscriptStartInjected = details && details.ready;
// Cleanup before leaving // Cleanup before leaving
localMessager.close(); localMessager.close();

View File

@ -933,7 +933,6 @@ FilterContainer.prototype.fromSelfie = function(selfie) {
return dict; return dict;
}; };
this.frozen = true;
this.acceptedCount = selfie.acceptedCount; this.acceptedCount = selfie.acceptedCount;
this.duplicateCount = selfie.duplicateCount; this.duplicateCount = selfie.duplicateCount;
this.hostnameFilters = dictFromSelfie(selfie.hostnameSpecificFilters); this.hostnameFilters = dictFromSelfie(selfie.hostnameSpecificFilters);
@ -951,6 +950,7 @@ FilterContainer.prototype.fromSelfie = function(selfie) {
this.highHighGenericDonthide = selfie.highHighGenericDonthide; this.highHighGenericDonthide = selfie.highHighGenericDonthide;
this.highHighGenericHideCount = selfie.highHighGenericHideCount; this.highHighGenericHideCount = selfie.highHighGenericHideCount;
this.highHighGenericDonthideCount = selfie.highHighGenericDonthideCount; this.highHighGenericDonthideCount = selfie.highHighGenericDonthideCount;
this.frozen = true;
}; };
/******************************************************************************/ /******************************************************************************/
@ -1127,7 +1127,12 @@ FilterContainer.prototype.retrieveDomainSelectors = function(request) {
var domain = µb.URI.domainFromHostname(hostname) || hostname; var domain = µb.URI.domainFromHostname(hostname) || hostname;
var pos = domain.indexOf('.'); var pos = domain.indexOf('.');
// https://github.com/gorhill/uBlock/issues/587
// r.ready will tell the content script the cosmetic filtering engine is
// up and ready.
var r = { var r = {
ready: this.frozen,
domain: domain, domain: domain,
entity: pos === -1 ? domain : domain.slice(0, pos - domain.length), entity: pos === -1 ? domain : domain.slice(0, pos - domain.length),
skipCosmeticFiltering: this.acceptedCount === 0, skipCosmeticFiltering: this.acceptedCount === 0,